Skip to content

A color picker made using python and tkinter library

Notifications You must be signed in to change notification settings

Iranildot/color-picker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

Color Picker

A color picker made using python and tkinter library

Overview

  • SliderFunctions:Manages the functionality related to the color slider, including calculating color positions based on RGB values, handling mouse events for color selection, and updating the UI accordingly.
  • GradientSlider (inherits from SliderFunctions): Represents a graphical slider for selecting colors along a gradient. It uses methods from SliderFunctions to calculate color positions and manage UI events.
  • PickerFunctions: Handles the core functionality for color picking, including converting color formats (RGB to hexadecimal and vice versa), calculating color positions, and updating the UI based on user input.
  • GradientPicker (inherits from PickerFunctions): Implements a color gradient picker interface using methods from PickerFunctions. It allows users to select colors from a gradient canvas and updates corresponding color representations (hexadecimal and RGB).
  • DisplayFunctions: Provides methods to update the display area with a chosen color. It's used by the Display class.
  • Display (inherits from DisplayFunctions): Represents a display area that visually shows the selected color. It updates its background color based on user selections.
  • Key Methods and Functionality: Color Conversion: Methods like convert_color_to_dict in SliderFunctions and PickerFunctions handle conversion between RGB and hexadecimal color formats.
  • Event Handling: Various methods (start_picking, pick_color, stop_picking, on_right_arrow, on_left_arrow, etc.) bind to mouse and keyboard events (<Button-1>, <B1-Motion>, <ButtonRelease-1>, <Right>, <Left>, <KeyPress>) to update color selections and UI components dynamically.
  • Drawing and UI Updates: The draw_slider and draw_gradient methods in GradientSlider and GradientPicker respectively use PIL to generate color gradient images and update the Tkinter canvas with these images.

Usage Example

Below is an example of how you might create and use these classes to create a color picker interface:

from colorpicker import *

color = ColorPicker(initial_color="#555555", theme="DARK").get_color()

print(color)

Output

PS C:\Users\User\Documents\ColorPicker> python .\test.py
{'hexadecimal': '#D54A4A', 'rgb': [213, 74, 74]}

How the app looks like

color picker

About

A color picker made using python and tkinter library

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages