ttk (very BETA)

appJar includes experimental support for ttk, a tk themed widget set.

If you run appJar in ttk mode, some of the widgets will be replaced with more native looking widgets.

NB. appJar has a lot of built in styling for standard widgets, supporting ttk has required changing how all this is done. When you come across issues, please log them in GitHub.

Enabling ttk


ttk will default to a theme similar to the operating system.
A list of additional themes can be displayed by calling:

Additional themes can be installed using ttk extensions.

These can be installed via pip: pip install ttkthemes
And then used the same as any other theme: app.setTtkTheme("black").

Styling ttk Widgets

appJar stores the ttk style as app.ttkStyle this can be modified or changed directly as required.

Default Widget Style

Each widget type has its own style, such as TLabel or TButton.
To change the style for all widgets of a certain type, reconfigure these styles:

app.ttkStyle.configure("TLabel", foreground="green", background="blue")

Root Style

All widgets inherit their style from the root style, known simply as .
If you want to change the style of all widgets, you can modify the root style.
NB. if particular widget types have set their own styles, modifying the root style won't change them.

app.ttkStyle.configure(".", background="black", foreground="white")

Create Your Own Styles

Finally, it's possible to create your own styles, and use them for particular widgets.
Your new style should inherit from the widget's style: MyButton.TButton

app.ttkStyle.configure("MyButton.TButton", foreground="red")

You can also create dynamic appearance changes to the widgets, called 'maps'. These allow you to change the properties of the widget in response to certain events, such as changing the colour of a button when the cursor is over it."MyButton.TButton", background=[("active", "blue")])

You'll need to pass a list, which contains tuples as a parameter. * Each tuple is responsible for changing one aspect of the widget in a particular state.

You then need to apply this style (which includes both ttkStyle.configure and to the relevant widgets:

app.setEntryStyle("Name", "BW.TEntry")

Built in Setters

You can still use the existing setters for background .setBg() and foreground .setFg():


Command Line Arguments

It's possible to switch on ttk theming from the command line.
Simply use the --ttk flag, with an optional theme name:

python3 --ttk  # turn on ttk widgets

Turn on ttk widgets and set a theme:

python3 --ttk aqua # turn on ttk with the aqua theme