This tutorial series is about the ttk module, which is a special extension of the popular Tkinter GUI library in Python. ttk basically stands for Themed Tkinter, as it provides theming and styling support for Tkinter.

The ttk module comes bundled with 18 widgets, out of which 12 are already present in Tkinter. Importing ttk over-writes these widgets with new ones which are designed to have a better and more modern look across all platforms.

Table of Contents

  1. Tkinter vs ttk Comparison
  2. ttk widget tutorials
  3. More about ttk
    • Importing ttk
    • List of Options
    • Styles

Tkinter vs ttk Comparison

There are two major differences between Tkinter and ttk.

Firstly ttk has 6 new widgets, the Combobox, Separator, Sizegrip, Treeview, Notebook and ProgressBar. As we mentioned earlier, there are 12 other widgets (Button, Checkbutton, Entry, Frame, Label, LabelFrame, Menubutton, PanedWindow, Radiobutton, Scale, Scrollbar, and Spinbox).

Secondly, the newer widgets introduced by ttk have slight syntax differences when it comes to certain menu options like bg and fg, which are normally present in tkinter. Instead of this, ttk introduces a Style class, which is used to apply customizations. Similarly, there are some new options that ttk introduces that weren’t present in tkinter.

ttk Widget Tutorials

Here we have individual tutorials for each of the 6 new widgets in ttk. Each tutorial is complete with an explanation, examples and list of possible options and customizations.

Notebook: This widget manages a collection of windows or “tabs” between which you can swap, changing the currently displayed window.

ProgressBar: This widget is used to show progress or the loading process through the use of animations.

Separator: Used to separate different widgets using a separator line.

Treeview: This widget is used to group together items in a tree-like hierarchy. Each item has a textual label, an optional image, and an optional list of data values

ComboBox: Used to create a dropdown list of options from which the user can select one.

Sizegrip: Creates a little handle near the bottom-right of the screen, which can be used to resize the window.

For the original 12 widgets, you can refer to the original Tkinter tutorial series, where we have individual tutorials for each widget.

For a list of updated options and a tutorial on the new Style class in ttk, refers to the below section.

More about Tkinter ttk (Tutorial)

Here is some extra content and information about the ttk module that will be of great help to all Tkinter and ttk users.

How to import ttk

Importing ttk can get a little tricky as it can be done in several ways. You don’t need to worry about installing or downloading ttk separately however, as it is part of the standard Python library, as a submodule within Tkinter.

A very “raw” way of importing it would be the following:

from tkinter import *
from tkinter.ttk import *

button = Button(......)

What this does is first import all the Widgets from tkinter without any namespace. The second import from ttk then occurs, and it overrides the tkinter import, replacing all common widgets. Hence when you create a button, it will be from the ttk module. You will no longer be able to use regular Tkinter versions with this method.

import tkinter as tk
import tkinter as ttk

button = tk.Button(......)
ttkButton = ttk.Button(......)

Alternatively, you could import it like this, which preserves namespaces. This gives you greater control over your widgets, allowing you to pick whether to use the Tkinter version, or the ttk version. (Useful if you just want to use a certain widget or two from ttk)

Styles in ttk

Every widget now has a style option, into which the name of the style is passed. This style is separately configured using the style class, and given attributes such as hover effects and colors. After creating a style, we can assign it to any widget using the style option.

Every Widget in Tkinter/ttk has a default style, that has a bunch of attributes already applied on it.

The below table shows the names of these default styles, which you may or may not want to override and change certain styling options for widgets belonging to that style group.

For more about Styles and related topics such as themes, check out our Tkinter ttk Style Tutorial, where we explain how to use, modify and create styles.

Widget classStyle name
ProgressbarHorizontal.TProgressbar / Vertical.TProgressbar
ScaleHorizontal.TScale / Vertical.TScale
ScrollbarHorizontal.TScrollbar / Vertical.TScrollbar

This marks the end of the Tkinter ttk Widgets tutorial. Any suggestions or contributions for CodersLegacy are more than welcome. Questions regarding the tutorial content can be asked in the comments section below.

Notify of
Inline Feedbacks
View all comments