What is the difference between the widgets of tkinter and tkinter.ttk in Python?

multigoodverse picture multigoodverse · Oct 24, 2013 · Viewed 33.1k times · Source

The main tkinter module and its submodule ttk in Python 3 appear to contain identical widgets (i.e. Buttons, CheckButtons, etc.).

So, when creating a button, one has the freedom to either use a tkinter.Button widget or a tkinter.ttk.Button.

Do you know what is the difference between them? Why would you choose one or the other?

Answer

Bryan Oakley picture Bryan Oakley · Oct 24, 2013

The widgets in tkinter are highly and easily configurable. You have almost complete control over how they look - border widths, fonts, images, colors, etc.

ttk widgets use styles to define how they look, so it takes a bit more work if you want a non-standard button. ttk widgets are also a little under-documented. Understanding the underlying theme and layout engines (layout within the widgets themselves, not pack, grid and place) is a challenge.

Generally speaking, the themed widgets will give you an application that looks more "native", but at the expense of a loss of configurability.

My advice is to use ttk widgets if you want your GUI to look a little more modern, and the tkinter widgets if you need a bit more configurability. You can use them both in the same applications.