Improved Tkinter widgets that accept HTML-like tagged text to support multiple fonts and enhanced visual schemes.
Project description
ttwidgets
Package TTWidgets improves the Button, Label, and Listbox widgets of
the Tkinter library and provides a new ToolTip widget, all with support for
multiple fonts and visual schemes.
Although the standard Tkinter Button and Label widgets are limited to a
single set of widget options (e.g. background/bg, foreground/fg, bitmap,
cursor, relief) and a single font, a TTWidgets enhanced widget can be
passed tagged text instead of plain text to create a visually compound widget
(with multiple fonts and visual option sets) that behaves like a simple widget.
- The
ButtonandLabelimplementations are complete. - The
Listboximplementation is partial: there is no multi-font support, but the user can use the new 'text' option to pass in tagged text to define all the elements with visual schemes. The user can also pass tagged text to the insert() method, and thereby skip the secondary call to itemconfig() for the inserted element(s). A full multi-font implementation of a tagged textListboxmay come later. - As a bonus, a
ToolTipwidget is included, which also accepts tagged text as input, allowing the creation of colorful and multi-font ToolTips.
All TTWidgets support the 'text' keyword to accept and process tagged text
as input on creation.
All TTWidgets support modification of 'text' via the config() method and
retrieval via cget().
As a ttwidgets Button example:
button = ttwidgets.TTButton(text="Isn't a <t case=title relief=raised bd=1 bg=white padx=2>button</t> with <tag bold fg=red bg=yellow>bold red on yellow text</tag> and \na <tag fg=blue funderline>hyperlink</tag> <tag relief=groove bd=2>groovy</tag> <tag bitmap=warning/>", command=lambda e=None: print("Released!"), bg='lightgray')
gives a Button with text "Isn't a Button with bold red on yellow text and a hyperlink groovy!", where:
- "Button" appears inside a raised button (with "title" case),
- "bold red on yellow text" is bold red text on a yellow background,
- "hyperlink" is blue and underlined,
- "groovy" is in a box with 'groove' relief, and
- "!" is a warning bitmap.
Here are two versions of the same button. Which one would YOU rather use? :)
As a ttwidgets ToolTip example:
tooltip = ttwidgets.TTToolTip(reg_but, text='My <t bg=cyan px=2 py=2 bd=2 relief=groove size=6 wraplength=70>Regular Button Cycle All States</t><t b> ToolTip</t>... See how it matches? :)', bg='white', relief=tk.GROOVE, borderwidth=5)
gives a ToolTip for button "reg_but" which includes a smaller version of the button it is tipping, to make the ToolTip more visually appealing. The ToolTip also shows bold text and a white background.
In general, all the visual options and font attributes are supported in the
tagged text. For a tagged text overview, please see ttwidgets class TTWidget help.
Please note that, due to its implementation based on underlying Tkinter Labels, a TTButton will not have the foreground/background color failure-to-change issue on MacOS that a Tkinter.Button has.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ttwidgets-1.1.3.tar.gz.
File metadata
- Download URL: ttwidgets-1.1.3.tar.gz
- Upload date:
- Size: 49.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d15cefb4668ea7fee356f4d7bf7728a978da1c2d2faed1d4b6ee31a0305f1e9
|
|
| MD5 |
c3ff0fc2f710a4aca4d541d81d56ed7f
|
|
| BLAKE2b-256 |
17b5c89657676ea745c0f1514a7d5c38b09f5cc35917a2823f84ced97d9c9a47
|
File details
Details for the file ttwidgets-1.1.3-py3-none-any.whl.
File metadata
- Download URL: ttwidgets-1.1.3-py3-none-any.whl
- Upload date:
- Size: 51.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d89d00d494bf6dbf218966a4ef97330f3df9d68add34977b87910333df9c046c
|
|
| MD5 |
3b5c95bbfeef5e4bfcc546598b5614c2
|
|
| BLAKE2b-256 |
784168325ee6ef36e3e305b11d553981c7498772f620c6855b4a185397f2d457
|