00
     /ˆÅÉ„mÖ\wÈ¾Æ ?÷     /:mod:`ttk` --- Tk themed widgets
================================

.. module:: ttk
   :synopsis: Tk themed widget set
.. sectionauthor:: Guilherme Polo <ggpolo@gmail.com>


.. index:: single: ttk

The :mod:`ttk` module provides access to the Tk themed widget set, which has
been introduced in Tk 8.5. If Python is not compiled against Tk 8.5 code may
still use this module as long as Tile is installed. However, some features
provided by the new Tk, like anti-aliased font rendering under X11, window
transparency (on X11 you will need a composition window manager) will be
missing.

The basic idea of :mod:`ttk` is to separate, to the extent possible, the code
implementing a widget's behavior from the code implementing its appearance.


.. seealso::

   `Tk Widget Styling Support <http://www.tcl.tk/cgi-bin/tct/tip/48>`_
      The document which brought up theming support for Tk


Using Ttk
---------

To start using Ttk, import its module::

   import ttk

But code like this::

   from Tkinter import *

may optionally want to use this::

   from Tkinter import *
   from ttk import *

And then several :mod:`ttk` widgets (:class:`Button`, :class:`Checkbutton`,
:class:`Entry`, :class:`Frame`, :class:`Label`, :class:`LabelFrame`,
:class:`Menubutton`, :class:`PanedWindow`, :class:`Radiobutton`, :class:`Scale`
and :class:`Scrollbar`) will automatically substitute for the Tk widgets.

This has the direct benefit of using the new widgets, giving better look & feel
across platforms, but be aware that they are not totally 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. Use :class:`ttk.Style` to
achieve the same (or better) styling.

.. seealso::

   `Converting existing applications to use the Tile widgets <http://tktable.sourceforge.net/tile/doc/converting.txt>`_
     A text which talks in Tcl terms about differences typically found when
     converting applications to use the new widgets.


Ttk Widgets
-----------

Ttk comes with 17 widgets, 11 of which already exist in Tkinter:
:class:`Button`, :class:`Checkbutton`, :class:`Entry`, :class:`Frame`,
:class:`Label`, :class:`LabelFrame`, :class:`Menubutton`,
:class:`PanedWindow`, :class:`Radiobutton`, :class:`Scale` and
:class:`Scrollbar`. The 6 new widget classes are: :class:`Combobox`,
:class:`Notebook`, :class:`Progressbar`, :class:`Separator`,
:class:`Sizegrip` and :class:`Treeview`.  All of these classes are
subclasses of :class:`Widget`.

As said previously, you will notice changes in look-and-feel as well in the
styling code. To demonstrate the latter, a very simple example is shown below.

Tk code::

   l1 = Tkinter.Label(text="Test", fg="black", bg="white")
   l2 = Tkinter.Label(text="Test", fg="black", bg="white")


Corresponding Ttk code::

   style = ttk.Style()
   style.configure("BW.TLabel", foreground="black", background="white")

   l1 = ttk.Label(text="Test", style="BW.TLabel")
   l2 = ttk.Label(text="Test", style="BW.TLabel")

For more information about TtkStyling_ read the :class:`Style` class
documentation.

Widget
------

:class:`ttk.Widget` defines standard options and methods supported by Tk
themed widgets and is not supposed to be directly instantiated.


Standard Options
^^^^^^^^^^^^^^^^

All the :mod:`ttk` widgets accept the following options:

   +-----------+--------------------------------------------------------------+
   | Option    | Description                                                  |
   +===========+==============================================================+
   | class     | Specifies the window class. The class is used when querying  |
   |           | the option database for the window's other options, to       |
   |           | determine the default bindtags for the window, and to select |
   |           | the widget's default layout and style. This is a read-only   |
   |           | option which may only be specified when the window is        |
   |           | created.                                   