RGB HSV Colour Picker#

rgb-hsv class#

Using tkinter Canvas to display rgba and hsv colour gradients:-

  • Added an hsv colour wheel with ring cursor to show hue and saturation.

  • All linked together using numpy arrays to draw gradients and chequers

    with alpha (opacity).

  • Resulting arrays are imported into tkinter as PPM images.

  • The themed Scale has been changed so that the trough is transparent and

    the slider changed to an upward arrow.

class rgbandhsv.RgbHsvSelect(fr0, enlargement)#

Bases: object

Class to construct rgba, hsv gradients and hsv colour wheel.

Parameters:

fr0 (str) -- parent widget

Return type:

None

ahandle(evt=None)#

Command callback for alpha.

Parameters:

evt (str) -- command handle

bhandle(evt=None)#

Command callback for blue.

Parameters:

evt (str) -- command handle

build()#

Widget construction.

checkhash(evt=None)#

Procedure called by entry for hash.

Parameters:
  • evt (str) -- bind handles

  • Results

  • -------

  • None

checksb(evt=None)#

Procedure called by rgb colour spinboxes.

Parameters:
  • evt (str) -- bind handles

  • Results

  • -------

  • None

checksb100(event=None)#

Procedure called by saturation and value spinboxes.

Parameters:
  • event (str) -- bind handles

  • Results

  • -------

  • None

checksba(evt=None)#

Procedure called by alpha spinbox.

Parameters:
  • evt (str) -- bind handles

  • Results

  • -------

  • None

checksbh(event=None)#

Procedure called by hue spinbox.

Parameters:

event (str) -- bind handles

click_ring(event)#

Procedure called when mouse clicks in colour wheel.

Parameters:

event (str) -- bind handle

Return type:

calls handle for cursor

door_bell(ring)#

Calling procedure from cursor binds.

Parameters:

ring (tuple of int) -- hue, saturation values

drag_ring(event)#

Procedure called when mouse drags cursor.

Parameters:

event (str) -- bind handle

Return type:

calls handle for cursor

ghandle(evt=None)#

Command callback for green.

Parameters:

evt (str) -- command handle

hhandle(evt=None)#

Command callback for hue.

Parameters:

evt (str) -- command handle

overlord(rgb=None, hsv=None)#

Supervisory procedure to control calls from handle functions.

Parameters:
  • rgb (tuple of integers) -- call from rgb

  • hsv (tuple of integers) -- call from hsv

Return type:

draws gradients and sets other colour system

related(h, s, v, r, g, b)#
Creating related Colours, 5 in saturation, 5 for value,

1 complementary

Parameters:
  • h (float) -- hue

  • s (float) -- saturation

  • v (float) -- value

  • r (int) -- red

  • g (int) -- green

  • b (int) -- blue

resize_acan(event)#

Bind function for alpha resizing

Parameters:

event (str)

resize_bcan(event)#

Bind function for blue resizing

Parameters:

event (str)

resize_gcan(event)#

Bind function for green resizing

Parameters:

event (str)

resize_hcan(event)#

Bind function for hue resizing

Parameters:

event (str)

resize_rcan(event)#

Bind function for red resizing

Parameters:

event (str)

resize_scan(event)#

Bind function for saturation resizing

Parameters:

event (str)

resize_vcan(event)#

Bind function for value resizing

Parameters:

event (str)

rhandle(evt=None)#

Command callback for red.

Parameters:
  • evt (str) -- command handle

  • Results

  • -------

  • None

shandle(evt=None)#

Command callback for saturation.

Parameters:

evt (str) -- command handle

vhandle(evt=None)#

Command callback for value.

Parameters:

evt (str) -- command handle

class rgbandhsv.TtkScale(parent, length, from_=0, to=255, orient='horizontal', variable=0, digits=None, tickinterval=None, sliderlength=16, command=None, enlargement=1)#

Bases: Scale

Class to draw themed Scale widget.

Parameters:
  • parent (str) -- parent widget

  • from (int) -- start of scale

  • to (int) -- end of scale

  • length (int) -- length in pixels

  • orient (str) -- orientation

  • variable (str) -- tk variable

  • digits (int) -- length variable when converted to string

  • tickinterval (float or int) -- how many digits show up in tick interval

  • sliderlength (int) -- what it says

  • command (str) -- procedure called when slider moves

build(parent, from_, to, sliderlength, tickinterval, length)#

Create ticks, as the themed Scale has no option.

Parameters:
  • parent (str) -- parent widget

  • from (int) -- start of scale

  • to (int) -- end of scale

  • length (int) -- length in pixels

  • tickinterval (float or int)