Choose Palette¶
-
class
choose_palette.
Slider
(x, y, width, height, active, type_, from_, to, resolution, **kwargs)[source]¶ Initializes a new Slider object for the graphical user interface
choose_palette.gui
. A Slider is a combination of aTk.Frame
including aTk.Label
,Tk.Slider
, and aTk.Entry
element with all necessary interactions.Parameters: - x (int) – x-position on the Tk interface
- y (int) – y-position on the Tk interface
- width (int) – width of the Slider object (
Tk.Frame
taking upTk.Scale
,Tk.Label
, andTk.Entry
) - height (int) – height of the Slider object (
Tk.Frame
taking upTk.Scale
,Tk.Label
, andTk.Entry
) - type (str) – name of the Slider
- from (numeric) – lower value of the Slider (see
isValidInt()
,isValidFloat()
) - to (numeric) – upper value of the Slider (see
isValidInt()
,isValidFloat()
) - resolution (numeric) – resolution of the slider, the increments when moving the Slider
- kwargs – Unused
-
OnTrace
(*args, **kwargs)[source]¶ Triggered when
Slider.trace()
is triggered. The method is loading the current value and sets theTk.Scale
andTk.Entry
element to the new value.
-
get
()[source]¶ Returns: Returns the current value of the slider. The return value depends on the slider config (int or float). Return type: int or float
-
isValidFloat
(x, from_ = -999., to = 999.)[source]¶ Helper function to check whether
x
is a valid float in the range[from_,to]
.Parameters: - x (float) – Value to be validated
- from (float) – Lower limit of the valid range
- to (float) – Upper limit of the valid range
Returns: Returns
True
ifx
is a valid float within[from_, to]
andFalse
otherwise.Return type: bool
-
isValidInt
(x, from_ = -999, to = 999)[source]¶ Helper function to check whether
x
is a valid integer in the range[from_,to]
.Parameters: - x (int) – Value to be validated
- from (int) – Lower limit of the valid range
- to (int) – Upper limit of the valid range
Returns: Returns
True
ifx
is a valid float within[from_, to]
andFalse
otherwise.Return type: bool
-
trace
(mode, *args, **kwargs)[source]¶ Trace method of the
Slider
object.Parameters: - mode (str) – default is
w
(call observer when variable is written) - args – arguments passed to
Tkinter.<vartype>.trace()
, at least one argument (a callback function) should be provided - kwargs – arguments passed to
Tkinter.<vartype>.trace()
, unused
- mode (str) – default is
-
choose_palette.
choose_palette
(**kwargs)[source]¶ Graphical user interface to choose HCL based color palettes. Returns an object of
palettes.diverging_hcl
,palettes.qualitative_hcl
, orpalettes.sequential_hcl
with user-defined default settings.Parameters: kwargs – See choose_palette.gui
.Returns: The object allows to get colors in different ways, the default is a list with hex colors. See palettes.hclpalette
or, more specifically, the manual of the depending palette (palettes.diverging_hcl
,palettes.qualitative_hcl
, orpalettes.sequential_hcl
).Return type: palettes.hclpalette object
-
class
choose_palette.
currentpalettecanvas
(parent, x, y, width, height)[source]¶ Draws the current palette (the palette as specified on the GUI), will be displayed in the lower part of the GUI.
Parameters: - parent (
Tk
) – theTk
object (interface) - x (numeric) – x position on the interface
- y (numeric) – y position on the interface
- width (numeric) – width of the palette on the interface
- height (numeric) – height of the palette on the interface
- parent (
-
class
choose_palette.
defaultpalettecanvas
(palframe, sliders, pal, n, xpos, figwidth, figheight)[source]¶ Sets up a
Tk.Canvas
element containing the colors of the default HCL color palettes which will be placed in the top part of the GUI.Parameters: - palframe (
Tk.Frame
) – the boundingTk.Frame
which takes up the palettes. - sliders (list) – list of
Slider
objects. When a user selets a new default palette the sliders will be set to the specification given the selected palette (and enabled/disabled corresponding to the palette specification) - pal (
defaultpalette
) – the default color palette - n (int) – number of colors to be drawn
- xpos (numeric) – x position within
Tk.Canvas
(palframe input) - figwidth (numeric) – width of the
Tk.Canvas
element (palframe input) - figheight (numeric) – width of the
Tk.Canvas
element (palframe input)
- palframe (
-
class
choose_palette.
gui
(**kwargs)[source]¶ choose_palette(**kwargs)
Graphical user interface to choose custom HCL-basec color palettes.
Parameters: kwargs – Optional, can be used to change the defaults when starting the GUI. Currently a parameter called palette
is allowed to specify the initial color palette. If not set,palette = "Blue-Red"
is used.Example
>>> colorspace.choose_palette()
-
OnChange
(*args, **kwargs)[source]¶ Triggered any time the slider values or control arguments change. Draws new current palette (see
_draw_currentpalette()
).
-
OnPaltypeChange
(*args, **kwargs)[source]¶ The callback function of the drop down element. Triggered every time the drop down element changes.
-
control
()[source]¶ Returns: Returns a dictionary with the current control options (see _add_control()
).Return type: dict
-
get_colors
()[source]¶ Returns: Returns a list of hex colors and nan
given the current settings on the GUI.numpy.nan
will be returned iffixup
is set to False but some colors lie outside the RGB color space.Return type: list
-
method
()[source]¶ Returns: Returns the name of the object which has to be called to get the colors. The name of the object is defined in the palconfig config files. For “Diverging” palettes this will be palettes.diverging_hcl
, for “Qualitative”palettes.qualitative_hcl
, and for “Sequential” palettespalettes.sequential_hcl
.Return type: str
-
palettes
()[source]¶ Returns: Returns the default palettes available. Return type: palettes.hclpalettes
-
palframe
()[source]¶ Returns: Returns the palette frame ( Tk.Frame
object, see_add_palframe()
).Return type: Tk.Frame
-