The TTK feature of tkinter provides "themed widgets" for some of the widgets. Some, like the Button widget, are supported in both the "TK" and "TTK" varieties. Others, like the Treeview widget which is used by the Tree and Table elements, are only available through TTK.
TTK can be thought of as providing these 2 features:
- Additional color and style options for some widgets
- A "Theme" for the TTK widgets that is applied to all TTK widgets
Note that the "TTK Theme" is not the same as the "PySimpleGUI Theme". They are entirely independent and places where TTK Themes are discussed, it's clear that TTK Theme is meant and not PySimpleGUI Theme. For example, the
Window object has a parameter named
ttk_theme which clearly sets the TTK theme for the window.
Some Elements Use TTK, Some Not
If there is both a TK and a TTK version of a Widget, usually it's the TK version that has been implemented. You will find a table in the Elements section that shows exactly which tkinter widget is used for each element.
These Elements use the TK version of the tkinter widget, not the TTK version. As a result, the TTK theme will not be applied to these elements:
These elements are based on TTK widgets:
Additionally, scrollbars are ttk based. This is what enables the PySimpleGUI Theme's colors to be used with the scrollbars. TK Scrollbars do not have the advanced coloring features that TTK Scrollbars have.
TTK Buttons were originally implemented so that the button colors could be set on the Mac. TK Buttons on the Mac were broken in tkinter for quite a while and the only way to set a color other than white for a button on the Mac was to use TTK Buttons. This bug has since been fixed in tkinter or in the Mac's drivers so both TK and TTK buttons should work fine on the Mac now.
By default Mac users will get ttk Buttons when a Button Element is used. All other platforms will get a normal TK Button. There are ways to override this behavior. One is by using the parameter
use_ttk_buttons when you create your window. If set to True, all buttons will be ttk Buttons in the window. If set to False, all buttons will be normal TK Buttons. If not set then the platform or the Button Element determines which is used.
TK and TTK buttons each behave differently on different operating systems. For example, TK Buttons change color when moused over on Linux, but not on Windows. TKK Buttons will change color when moused over. It can be confusing so be sure and test your application on all operating systems you plan on it being used on (something you should be doing for all of your PySimpleGUI programs that you're making available to other people).
If a system-wide setting is desired, then the default can be set using
set_options. This will affect all windows such as popups and the debug window.
Tkinter has a number of "Themes" that can be used with ttk widgets. Which TTK Themes are available to you depends on the platform. Linux has a shorter number of selections for TTK Themes than Windows. These are the Windows choices:
There are constants defined to help you with code completion to determine what your choices are. Theme constants start with
THEME_. For example, the "clam" theme is
You're urged to experiment with this setting to determine which you like the most. They change the ttk-based elements in subtle but still significant ways. Also be aware that how your element appears on one operating system may not be the same on other operating systems.
Setting TTK Theme
There are 3 ways to set the TTK Theme to be used by PySimpleGUI.
- When creating a
Window. Only that
Windowwill use the theme.
- By calling
set_optionsand setting the
ttk_themeparameter. All Windows, including popups, will use the theme
- Using the Global PySimpleGUI Settings window. All of your PySimpleGUI applications will use the theme.
If an element can have a scrollbar, then you can customize the look of the scrollbar. Like many PySimpleGUI settings, there are numerous places to set the default that will be used. You can specify the scrollbar customization in these ways:
- When creating the element.
- When creating the
Window. All elements in the Window will use this setting unless the element has a setting explicitly defined in the layout.
- By calling
set_optionswhich will change the default for all windows created, unless explicitly set by a Window or Element.
- In the PySimpleGUI Global Settings window which sets the defaults for all of your PySimpleGUI programs. on an element by element basis, at the Window level, or
Global PySimpleGUI TTK Settings
This is where you'll find the TTK settings in the Global PySimpleGUI Settings Window. Notice that you can set both the default theme as well as customize your scrollbars using this interface. All of your PySimpleGUI programs will use these settings unless your program explicitly indicates a particular setting using
Window or when creating an Element.