Skip to content

csecht/tkinter_utilities

Repository files navigation

tkinter_utilities

tk-color_widget-helper

tkinter-colors

A Python utility to help choose colors and their color_widget blind equivalents for tkinter GUIs. Draws an interactive color_widget table for 760 color_widget names found in X11 rgb.txt that are recognized by tkinter 8.6. Works with Linux, Windows, and MacOS. Usage: Click on a color_widget name to show its hex code and RGB value and display that color_widget as background. Right-click a different color_widget to change the text foreground. Clicking on another color_widget will retain that selected foreground. Click with a key modifier to show the color_widget blind simulation of the selected color_widget: Shift = deuteranopia, Ctrl = protanopia, Alt(Command) = tritanopia, Shift-Ctrl = grayscale; the foreground color_widget will automatically match the simulation type. Simulated color_widget hex codes and RGB values may not correspond to any named color_widget, but the hex string will be recognized by tkinter. Using the Ctrl key (or Command in macOS) while pressing D, P, T, or G will pop-up a non-interactive color_widget table simulated for deuteranopia, protanopia, tritanopia, or grayscale, respectively. Text in the color_widget display and data fields can be cut, copied, pasted, or edited with standard keyboard and click commands. Runs with Python 3.6 and tkinter 8.6 or later. Color table construction based on code from https://stackoverflow.com/questions/4969543/colour-chart-for-tkinter-and-tix

From the green Code button above, download and unzip the ZIP file. From within the resulting tkinter_utilities-main folder, open a Terminal or Command Prompt.

Usage:

From within the program's folder, use one of these Terminal or Command Prompt commands, depending on your system:

        python3 -m tk_color_helper (recommended for all systems)
        py tk_color_helper.py (Windows)
        python3 tk_color_helper.py (Linux, Mac)
        ./tk_color_helper.py (Linux, Mac)

Command line arguments --help and --about are available, e.g.,

$ python3 -m tk_color_helper --help
usage: tk_color_helper.py [-h] [--about]

optional arguments:
  -h, --help      show this help message and exit
  --about         Provide description, version, GNU license

Table at startup: tkinter-colors

Example usage: Click on LightSeaGreen to select a background... select-background

...next, right-click MediumVioletRed to change the foreground... select-foreground

..next, Shift-click on LightSeaGreen. The background and foreground switch to the simulated colors for deuteranopia. Right-clicking on other colors will display those foreground selections with deuteranopia simulation. Shift-click on different colors to change the simulated background. change-simulation

To display non-interactive pop-up windows of the full color table as seen with deuteranopia, protanopia, tritanopia, and grayscale, use the Ctrl key (or Command key on macOS) with any of the following keys: D, P, T, or G. Deuteranopia: deuteranopeia-simulated-colors

Protanopia: protanopeia-simulated-colors

Tritanopia: tritanopia-simulated-colors

Grayscale: grayscale-simulated-colors

tk_mvc_template.py

A template for setting up a tkinter application with an MVC architecture. Plenty of comments are provided to explain what is going on.

tk_widget_table.py

A template for positioning contiguous widgets in a table format where each Label is bound to various functions. This is the approach used in the tk_color_helper program. While buttons can also be used with this approach, be aware that Button() configurations on MacOS are limited in tkinter.

Example: 15 x 10 table of labels. Colors of several labels were changed by mouse clicks. Texts of labels were defined as serial digits during table construction in a for-loop.

widget-table

About

Scripts to: review colors in Python3 tkinter GUIs with color-blind users in mind; demonstrate MVC structure for tkinter

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages