What is the difference between the widgets of tkinter and tkinter.ttk in Python?
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.
My opinion for beginners who are starting to learn Tkinter
, is to use Tkinter
widgets, because they're really easy to learn. But on the other hand Tkinter.ttk
is a module designed to make Tkinter
widgets look really perfectly, but is really hard to learn and there are no easy options there. Like there are no -fg
, -bg
. Perhaps, there are no new styles available in Tkinter
. Style are only designed for ttk
, and can be found in ttk
.
And Tkinter
widgets really don't look like other native platform widgets.
But ttk
is nicer and smoother looking, and look like other native platforms.
So if you are making apps for your own private use, then use Tkinter
and also use some ttk
if needed, because ttk
supports much cooler widgets that can change the look of your app.
And if you are making apps for public use, then go for both because Tkinter
is needed for creating the window and some more important stuff, and for widgets go for ttk
.
But honestly, I say use both because there are no conflicts between the two; just use them both to your advantage.
Honestly using ttk
is a challenge! Because it has no Grid
,Pack
, Place
and many other options that are normally available in Tkinter
widgets. But wait!! Tkinter
has those options! So use both! Try to make a nice app!
That is the real difference between the two: Tkinter
widgets are more configurable, and ttk
is more modern and it is configurable with styles which are really handy shortcuts. And Tkinter
is like the core of the window and ttk
is styling. Think of it like this:
Tkinter --- HTML, ttk --- CSS, Python --- JavaScript.