:mod:`!tkinter.ttk` --- Tk themed widgets ========================================= .. module:: tkinter.ttk :synopsis: Tk themed widget set .. sectionauthor:: Guilherme Polo **Source code:** :source:`Lib/tkinter/ttk.py` .. index:: single: ttk -------------- The :mod:`!tkinter.ttk` module provides access to the Tk themed widget set, introduced in Tk 8.5. Its widgets adapt their appearance to the platform's native theme, giving an application a better and more consistent look and feel than the classic :mod:`tkinter` widgets, whose appearance is fixed. The basic idea for :mod:`tkinter.ttk` is to separate, to the extent possible, the code implementing a widget's behavior from the code implementing its appearance. Ttk widgets are used just like the classic :mod:`tkinter` widgets and share the same machinery: the widget hierarchy, the geometry managers, variable coupling and event binding. Those foundational concepts are covered in the :mod:`tkinter` documentation and are not repeated here. .. versionadded:: 3.1 .. seealso:: `Tk Widget Styling Support (TIP #48) `_ The Tcl Improvement Proposal that introduced the themed widget styling engine. Using Ttk --------- To start using Ttk, import its module:: from tkinter import ttk To override the basic Tk widgets, the import should follow the Tk import:: from tkinter import * from tkinter.ttk import * That code causes several :mod:`tkinter.ttk` widgets (:class:`Button`, :class:`Checkbutton`, :class:`Entry`, :class:`Frame`, :class:`Label`, :class:`LabelFrame`, :class:`Menubutton`, :class:`OptionMenu`, :class:`PanedWindow`, :class:`Radiobutton`, :class:`Scale`, :class:`Scrollbar` and :class:`Spinbox`) to automatically replace the Tk widgets. .. note:: Overriding the classic widgets with ``from tkinter.ttk import *`` is convenient for adapting existing code, but new code is usually clearer if it imports the module as ``from tkinter import ttk`` and refers to the themed widgets explicitly, such as ``ttk.Button``. This has the direct benefit of using the new widgets which gives a better look and feel across platforms; however, the replacement widgets are not completely compatible. The main difference is that widget options such as ``fg``, ``bg`` and others related to widget styling are no longer present in Ttk widgets. Instead, use the :class:`ttk.Style