Miscellaneous Stuff¶
The tks Module¶
tkStuff - A collection of Tk widgets
-
class
tks.DefaultColors¶ A container for color names.
-
class
tks.DefaultFonts¶ A container for font information.
-
class
tks.PickleVar(master=None, value=None, name=None)¶ A Tkinter variable which stores values as pickled objects.
-
tks.load_colors()¶ Load color definitions from the .tksrc file
-
tks.load_fonts()¶ Load font definitions from the .tksrc file
-
tks.parse_geometry(geom)¶ Return a width, height, x, y tuple from a Tk geometry.
-
tks.rect_at(point, size, size_y=-1)¶ Returns a rectangle centred at point. If only size is provided then the rectangle will be a square. The dimensions will be size * 2.
-
tks.rect_center(rect)¶ Return the centre of a rectangle as an (x, y) tuple.
Color Functions (tks.color_funcs)¶
Various functions to manipulate RGB hex, RGB, HSV and HLS colors.
-
tks.color_funcs.clamp(value)¶ Clamp a float between 0.0 and 1.0
-
tks.color_funcs.clamped_tuple(value)¶ Clamps the values in a tuple between 0.0 and 1.0
-
tks.color_funcs.color_string_to_color(value, allow_short_hex=True)¶ Convert a color string to a (color format, value) tuple where the color format is one of rgbhex, rgb, hsv or hls
-
tks.color_funcs.color_string_to_rgb(value)¶ Return an RGB tuple from a color string.
-
tks.color_funcs.color_string_to_tuple(value)¶ Convert a color string to a tuple of floats.
-
tks.color_funcs.contrast_color(rgb)¶ Return either white or black whichever provides the most contrast
-
tks.color_funcs.hex_string_to_rgb(value, allow_short=True)¶ Convert from a hex color string of the form #abc or #abcdef to an RGB tuple.
Parameters:
-
tks.color_funcs.luminosity_transform(color, luminosity=0.05)¶ Transform an RGB color by a luminosity.
If luminosity is a tuple then the 3 elements are used to transform the red, green and blue values individually. If a float then the same value is used to transform all 3 elements.
-
tks.color_funcs.rgb_intensity(rgb)¶ Convert an RGB color to its intensity
-
tks.color_funcs.rgb_shade(rgb, percent=5)¶ Create a shade of the RGB color
Parameters:
-
tks.color_funcs.rgb_shades(rgb, base_percent, count, linear=True)¶ Produce a list of shades from the base color
Parameters:
-
tks.color_funcs.rgb_tint(rgb, percent=5)¶ Create a tinted version of the RGB color
Parameters:
-
tks.color_funcs.rgb_tints(rgb, base_percent, count, linear=True)¶ Produce a list of tints from the base color
Parameters:
-
tks.color_funcs.rgb_to_hex_string(value)¶ Convert from an (R, G, B) tuple to a hex color.
Parameters: value (tuple) – The RGB value to convert R, G and B should be in the range 0.0 - 1.0
-
tks.color_funcs.rgb_to_hls_string(value, dp=3)¶ Convert from an (R, G, B) tuple to an HLS string.
Parameters: R, G and B should be in the range 0.0 - 1.0
-
tks.color_funcs.rgb_to_hsv_string(value, dp=3)¶ Convert from an (R, G, B) tuple to an HSV string.
Parameters: R, G and B should be in the range 0.0 - 1.0
Icon Functions (tks.icon)¶
-
tks.icon.set_icon_from_data(root, image_data)¶ Set the icon for a root window from image data.
Parameters: - root – Toplevel window for which to set the icon.
- image_data (bytes) – The image data to use