gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2064 lines
141KB

  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="../">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <meta property="og:title" content="tkinter.ttk — Tk themed widgets" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/library/tkinter.ttk.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="Source code: Lib/tkinter/ttk.py The tkinter.ttk module provides access to the Tk themed widget set, introduced in Tk 8.5. It provides additional benefits including anti-aliased font rendering under..." />
  11. <meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
  12. <meta property="og:image:alt" content="Python documentation" />
  13. <meta name="description" content="Source code: Lib/tkinter/ttk.py The tkinter.ttk module provides access to the Tk themed widget set, introduced in Tk 8.5. It provides additional benefits including anti-aliased font rendering under..." />
  14. <meta property="og:image:width" content="200" />
  15. <meta property="og:image:height" content="200" />
  16. <meta name="theme-color" content="#3776ab" />
  17. <title>tkinter.ttk — Tk themed widgets &#8212; Python 3.12.3 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
  18. <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
  19. <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=bb723527" />
  20. <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=b20cc3f5" />
  21. <script src="../_static/documentation_options.js?v=2c828074"></script>
  22. <script src="../_static/doctools.js?v=888ff710"></script>
  23. <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
  24. <script src="../_static/sidebar.js"></script>
  25. <link rel="search" type="application/opensearchdescription+xml"
  26. title="Search within Python 3.12.3 documentation"
  27. href="../_static/opensearch.xml"/>
  28. <link rel="author" title="About these documents" href="../about.html" />
  29. <link rel="index" title="Index" href="../genindex.html" />
  30. <link rel="search" title="Search" href="../search.html" />
  31. <link rel="copyright" title="Copyright" href="../copyright.html" />
  32. <link rel="next" title="tkinter.tix — Extension widgets for Tk" href="tkinter.tix.html" />
  33. <link rel="prev" title="tkinter.dnd — Drag and drop support" href="tkinter.dnd.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/library/tkinter.ttk.html" />
  35. <style>
  36. @media only screen {
  37. table.full-width-table {
  38. width: 100%;
  39. }
  40. }
  41. </style>
  42. <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
  43. <link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
  44. <script type="text/javascript" src="../_static/copybutton.js"></script>
  45. <script type="text/javascript" src="../_static/menu.js"></script>
  46. <script type="text/javascript" src="../_static/search-focus.js"></script>
  47. <script type="text/javascript" src="../_static/themetoggle.js"></script>
  48. </head>
  49. <body>
  50. <div class="mobile-nav">
  51. <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
  52. aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
  53. <nav class="nav-content" role="navigation">
  54. <label for="menuToggler" class="toggler__label">
  55. <span></span>
  56. </label>
  57. <span class="nav-items-wrapper">
  58. <a href="https://www.python.org/" class="nav-logo">
  59. <img src="../_static/py.svg" alt="Python logo"/>
  60. </a>
  61. <span class="version_switcher_placeholder"></span>
  62. <form role="search" class="search" action="../search.html" method="get">
  63. <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
  64. <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
  65. </svg>
  66. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  67. <input type="submit" value="Go"/>
  68. </form>
  69. </span>
  70. </nav>
  71. <div class="menu-wrapper">
  72. <nav class="menu" role="navigation" aria-label="main navigation">
  73. <div class="language_switcher_placeholder"></div>
  74. <label class="theme-selector-label">
  75. Theme
  76. <select class="theme-selector" oninput="activateTheme(this.value)">
  77. <option value="auto" selected>Auto</option>
  78. <option value="light">Light</option>
  79. <option value="dark">Dark</option>
  80. </select>
  81. </label>
  82. <div>
  83. <h3><a href="../contents.html">Table of Contents</a></h3>
  84. <ul>
  85. <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.ttk</span></code> — Tk themed widgets</a><ul>
  86. <li><a class="reference internal" href="#using-ttk">Using Ttk</a></li>
  87. <li><a class="reference internal" href="#ttk-widgets">Ttk Widgets</a></li>
  88. <li><a class="reference internal" href="#widget">Widget</a><ul>
  89. <li><a class="reference internal" href="#standard-options">Standard Options</a></li>
  90. <li><a class="reference internal" href="#scrollable-widget-options">Scrollable Widget Options</a></li>
  91. <li><a class="reference internal" href="#label-options">Label Options</a></li>
  92. <li><a class="reference internal" href="#compatibility-options">Compatibility Options</a></li>
  93. <li><a class="reference internal" href="#widget-states">Widget States</a></li>
  94. <li><a class="reference internal" href="#ttk-widget">ttk.Widget</a></li>
  95. </ul>
  96. </li>
  97. <li><a class="reference internal" href="#combobox">Combobox</a><ul>
  98. <li><a class="reference internal" href="#options">Options</a></li>
  99. <li><a class="reference internal" href="#virtual-events">Virtual events</a></li>
  100. <li><a class="reference internal" href="#ttk-combobox">ttk.Combobox</a></li>
  101. </ul>
  102. </li>
  103. <li><a class="reference internal" href="#spinbox">Spinbox</a><ul>
  104. <li><a class="reference internal" href="#id1">Options</a></li>
  105. <li><a class="reference internal" href="#id2">Virtual events</a></li>
  106. <li><a class="reference internal" href="#ttk-spinbox">ttk.Spinbox</a></li>
  107. </ul>
  108. </li>
  109. <li><a class="reference internal" href="#notebook">Notebook</a><ul>
  110. <li><a class="reference internal" href="#id3">Options</a></li>
  111. <li><a class="reference internal" href="#tab-options">Tab Options</a></li>
  112. <li><a class="reference internal" href="#tab-identifiers">Tab Identifiers</a></li>
  113. <li><a class="reference internal" href="#id4">Virtual Events</a></li>
  114. <li><a class="reference internal" href="#ttk-notebook">ttk.Notebook</a></li>
  115. </ul>
  116. </li>
  117. <li><a class="reference internal" href="#progressbar">Progressbar</a><ul>
  118. <li><a class="reference internal" href="#id5">Options</a></li>
  119. <li><a class="reference internal" href="#ttk-progressbar">ttk.Progressbar</a></li>
  120. </ul>
  121. </li>
  122. <li><a class="reference internal" href="#separator">Separator</a><ul>
  123. <li><a class="reference internal" href="#id6">Options</a></li>
  124. </ul>
  125. </li>
  126. <li><a class="reference internal" href="#sizegrip">Sizegrip</a><ul>
  127. <li><a class="reference internal" href="#platform-specific-notes">Platform-specific notes</a></li>
  128. <li><a class="reference internal" href="#bugs">Bugs</a></li>
  129. </ul>
  130. </li>
  131. <li><a class="reference internal" href="#treeview">Treeview</a><ul>
  132. <li><a class="reference internal" href="#id7">Options</a></li>
  133. <li><a class="reference internal" href="#item-options">Item Options</a></li>
  134. <li><a class="reference internal" href="#tag-options">Tag Options</a></li>
  135. <li><a class="reference internal" href="#column-identifiers">Column Identifiers</a></li>
  136. <li><a class="reference internal" href="#id8">Virtual Events</a></li>
  137. <li><a class="reference internal" href="#ttk-treeview">ttk.Treeview</a></li>
  138. </ul>
  139. </li>
  140. <li><a class="reference internal" href="#ttk-styling">Ttk Styling</a><ul>
  141. <li><a class="reference internal" href="#layouts">Layouts</a></li>
  142. </ul>
  143. </li>
  144. </ul>
  145. </li>
  146. </ul>
  147. </div>
  148. <div>
  149. <h4>Previous topic</h4>
  150. <p class="topless"><a href="tkinter.dnd.html"
  151. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.dnd</span></code> — Drag and drop support</a></p>
  152. </div>
  153. <div>
  154. <h4>Next topic</h4>
  155. <p class="topless"><a href="tkinter.tix.html"
  156. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.tix</span></code> — Extension widgets for Tk</a></p>
  157. </div>
  158. <div role="note" aria-label="source link">
  159. <h3>This Page</h3>
  160. <ul class="this-page-menu">
  161. <li><a href="../bugs.html">Report a Bug</a></li>
  162. <li>
  163. <a href="https://github.com/python/cpython/blob/main/Doc/library/tkinter.ttk.rst"
  164. rel="nofollow">Show Source
  165. </a>
  166. </li>
  167. </ul>
  168. </div>
  169. </nav>
  170. </div>
  171. </div>
  172. <div class="related" role="navigation" aria-label="related navigation">
  173. <h3>Navigation</h3>
  174. <ul>
  175. <li class="right" style="margin-right: 10px">
  176. <a href="../genindex.html" title="General Index"
  177. accesskey="I">index</a></li>
  178. <li class="right" >
  179. <a href="../py-modindex.html" title="Python Module Index"
  180. >modules</a> |</li>
  181. <li class="right" >
  182. <a href="tkinter.tix.html" title="tkinter.tix — Extension widgets for Tk"
  183. accesskey="N">next</a> |</li>
  184. <li class="right" >
  185. <a href="tkinter.dnd.html" title="tkinter.dnd — Drag and drop support"
  186. accesskey="P">previous</a> |</li>
  187. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  188. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  189. <li class="switchers">
  190. <div class="language_switcher_placeholder"></div>
  191. <div class="version_switcher_placeholder"></div>
  192. </li>
  193. <li>
  194. </li>
  195. <li id="cpython-language-and-version">
  196. <a href="../index.html">3.12.3 Documentation</a> &#187;
  197. </li>
  198. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  199. <li class="nav-item nav-item-2"><a href="tk.html" accesskey="U">Graphical User Interfaces with Tk</a> &#187;</li>
  200. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.ttk</span></code> — Tk themed widgets</a></li>
  201. <li class="right">
  202. <div class="inline-search" role="search">
  203. <form class="inline-search" action="../search.html" method="get">
  204. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  205. <input type="submit" value="Go" />
  206. </form>
  207. </div>
  208. |
  209. </li>
  210. <li class="right">
  211. <label class="theme-selector-label">
  212. Theme
  213. <select class="theme-selector" oninput="activateTheme(this.value)">
  214. <option value="auto" selected>Auto</option>
  215. <option value="light">Light</option>
  216. <option value="dark">Dark</option>
  217. </select>
  218. </label> |</li>
  219. </ul>
  220. </div>
  221. <div class="document">
  222. <div class="documentwrapper">
  223. <div class="bodywrapper">
  224. <div class="body" role="main">
  225. <section id="module-tkinter.ttk">
  226. <span id="tkinter-ttk-tk-themed-widgets"></span><h1><a class="reference internal" href="#module-tkinter.ttk" title="tkinter.ttk: Tk themed widget set"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.ttk</span></code></a> — Tk themed widgets<a class="headerlink" href="#module-tkinter.ttk" title="Link to this heading">¶</a></h1>
  227. <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/tkinter/ttk.py">Lib/tkinter/ttk.py</a></p>
  228. <hr class="docutils" id="index-0" />
  229. <p>The <a class="reference internal" href="#module-tkinter.ttk" title="tkinter.ttk: Tk themed widget set"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.ttk</span></code></a> module provides access to the Tk themed widget set,
  230. introduced in Tk 8.5. It provides additional benefits including anti-aliased font
  231. rendering under X11 and window transparency (requiring a composition
  232. window manager on X11).</p>
  233. <p>The basic idea for <a class="reference internal" href="#module-tkinter.ttk" title="tkinter.ttk: Tk themed widget set"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.ttk</span></code></a> is to separate, to the extent possible,
  234. the code implementing a widget’s behavior from the code implementing its
  235. appearance.</p>
  236. <div class="admonition seealso">
  237. <p class="admonition-title">See also</p>
  238. <dl class="simple">
  239. <dt><a class="reference external" href="https://core.tcl.tk/tips/doc/trunk/tip/48.md">Tk Widget Styling Support</a></dt><dd><p>A document introducing theming support for Tk</p>
  240. </dd>
  241. </dl>
  242. </div>
  243. <section id="using-ttk">
  244. <h2>Using Ttk<a class="headerlink" href="#using-ttk" title="Link to this heading">¶</a></h2>
  245. <p>To start using Ttk, import its module:</p>
  246. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">tkinter</span> <span class="kn">import</span> <span class="n">ttk</span>
  247. </pre></div>
  248. </div>
  249. <p>To override the basic Tk widgets, the import should follow the Tk import:</p>
  250. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">tkinter</span> <span class="kn">import</span> <span class="o">*</span>
  251. <span class="kn">from</span> <span class="nn">tkinter.ttk</span> <span class="kn">import</span> <span class="o">*</span>
  252. </pre></div>
  253. </div>
  254. <p>That code causes several <a class="reference internal" href="#module-tkinter.ttk" title="tkinter.ttk: Tk themed widget set"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.ttk</span></code></a> widgets (<code class="xref py py-class docutils literal notranslate"><span class="pre">Button</span></code>,
  255. <code class="xref py py-class docutils literal notranslate"><span class="pre">Checkbutton</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Entry</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Frame</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Label</span></code>,
  256. <code class="xref py py-class docutils literal notranslate"><span class="pre">LabelFrame</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Menubutton</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">PanedWindow</span></code>,
  257. <code class="xref py py-class docutils literal notranslate"><span class="pre">Radiobutton</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Scale</span></code> and <code class="xref py py-class docutils literal notranslate"><span class="pre">Scrollbar</span></code>) to
  258. automatically replace the Tk widgets.</p>
  259. <p>This has the direct benefit of using the new widgets which gives a better
  260. look and feel across platforms; however, the replacement widgets are not
  261. completely compatible. The main difference is that widget options such as
  262. “fg”, “bg” and others related to widget styling are no
  263. longer present in Ttk widgets. Instead, use the <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Style</span></code> class
  264. for improved styling effects.</p>
  265. <div class="admonition seealso">
  266. <p class="admonition-title">See also</p>
  267. <dl class="simple">
  268. <dt><a class="reference external" href="https://tktable.sourceforge.net/tile/doc/converting.txt">Converting existing applications to use Tile widgets</a></dt><dd><p>A monograph (using Tcl terminology) about differences typically
  269. encountered when moving applications to use the new widgets.</p>
  270. </dd>
  271. </dl>
  272. </div>
  273. </section>
  274. <section id="ttk-widgets">
  275. <h2>Ttk Widgets<a class="headerlink" href="#ttk-widgets" title="Link to this heading">¶</a></h2>
  276. <p>Ttk comes with 18 widgets, twelve of which already existed in tkinter:
  277. <code class="xref py py-class docutils literal notranslate"><span class="pre">Button</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Checkbutton</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Entry</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Frame</span></code>,
  278. <code class="xref py py-class docutils literal notranslate"><span class="pre">Label</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">LabelFrame</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Menubutton</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">PanedWindow</span></code>,
  279. <code class="xref py py-class docutils literal notranslate"><span class="pre">Radiobutton</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Scale</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Scrollbar</span></code>, and <a class="reference internal" href="#tkinter.ttk.Spinbox" title="tkinter.ttk.Spinbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Spinbox</span></code></a>.
  280. The other six are new: <a class="reference internal" href="#tkinter.ttk.Combobox" title="tkinter.ttk.Combobox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Combobox</span></code></a>, <a class="reference internal" href="#tkinter.ttk.Notebook" title="tkinter.ttk.Notebook"><code class="xref py py-class docutils literal notranslate"><span class="pre">Notebook</span></code></a>,
  281. <a class="reference internal" href="#tkinter.ttk.Progressbar" title="tkinter.ttk.Progressbar"><code class="xref py py-class docutils literal notranslate"><span class="pre">Progressbar</span></code></a>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Separator</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Sizegrip</span></code> and
  282. <a class="reference internal" href="#tkinter.ttk.Treeview" title="tkinter.ttk.Treeview"><code class="xref py py-class docutils literal notranslate"><span class="pre">Treeview</span></code></a>. And all them are subclasses of <a class="reference internal" href="#tkinter.ttk.Widget" title="tkinter.ttk.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.</p>
  283. <p>Using the Ttk widgets gives the application an improved look and feel.
  284. As discussed above, there are differences in how the styling is coded.</p>
  285. <p>Tk code:</p>
  286. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">l1</span> <span class="o">=</span> <span class="n">tkinter</span><span class="o">.</span><span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s2">&quot;Test&quot;</span><span class="p">,</span> <span class="n">fg</span><span class="o">=</span><span class="s2">&quot;black&quot;</span><span class="p">,</span> <span class="n">bg</span><span class="o">=</span><span class="s2">&quot;white&quot;</span><span class="p">)</span>
  287. <span class="n">l2</span> <span class="o">=</span> <span class="n">tkinter</span><span class="o">.</span><span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s2">&quot;Test&quot;</span><span class="p">,</span> <span class="n">fg</span><span class="o">=</span><span class="s2">&quot;black&quot;</span><span class="p">,</span> <span class="n">bg</span><span class="o">=</span><span class="s2">&quot;white&quot;</span><span class="p">)</span>
  288. </pre></div>
  289. </div>
  290. <p>Ttk code:</p>
  291. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">style</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">()</span>
  292. <span class="n">style</span><span class="o">.</span><span class="n">configure</span><span class="p">(</span><span class="s2">&quot;BW.TLabel&quot;</span><span class="p">,</span> <span class="n">foreground</span><span class="o">=</span><span class="s2">&quot;black&quot;</span><span class="p">,</span> <span class="n">background</span><span class="o">=</span><span class="s2">&quot;white&quot;</span><span class="p">)</span>
  293. <span class="n">l1</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s2">&quot;Test&quot;</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="s2">&quot;BW.TLabel&quot;</span><span class="p">)</span>
  294. <span class="n">l2</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s2">&quot;Test&quot;</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="s2">&quot;BW.TLabel&quot;</span><span class="p">)</span>
  295. </pre></div>
  296. </div>
  297. <p>For more information about <a class="reference internal" href="#ttkstyling">TtkStyling</a>, see the <a class="reference internal" href="#tkinter.ttk.Style" title="tkinter.ttk.Style"><code class="xref py py-class docutils literal notranslate"><span class="pre">Style</span></code></a> class
  298. documentation.</p>
  299. </section>
  300. <section id="widget">
  301. <h2>Widget<a class="headerlink" href="#widget" title="Link to this heading">¶</a></h2>
  302. <p><code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Widget</span></code> defines standard options and methods supported by Tk
  303. themed widgets and is not supposed to be directly instantiated.</p>
  304. <section id="standard-options">
  305. <h3>Standard Options<a class="headerlink" href="#standard-options" title="Link to this heading">¶</a></h3>
  306. <p>All the <code class="xref py py-mod docutils literal notranslate"><span class="pre">ttk</span></code> Widgets accept the following options:</p>
  307. <table class="docutils align-default">
  308. <thead>
  309. <tr class="row-odd"><th class="head"><p>Option</p></th>
  310. <th class="head"><p>Description</p></th>
  311. </tr>
  312. </thead>
  313. <tbody>
  314. <tr class="row-even"><td><p>class</p></td>
  315. <td><p>Specifies the window class. The class is used when querying
  316. the option database for the window’s other options, to
  317. determine the default bindtags for the window, and to select
  318. the widget’s default layout and style. This option is
  319. read-only, and may only be specified when the window is
  320. created.</p></td>
  321. </tr>
  322. <tr class="row-odd"><td><p>cursor</p></td>
  323. <td><p>Specifies the mouse cursor to be used for the widget. If set
  324. to the empty string (the default), the cursor is inherited
  325. for the parent widget.</p></td>
  326. </tr>
  327. <tr class="row-even"><td><p>takefocus</p></td>
  328. <td><p>Determines whether the window accepts the focus during
  329. keyboard traversal. 0, 1 or an empty string is returned.
  330. If 0 is returned, it means that the window should be skipped
  331. entirely during keyboard traversal. If 1, it means that the
  332. window should receive the input focus as long as it is
  333. viewable. And an empty string means that the traversal
  334. scripts make the decision about whether or not to focus
  335. on the window.</p></td>
  336. </tr>
  337. <tr class="row-odd"><td><p>style</p></td>
  338. <td><p>May be used to specify a custom widget style.</p></td>
  339. </tr>
  340. </tbody>
  341. </table>
  342. </section>
  343. <section id="scrollable-widget-options">
  344. <h3>Scrollable Widget Options<a class="headerlink" href="#scrollable-widget-options" title="Link to this heading">¶</a></h3>
  345. <p>The following options are supported by widgets that are controlled by a
  346. scrollbar.</p>
  347. <table class="docutils align-default">
  348. <thead>
  349. <tr class="row-odd"><th class="head"><p>Option</p></th>
  350. <th class="head"><p>Description</p></th>
  351. </tr>
  352. </thead>
  353. <tbody>
  354. <tr class="row-even"><td><p>xscrollcommand</p></td>
  355. <td><p>Used to communicate with horizontal scrollbars.</p>
  356. <p>When the view in the widget’s window change, the widget
  357. will generate a Tcl command based on the scrollcommand.</p>
  358. <p>Usually this option consists of the method
  359. <code class="xref py py-meth docutils literal notranslate"><span class="pre">Scrollbar.set()</span></code> of some scrollbar. This will cause
  360. the scrollbar to be updated whenever the view in the
  361. window changes.</p>
  362. </td>
  363. </tr>
  364. <tr class="row-odd"><td><p>yscrollcommand</p></td>
  365. <td><p>Used to communicate with vertical scrollbars.
  366. For some more information, see above.</p></td>
  367. </tr>
  368. </tbody>
  369. </table>
  370. </section>
  371. <section id="label-options">
  372. <h3>Label Options<a class="headerlink" href="#label-options" title="Link to this heading">¶</a></h3>
  373. <p>The following options are supported by labels, buttons and other button-like
  374. widgets.</p>
  375. <table class="docutils align-default">
  376. <thead>
  377. <tr class="row-odd"><th class="head"><p>Option</p></th>
  378. <th class="head"><p>Description</p></th>
  379. </tr>
  380. </thead>
  381. <tbody>
  382. <tr class="row-even"><td><p>text</p></td>
  383. <td><p>Specifies a text string to be displayed inside the widget.</p></td>
  384. </tr>
  385. <tr class="row-odd"><td><p>textvariable</p></td>
  386. <td><p>Specifies a name whose value will be used in place of the
  387. text option resource.</p></td>
  388. </tr>
  389. <tr class="row-even"><td><p>underline</p></td>
  390. <td><p>If set, specifies the index (0-based) of a character to
  391. underline in the text string. The underline character is
  392. used for mnemonic activation.</p></td>
  393. </tr>
  394. <tr class="row-odd"><td><p>image</p></td>
  395. <td><p>Specifies an image to display. This is a list of 1 or more
  396. elements. The first element is the default image name. The
  397. rest of the list if a sequence of statespec/value pairs as
  398. defined by <a class="reference internal" href="#tkinter.ttk.Style.map" title="tkinter.ttk.Style.map"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Style.map()</span></code></a>, specifying different images
  399. to use when the widget is in a particular state or a
  400. combination of states. All images in the list should have
  401. the same size.</p></td>
  402. </tr>
  403. <tr class="row-even"><td><p>compound</p></td>
  404. <td><p>Specifies how to display the image relative to the text,
  405. in the case both text and images options are present.
  406. Valid values are:</p>
  407. <ul class="simple">
  408. <li><p>text: display text only</p></li>
  409. <li><p>image: display image only</p></li>
  410. <li><p>top, bottom, left, right: display image above, below,
  411. left of, or right of the text, respectively.</p></li>
  412. <li><p>none: the default. display the image if present,
  413. otherwise the text.</p></li>
  414. </ul>
  415. </td>
  416. </tr>
  417. <tr class="row-odd"><td><p>width</p></td>
  418. <td><p>If greater than zero, specifies how much space, in
  419. character widths, to allocate for the text label, if less
  420. than zero, specifies a minimum width. If zero or
  421. unspecified, the natural width of the text label is used.</p></td>
  422. </tr>
  423. </tbody>
  424. </table>
  425. </section>
  426. <section id="compatibility-options">
  427. <h3>Compatibility Options<a class="headerlink" href="#compatibility-options" title="Link to this heading">¶</a></h3>
  428. <table class="docutils align-default">
  429. <thead>
  430. <tr class="row-odd"><th class="head"><p>Option</p></th>
  431. <th class="head"><p>Description</p></th>
  432. </tr>
  433. </thead>
  434. <tbody>
  435. <tr class="row-even"><td><p>state</p></td>
  436. <td><p>May be set to “normal” or “disabled” to control the “disabled”
  437. state bit. This is a write-only option: setting it changes the
  438. widget state, but the <a class="reference internal" href="#tkinter.ttk.Widget.state" title="tkinter.ttk.Widget.state"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Widget.state()</span></code></a> method does not
  439. affect this option.</p></td>
  440. </tr>
  441. </tbody>
  442. </table>
  443. </section>
  444. <section id="widget-states">
  445. <h3>Widget States<a class="headerlink" href="#widget-states" title="Link to this heading">¶</a></h3>
  446. <p>The widget state is a bitmap of independent state flags.</p>
  447. <table class="docutils align-default">
  448. <thead>
  449. <tr class="row-odd"><th class="head"><p>Flag</p></th>
  450. <th class="head"><p>Description</p></th>
  451. </tr>
  452. </thead>
  453. <tbody>
  454. <tr class="row-even"><td><p>active</p></td>
  455. <td><p>The mouse cursor is over the widget and pressing a mouse
  456. button will cause some action to occur</p></td>
  457. </tr>
  458. <tr class="row-odd"><td><p>disabled</p></td>
  459. <td><p>Widget is disabled under program control</p></td>
  460. </tr>
  461. <tr class="row-even"><td><p>focus</p></td>
  462. <td><p>Widget has keyboard focus</p></td>
  463. </tr>
  464. <tr class="row-odd"><td><p>pressed</p></td>
  465. <td><p>Widget is being pressed</p></td>
  466. </tr>
  467. <tr class="row-even"><td><p>selected</p></td>
  468. <td><p>“On”, “true”, or “current” for things like Checkbuttons and
  469. radiobuttons</p></td>
  470. </tr>
  471. <tr class="row-odd"><td><p>background</p></td>
  472. <td><p>Windows and Mac have a notion of an “active” or foreground
  473. window. The <em>background</em> state is set for widgets in a
  474. background window, and cleared for those in the foreground
  475. window</p></td>
  476. </tr>
  477. <tr class="row-even"><td><p>readonly</p></td>
  478. <td><p>Widget should not allow user modification</p></td>
  479. </tr>
  480. <tr class="row-odd"><td><p>alternate</p></td>
  481. <td><p>A widget-specific alternate display format</p></td>
  482. </tr>
  483. <tr class="row-even"><td><p>invalid</p></td>
  484. <td><p>The widget’s value is invalid</p></td>
  485. </tr>
  486. </tbody>
  487. </table>
  488. <p>A state specification is a sequence of state names, optionally prefixed with
  489. an exclamation point indicating that the bit is off.</p>
  490. </section>
  491. <section id="ttk-widget">
  492. <h3>ttk.Widget<a class="headerlink" href="#ttk-widget" title="Link to this heading">¶</a></h3>
  493. <p>Besides the methods described below, the <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Widget</span></code> supports the
  494. methods <code class="xref py py-meth docutils literal notranslate"><span class="pre">tkinter.Widget.cget()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">tkinter.Widget.configure()</span></code>.</p>
  495. <dl class="py class">
  496. <dt class="sig sig-object py" id="tkinter.ttk.Widget">
  497. <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.ttk.</span></span><span class="sig-name descname"><span class="pre">Widget</span></span><a class="headerlink" href="#tkinter.ttk.Widget" title="Link to this definition">¶</a></dt>
  498. <dd><dl class="py method">
  499. <dt class="sig sig-object py" id="tkinter.ttk.Widget.identify">
  500. <span class="sig-name descname"><span class="pre">identify</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Widget.identify" title="Link to this definition">¶</a></dt>
  501. <dd><p>Returns the name of the element at position <em>x</em> <em>y</em>, or the empty string
  502. if the point does not lie within any element.</p>
  503. <p><em>x</em> and <em>y</em> are pixel coordinates relative to the widget.</p>
  504. </dd></dl>
  505. <dl class="py method">
  506. <dt class="sig sig-object py" id="tkinter.ttk.Widget.instate">
  507. <span class="sig-name descname"><span class="pre">instate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">statespec</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">callback</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Widget.instate" title="Link to this definition">¶</a></dt>
  508. <dd><p>Test the widget’s state. If a callback is not specified, returns <code class="docutils literal notranslate"><span class="pre">True</span></code>
  509. if the widget state matches <em>statespec</em> and <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise. If callback
  510. is specified then it is called with args if widget state matches
  511. <em>statespec</em>.</p>
  512. </dd></dl>
  513. <dl class="py method">
  514. <dt class="sig sig-object py" id="tkinter.ttk.Widget.state">
  515. <span class="sig-name descname"><span class="pre">state</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">statespec</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Widget.state" title="Link to this definition">¶</a></dt>
  516. <dd><p>Modify or inquire widget state. If <em>statespec</em> is specified, sets the
  517. widget state according to it and return a new <em>statespec</em> indicating
  518. which flags were changed. If <em>statespec</em> is not specified, returns
  519. the currently enabled state flags.</p>
  520. </dd></dl>
  521. <p><em>statespec</em> will usually be a list or a tuple.</p>
  522. </dd></dl>
  523. </section>
  524. </section>
  525. <section id="combobox">
  526. <h2>Combobox<a class="headerlink" href="#combobox" title="Link to this heading">¶</a></h2>
  527. <p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Combobox</span></code> widget combines a text field with a pop-down list of
  528. values. This widget is a subclass of <code class="xref py py-class docutils literal notranslate"><span class="pre">Entry</span></code>.</p>
  529. <p>Besides the methods inherited from <a class="reference internal" href="#tkinter.ttk.Widget" title="tkinter.ttk.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>: <code class="xref py py-meth docutils literal notranslate"><span class="pre">Widget.cget()</span></code>,
  530. <code class="xref py py-meth docutils literal notranslate"><span class="pre">Widget.configure()</span></code>, <a class="reference internal" href="#tkinter.ttk.Widget.identify" title="tkinter.ttk.Widget.identify"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Widget.identify()</span></code></a>, <a class="reference internal" href="#tkinter.ttk.Widget.instate" title="tkinter.ttk.Widget.instate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Widget.instate()</span></code></a>
  531. and <a class="reference internal" href="#tkinter.ttk.Widget.state" title="tkinter.ttk.Widget.state"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Widget.state()</span></code></a>, and the following inherited from <code class="xref py py-class docutils literal notranslate"><span class="pre">Entry</span></code>:
  532. <code class="xref py py-meth docutils literal notranslate"><span class="pre">Entry.bbox()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">Entry.delete()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">Entry.icursor()</span></code>,
  533. <code class="xref py py-meth docutils literal notranslate"><span class="pre">Entry.index()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">Entry.insert()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">Entry.selection()</span></code>,
  534. <code class="xref py py-meth docutils literal notranslate"><span class="pre">Entry.xview()</span></code>, it has some other methods, described at
  535. <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Combobox</span></code>.</p>
  536. <section id="options">
  537. <h3>Options<a class="headerlink" href="#options" title="Link to this heading">¶</a></h3>
  538. <p>This widget accepts the following specific options:</p>
  539. <table class="docutils align-default">
  540. <thead>
  541. <tr class="row-odd"><th class="head"><p>Option</p></th>
  542. <th class="head"><p>Description</p></th>
  543. </tr>
  544. </thead>
  545. <tbody>
  546. <tr class="row-even"><td><p>exportselection</p></td>
  547. <td><p>Boolean value. If set, the widget selection is linked
  548. to the Window Manager selection (which can be returned
  549. by invoking Misc.selection_get, for example).</p></td>
  550. </tr>
  551. <tr class="row-odd"><td><p>justify</p></td>
  552. <td><p>Specifies how the text is aligned within the widget.
  553. One of “left”, “center”, or “right”.</p></td>
  554. </tr>
  555. <tr class="row-even"><td><p>height</p></td>
  556. <td><p>Specifies the height of the pop-down listbox, in rows.</p></td>
  557. </tr>
  558. <tr class="row-odd"><td><p>postcommand</p></td>
  559. <td><p>A script (possibly registered with Misc.register) that
  560. is called immediately before displaying the values. It
  561. may specify which values to display.</p></td>
  562. </tr>
  563. <tr class="row-even"><td><p>state</p></td>
  564. <td><p>One of “normal”, “readonly”, or “disabled”. In the
  565. “readonly” state, the value may not be edited directly,
  566. and the user can only selection of the values from the
  567. dropdown list. In the “normal” state, the text field is
  568. directly editable. In the “disabled” state, no
  569. interaction is possible.</p></td>
  570. </tr>
  571. <tr class="row-odd"><td><p>textvariable</p></td>
  572. <td><p>Specifies a name whose value is linked to the widget
  573. value. Whenever the value associated with that name
  574. changes, the widget value is updated, and vice versa.
  575. See <code class="xref py py-class docutils literal notranslate"><span class="pre">tkinter.StringVar</span></code>.</p></td>
  576. </tr>
  577. <tr class="row-even"><td><p>values</p></td>
  578. <td><p>Specifies the list of values to display in the
  579. drop-down listbox.</p></td>
  580. </tr>
  581. <tr class="row-odd"><td><p>width</p></td>
  582. <td><p>Specifies an integer value indicating the desired width
  583. of the entry window, in average-size characters of the
  584. widget’s font.</p></td>
  585. </tr>
  586. </tbody>
  587. </table>
  588. </section>
  589. <section id="virtual-events">
  590. <h3>Virtual events<a class="headerlink" href="#virtual-events" title="Link to this heading">¶</a></h3>
  591. <p>The combobox widgets generates a <strong>&lt;&lt;ComboboxSelected&gt;&gt;</strong> virtual event
  592. when the user selects an element from the list of values.</p>
  593. </section>
  594. <section id="ttk-combobox">
  595. <h3>ttk.Combobox<a class="headerlink" href="#ttk-combobox" title="Link to this heading">¶</a></h3>
  596. <dl class="py class">
  597. <dt class="sig sig-object py" id="tkinter.ttk.Combobox">
  598. <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.ttk.</span></span><span class="sig-name descname"><span class="pre">Combobox</span></span><a class="headerlink" href="#tkinter.ttk.Combobox" title="Link to this definition">¶</a></dt>
  599. <dd><dl class="py method">
  600. <dt class="sig sig-object py" id="tkinter.ttk.Combobox.current">
  601. <span class="sig-name descname"><span class="pre">current</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newindex</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Combobox.current" title="Link to this definition">¶</a></dt>
  602. <dd><p>If <em>newindex</em> is specified, sets the combobox value to the element
  603. position <em>newindex</em>. Otherwise, returns the index of the current value or
  604. -1 if the current value is not in the values list.</p>
  605. </dd></dl>
  606. <dl class="py method">
  607. <dt class="sig sig-object py" id="tkinter.ttk.Combobox.get">
  608. <span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Combobox.get" title="Link to this definition">¶</a></dt>
  609. <dd><p>Returns the current value of the combobox.</p>
  610. </dd></dl>
  611. <dl class="py method">
  612. <dt class="sig sig-object py" id="tkinter.ttk.Combobox.set">
  613. <span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Combobox.set" title="Link to this definition">¶</a></dt>
  614. <dd><p>Sets the value of the combobox to <em>value</em>.</p>
  615. </dd></dl>
  616. </dd></dl>
  617. </section>
  618. </section>
  619. <section id="spinbox">
  620. <h2>Spinbox<a class="headerlink" href="#spinbox" title="Link to this heading">¶</a></h2>
  621. <p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Spinbox</span></code> widget is a <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Entry</span></code> enhanced with increment
  622. and decrement arrows. It can be used for numbers or lists of string values.
  623. This widget is a subclass of <code class="xref py py-class docutils literal notranslate"><span class="pre">Entry</span></code>.</p>
  624. <p>Besides the methods inherited from <a class="reference internal" href="#tkinter.ttk.Widget" title="tkinter.ttk.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>: <code class="xref py py-meth docutils literal notranslate"><span class="pre">Widget.cget()</span></code>,
  625. <code class="xref py py-meth docutils literal notranslate"><span class="pre">Widget.configure()</span></code>, <a class="reference internal" href="#tkinter.ttk.Widget.identify" title="tkinter.ttk.Widget.identify"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Widget.identify()</span></code></a>, <a class="reference internal" href="#tkinter.ttk.Widget.instate" title="tkinter.ttk.Widget.instate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Widget.instate()</span></code></a>
  626. and <a class="reference internal" href="#tkinter.ttk.Widget.state" title="tkinter.ttk.Widget.state"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Widget.state()</span></code></a>, and the following inherited from <code class="xref py py-class docutils literal notranslate"><span class="pre">Entry</span></code>:
  627. <code class="xref py py-meth docutils literal notranslate"><span class="pre">Entry.bbox()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">Entry.delete()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">Entry.icursor()</span></code>,
  628. <code class="xref py py-meth docutils literal notranslate"><span class="pre">Entry.index()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">Entry.insert()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">Entry.xview()</span></code>,
  629. it has some other methods, described at <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Spinbox</span></code>.</p>
  630. <section id="id1">
  631. <h3>Options<a class="headerlink" href="#id1" title="Link to this heading">¶</a></h3>
  632. <p>This widget accepts the following specific options:</p>
  633. <table class="docutils align-default">
  634. <thead>
  635. <tr class="row-odd"><th class="head"><p>Option</p></th>
  636. <th class="head"><p>Description</p></th>
  637. </tr>
  638. </thead>
  639. <tbody>
  640. <tr class="row-even"><td><p>from</p></td>
  641. <td><p>Float value. If set, this is the minimum value to
  642. which the decrement button will decrement. Must be
  643. spelled as <code class="docutils literal notranslate"><span class="pre">from_</span></code> when used as an argument, since
  644. <code class="docutils literal notranslate"><span class="pre">from</span></code> is a Python keyword.</p></td>
  645. </tr>
  646. <tr class="row-odd"><td><p>to</p></td>
  647. <td><p>Float value. If set, this is the maximum value to
  648. which the increment button will increment.</p></td>
  649. </tr>
  650. <tr class="row-even"><td><p>increment</p></td>
  651. <td><p>Float value. Specifies the amount which the
  652. increment/decrement buttons change the
  653. value. Defaults to 1.0.</p></td>
  654. </tr>
  655. <tr class="row-odd"><td><p>values</p></td>
  656. <td><p>Sequence of string or float values. If specified,
  657. the increment/decrement buttons will cycle through
  658. the items in this sequence rather than incrementing
  659. or decrementing numbers.</p></td>
  660. </tr>
  661. <tr class="row-even"><td><p>wrap</p></td>
  662. <td><p>Boolean value. If <code class="docutils literal notranslate"><span class="pre">True</span></code>, increment and decrement
  663. buttons will cycle from the <code class="docutils literal notranslate"><span class="pre">to</span></code> value to the
  664. <code class="docutils literal notranslate"><span class="pre">from</span></code> value or the <code class="docutils literal notranslate"><span class="pre">from</span></code> value to the <code class="docutils literal notranslate"><span class="pre">to</span></code>
  665. value, respectively.</p></td>
  666. </tr>
  667. <tr class="row-odd"><td><p>format</p></td>
  668. <td><p>String value. This specifies the format of numbers
  669. set by the increment/decrement buttons. It must be
  670. in the form “%W.Pf”, where W is the padded width of
  671. the value, P is the precision, and ‘%’ and ‘f’ are
  672. literal.</p></td>
  673. </tr>
  674. <tr class="row-even"><td><p>command</p></td>
  675. <td><p>Python callable. Will be called with no arguments
  676. whenever either of the increment or decrement buttons
  677. are pressed.</p></td>
  678. </tr>
  679. </tbody>
  680. </table>
  681. </section>
  682. <section id="id2">
  683. <h3>Virtual events<a class="headerlink" href="#id2" title="Link to this heading">¶</a></h3>
  684. <p>The spinbox widget generates an <strong>&lt;&lt;Increment&gt;&gt;</strong> virtual event when the
  685. user presses &lt;Up&gt;, and a <strong>&lt;&lt;Decrement&gt;&gt;</strong> virtual event when the user
  686. presses &lt;Down&gt;.</p>
  687. </section>
  688. <section id="ttk-spinbox">
  689. <h3>ttk.Spinbox<a class="headerlink" href="#ttk-spinbox" title="Link to this heading">¶</a></h3>
  690. <dl class="py class">
  691. <dt class="sig sig-object py" id="tkinter.ttk.Spinbox">
  692. <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.ttk.</span></span><span class="sig-name descname"><span class="pre">Spinbox</span></span><a class="headerlink" href="#tkinter.ttk.Spinbox" title="Link to this definition">¶</a></dt>
  693. <dd><dl class="py method">
  694. <dt class="sig sig-object py" id="tkinter.ttk.Spinbox.get">
  695. <span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Spinbox.get" title="Link to this definition">¶</a></dt>
  696. <dd><p>Returns the current value of the spinbox.</p>
  697. </dd></dl>
  698. <dl class="py method">
  699. <dt class="sig sig-object py" id="tkinter.ttk.Spinbox.set">
  700. <span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Spinbox.set" title="Link to this definition">¶</a></dt>
  701. <dd><p>Sets the value of the spinbox to <em>value</em>.</p>
  702. </dd></dl>
  703. </dd></dl>
  704. </section>
  705. </section>
  706. <section id="notebook">
  707. <h2>Notebook<a class="headerlink" href="#notebook" title="Link to this heading">¶</a></h2>
  708. <p>Ttk Notebook widget manages a collection of windows and displays a single
  709. one at a time. Each child window is associated with a tab, which the user
  710. may select to change the currently displayed window.</p>
  711. <section id="id3">
  712. <h3>Options<a class="headerlink" href="#id3" title="Link to this heading">¶</a></h3>
  713. <p>This widget accepts the following specific options:</p>
  714. <table class="docutils align-default">
  715. <thead>
  716. <tr class="row-odd"><th class="head"><p>Option</p></th>
  717. <th class="head"><p>Description</p></th>
  718. </tr>
  719. </thead>
  720. <tbody>
  721. <tr class="row-even"><td><p>height</p></td>
  722. <td><p>If present and greater than zero, specifies the desired height
  723. of the pane area (not including internal padding or tabs).
  724. Otherwise, the maximum height of all panes is used.</p></td>
  725. </tr>
  726. <tr class="row-odd"><td><p>padding</p></td>
  727. <td><p>Specifies the amount of extra space to add around the outside
  728. of the notebook. The padding is a list up to four length
  729. specifications left top right bottom. If fewer than four
  730. elements are specified, bottom defaults to top, right defaults
  731. to left, and top defaults to left.</p></td>
  732. </tr>
  733. <tr class="row-even"><td><p>width</p></td>
  734. <td><p>If present and greater than zero, specified the desired width
  735. of the pane area (not including internal padding). Otherwise,
  736. the maximum width of all panes is used.</p></td>
  737. </tr>
  738. </tbody>
  739. </table>
  740. </section>
  741. <section id="tab-options">
  742. <h3>Tab Options<a class="headerlink" href="#tab-options" title="Link to this heading">¶</a></h3>
  743. <p>There are also specific options for tabs:</p>
  744. <table class="docutils align-default">
  745. <thead>
  746. <tr class="row-odd"><th class="head"><p>Option</p></th>
  747. <th class="head"><p>Description</p></th>
  748. </tr>
  749. </thead>
  750. <tbody>
  751. <tr class="row-even"><td><p>state</p></td>
  752. <td><p>Either “normal”, “disabled” or “hidden”. If “disabled”, then
  753. the tab is not selectable. If “hidden”, then the tab is not
  754. shown.</p></td>
  755. </tr>
  756. <tr class="row-odd"><td><p>sticky</p></td>
  757. <td><p>Specifies how the child window is positioned within the pane
  758. area. Value is a string containing zero or more of the
  759. characters “n”, “s”, “e” or “w”. Each letter refers to a
  760. side (north, south, east or west) that the child window will
  761. stick to, as per the <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid()</span></code> geometry manager.</p></td>
  762. </tr>
  763. <tr class="row-even"><td><p>padding</p></td>
  764. <td><p>Specifies the amount of extra space to add between the
  765. notebook and this pane. Syntax is the same as for the option
  766. padding used by this widget.</p></td>
  767. </tr>
  768. <tr class="row-odd"><td><p>text</p></td>
  769. <td><p>Specifies a text to be displayed in the tab.</p></td>
  770. </tr>
  771. <tr class="row-even"><td><p>image</p></td>
  772. <td><p>Specifies an image to display in the tab. See the option
  773. image described in <a class="reference internal" href="#tkinter.ttk.Widget" title="tkinter.ttk.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.</p></td>
  774. </tr>
  775. <tr class="row-odd"><td><p>compound</p></td>
  776. <td><p>Specifies how to display the image relative to the text, in
  777. the case both options text and image are present. See
  778. <a class="reference internal" href="#label-options">Label Options</a> for legal values.</p></td>
  779. </tr>
  780. <tr class="row-even"><td><p>underline</p></td>
  781. <td><p>Specifies the index (0-based) of a character to underline in
  782. the text string. The underlined character is used for
  783. mnemonic activation if <a class="reference internal" href="#tkinter.ttk.Notebook.enable_traversal" title="tkinter.ttk.Notebook.enable_traversal"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Notebook.enable_traversal()</span></code></a> is
  784. called.</p></td>
  785. </tr>
  786. </tbody>
  787. </table>
  788. </section>
  789. <section id="tab-identifiers">
  790. <h3>Tab Identifiers<a class="headerlink" href="#tab-identifiers" title="Link to this heading">¶</a></h3>
  791. <p>The tab_id present in several methods of <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Notebook</span></code> may take any
  792. of the following forms:</p>
  793. <ul class="simple">
  794. <li><p>An integer between zero and the number of tabs</p></li>
  795. <li><p>The name of a child window</p></li>
  796. <li><p>A positional specification of the form “&#64;x,y”, which identifies the tab</p></li>
  797. <li><p>The literal string “current”, which identifies the currently selected tab</p></li>
  798. <li><p>The literal string “end”, which returns the number of tabs (only valid for
  799. <a class="reference internal" href="#tkinter.ttk.Notebook.index" title="tkinter.ttk.Notebook.index"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Notebook.index()</span></code></a>)</p></li>
  800. </ul>
  801. </section>
  802. <section id="id4">
  803. <h3>Virtual Events<a class="headerlink" href="#id4" title="Link to this heading">¶</a></h3>
  804. <p>This widget generates a <strong>&lt;&lt;NotebookTabChanged&gt;&gt;</strong> virtual event after a new
  805. tab is selected.</p>
  806. </section>
  807. <section id="ttk-notebook">
  808. <h3>ttk.Notebook<a class="headerlink" href="#ttk-notebook" title="Link to this heading">¶</a></h3>
  809. <dl class="py class">
  810. <dt class="sig sig-object py" id="tkinter.ttk.Notebook">
  811. <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.ttk.</span></span><span class="sig-name descname"><span class="pre">Notebook</span></span><a class="headerlink" href="#tkinter.ttk.Notebook" title="Link to this definition">¶</a></dt>
  812. <dd><dl class="py method">
  813. <dt class="sig sig-object py" id="tkinter.ttk.Notebook.add">
  814. <span class="sig-name descname"><span class="pre">add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">child</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Notebook.add" title="Link to this definition">¶</a></dt>
  815. <dd><p>Adds a new tab to the notebook.</p>
  816. <p>If window is currently managed by the notebook but hidden, it is
  817. restored to its previous position.</p>
  818. <p>See <a class="reference internal" href="#tab-options">Tab Options</a> for the list of available options.</p>
  819. </dd></dl>
  820. <dl class="py method">
  821. <dt class="sig sig-object py" id="tkinter.ttk.Notebook.forget">
  822. <span class="sig-name descname"><span class="pre">forget</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tab_id</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Notebook.forget" title="Link to this definition">¶</a></dt>
  823. <dd><p>Removes the tab specified by <em>tab_id</em>, unmaps and unmanages the
  824. associated window.</p>
  825. </dd></dl>
  826. <dl class="py method">
  827. <dt class="sig sig-object py" id="tkinter.ttk.Notebook.hide">
  828. <span class="sig-name descname"><span class="pre">hide</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tab_id</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Notebook.hide" title="Link to this definition">¶</a></dt>
  829. <dd><p>Hides the tab specified by <em>tab_id</em>.</p>
  830. <p>The tab will not be displayed, but the associated window remains
  831. managed by the notebook and its configuration remembered. Hidden tabs
  832. may be restored with the <a class="reference internal" href="#tkinter.ttk.Notebook.add" title="tkinter.ttk.Notebook.add"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add()</span></code></a> command.</p>
  833. </dd></dl>
  834. <dl class="py method">
  835. <dt class="sig sig-object py" id="tkinter.ttk.Notebook.identify">
  836. <span class="sig-name descname"><span class="pre">identify</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Notebook.identify" title="Link to this definition">¶</a></dt>
  837. <dd><p>Returns the name of the tab element at position <em>x</em>, <em>y</em>, or the empty
  838. string if none.</p>
  839. </dd></dl>
  840. <dl class="py method">
  841. <dt class="sig sig-object py" id="tkinter.ttk.Notebook.index">
  842. <span class="sig-name descname"><span class="pre">index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tab_id</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Notebook.index" title="Link to this definition">¶</a></dt>
  843. <dd><p>Returns the numeric index of the tab specified by <em>tab_id</em>, or the total
  844. number of tabs if <em>tab_id</em> is the string “end”.</p>
  845. </dd></dl>
  846. <dl class="py method">
  847. <dt class="sig sig-object py" id="tkinter.ttk.Notebook.insert">
  848. <span class="sig-name descname"><span class="pre">insert</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pos</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">child</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Notebook.insert" title="Link to this definition">¶</a></dt>
  849. <dd><p>Inserts a pane at the specified position.</p>
  850. <p><em>pos</em> is either the string “end”, an integer index, or the name of a
  851. managed child. If <em>child</em> is already managed by the notebook, moves it to
  852. the specified position.</p>
  853. <p>See <a class="reference internal" href="#tab-options">Tab Options</a> for the list of available options.</p>
  854. </dd></dl>
  855. <dl class="py method">
  856. <dt class="sig sig-object py" id="tkinter.ttk.Notebook.select">
  857. <span class="sig-name descname"><span class="pre">select</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tab_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Notebook.select" title="Link to this definition">¶</a></dt>
  858. <dd><p>Selects the specified <em>tab_id</em>.</p>
  859. <p>The associated child window will be displayed, and the
  860. previously selected window (if different) is unmapped. If <em>tab_id</em> is
  861. omitted, returns the widget name of the currently selected pane.</p>
  862. </dd></dl>
  863. <dl class="py method">
  864. <dt class="sig sig-object py" id="tkinter.ttk.Notebook.tab">
  865. <span class="sig-name descname"><span class="pre">tab</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tab_id</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">option</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Notebook.tab" title="Link to this definition">¶</a></dt>
  866. <dd><p>Query or modify the options of the specific <em>tab_id</em>.</p>
  867. <p>If <em>kw</em> is not given, returns a dictionary of the tab option values. If
  868. <em>option</em> is specified, returns the value of that <em>option</em>. Otherwise,
  869. sets the options to the corresponding values.</p>
  870. </dd></dl>
  871. <dl class="py method">
  872. <dt class="sig sig-object py" id="tkinter.ttk.Notebook.tabs">
  873. <span class="sig-name descname"><span class="pre">tabs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Notebook.tabs" title="Link to this definition">¶</a></dt>
  874. <dd><p>Returns a list of windows managed by the notebook.</p>
  875. </dd></dl>
  876. <dl class="py method">
  877. <dt class="sig sig-object py" id="tkinter.ttk.Notebook.enable_traversal">
  878. <span class="sig-name descname"><span class="pre">enable_traversal</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Notebook.enable_traversal" title="Link to this definition">¶</a></dt>
  879. <dd><p>Enable keyboard traversal for a toplevel window containing this notebook.</p>
  880. <p>This will extend the bindings for the toplevel window containing the
  881. notebook as follows:</p>
  882. <ul class="simple">
  883. <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Control</kbd>-<kbd class="kbd docutils literal notranslate">Tab</kbd></kbd>: selects the tab following the currently selected one.</p></li>
  884. <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Shift</kbd>-<kbd class="kbd docutils literal notranslate">Control</kbd>-<kbd class="kbd docutils literal notranslate">Tab</kbd></kbd>: selects the tab preceding the currently selected one.</p></li>
  885. <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Alt</kbd>-<kbd class="kbd docutils literal notranslate">K</kbd></kbd>: where <em>K</em> is the mnemonic (underlined) character of any tab, will
  886. select that tab.</p></li>
  887. </ul>
  888. <p>Multiple notebooks in a single toplevel may be enabled for traversal,
  889. including nested notebooks. However, notebook traversal only works
  890. properly if all panes have the notebook they are in as master.</p>
  891. </dd></dl>
  892. </dd></dl>
  893. </section>
  894. </section>
  895. <section id="progressbar">
  896. <h2>Progressbar<a class="headerlink" href="#progressbar" title="Link to this heading">¶</a></h2>
  897. <p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Progressbar</span></code> widget shows the status of a long-running
  898. operation. It can operate in two modes: 1) the determinate mode which shows the
  899. amount completed relative to the total amount of work to be done and 2) the
  900. indeterminate mode which provides an animated display to let the user know that
  901. work is progressing.</p>
  902. <section id="id5">
  903. <h3>Options<a class="headerlink" href="#id5" title="Link to this heading">¶</a></h3>
  904. <p>This widget accepts the following specific options:</p>
  905. <table class="docutils align-default">
  906. <thead>
  907. <tr class="row-odd"><th class="head"><p>Option</p></th>
  908. <th class="head"><p>Description</p></th>
  909. </tr>
  910. </thead>
  911. <tbody>
  912. <tr class="row-even"><td><p>orient</p></td>
  913. <td><p>One of “horizontal” or “vertical”. Specifies the orientation
  914. of the progress bar.</p></td>
  915. </tr>
  916. <tr class="row-odd"><td><p>length</p></td>
  917. <td><p>Specifies the length of the long axis of the progress bar
  918. (width if horizontal, height if vertical).</p></td>
  919. </tr>
  920. <tr class="row-even"><td><p>mode</p></td>
  921. <td><p>One of “determinate” or “indeterminate”.</p></td>
  922. </tr>
  923. <tr class="row-odd"><td><p>maximum</p></td>
  924. <td><p>A number specifying the maximum value. Defaults to 100.</p></td>
  925. </tr>
  926. <tr class="row-even"><td><p>value</p></td>
  927. <td><p>The current value of the progress bar. In “determinate” mode,
  928. this represents the amount of work completed. In
  929. “indeterminate” mode, it is interpreted as modulo <em>maximum</em>;
  930. that is, the progress bar completes one “cycle” when its value
  931. increases by <em>maximum</em>.</p></td>
  932. </tr>
  933. <tr class="row-odd"><td><p>variable</p></td>
  934. <td><p>A name which is linked to the option value. If specified, the
  935. value of the progress bar is automatically set to the value of
  936. this name whenever the latter is modified.</p></td>
  937. </tr>
  938. <tr class="row-even"><td><p>phase</p></td>
  939. <td><p>Read-only option. The widget periodically increments the value
  940. of this option whenever its value is greater than 0 and, in
  941. determinate mode, less than maximum. This option may be used
  942. by the current theme to provide additional animation effects.</p></td>
  943. </tr>
  944. </tbody>
  945. </table>
  946. </section>
  947. <section id="ttk-progressbar">
  948. <h3>ttk.Progressbar<a class="headerlink" href="#ttk-progressbar" title="Link to this heading">¶</a></h3>
  949. <dl class="py class">
  950. <dt class="sig sig-object py" id="tkinter.ttk.Progressbar">
  951. <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.ttk.</span></span><span class="sig-name descname"><span class="pre">Progressbar</span></span><a class="headerlink" href="#tkinter.ttk.Progressbar" title="Link to this definition">¶</a></dt>
  952. <dd><dl class="py method">
  953. <dt class="sig sig-object py" id="tkinter.ttk.Progressbar.start">
  954. <span class="sig-name descname"><span class="pre">start</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">interval</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Progressbar.start" title="Link to this definition">¶</a></dt>
  955. <dd><p>Begin autoincrement mode: schedules a recurring timer event that calls
  956. <a class="reference internal" href="#tkinter.ttk.Progressbar.step" title="tkinter.ttk.Progressbar.step"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Progressbar.step()</span></code></a> every <em>interval</em> milliseconds. If omitted,
  957. <em>interval</em> defaults to 50 milliseconds.</p>
  958. </dd></dl>
  959. <dl class="py method">
  960. <dt class="sig sig-object py" id="tkinter.ttk.Progressbar.step">
  961. <span class="sig-name descname"><span class="pre">step</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">amount</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Progressbar.step" title="Link to this definition">¶</a></dt>
  962. <dd><p>Increments the progress bar’s value by <em>amount</em>.</p>
  963. <p><em>amount</em> defaults to 1.0 if omitted.</p>
  964. </dd></dl>
  965. <dl class="py method">
  966. <dt class="sig sig-object py" id="tkinter.ttk.Progressbar.stop">
  967. <span class="sig-name descname"><span class="pre">stop</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Progressbar.stop" title="Link to this definition">¶</a></dt>
  968. <dd><p>Stop autoincrement mode: cancels any recurring timer event initiated by
  969. <a class="reference internal" href="#tkinter.ttk.Progressbar.start" title="tkinter.ttk.Progressbar.start"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Progressbar.start()</span></code></a> for this progress bar.</p>
  970. </dd></dl>
  971. </dd></dl>
  972. </section>
  973. </section>
  974. <section id="separator">
  975. <h2>Separator<a class="headerlink" href="#separator" title="Link to this heading">¶</a></h2>
  976. <p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Separator</span></code> widget displays a horizontal or vertical separator
  977. bar.</p>
  978. <p>It has no other methods besides the ones inherited from <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Widget</span></code>.</p>
  979. <section id="id6">
  980. <h3>Options<a class="headerlink" href="#id6" title="Link to this heading">¶</a></h3>
  981. <p>This widget accepts the following specific option:</p>
  982. <table class="docutils align-default">
  983. <thead>
  984. <tr class="row-odd"><th class="head"><p>Option</p></th>
  985. <th class="head"><p>Description</p></th>
  986. </tr>
  987. </thead>
  988. <tbody>
  989. <tr class="row-even"><td><p>orient</p></td>
  990. <td><p>One of “horizontal” or “vertical”. Specifies the orientation of
  991. the separator.</p></td>
  992. </tr>
  993. </tbody>
  994. </table>
  995. </section>
  996. </section>
  997. <section id="sizegrip">
  998. <h2>Sizegrip<a class="headerlink" href="#sizegrip" title="Link to this heading">¶</a></h2>
  999. <p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Sizegrip</span></code> widget (also known as a grow box) allows the user to
  1000. resize the containing toplevel window by pressing and dragging the grip.</p>
  1001. <p>This widget has neither specific options nor specific methods, besides the
  1002. ones inherited from <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Widget</span></code>.</p>
  1003. <section id="platform-specific-notes">
  1004. <h3>Platform-specific notes<a class="headerlink" href="#platform-specific-notes" title="Link to this heading">¶</a></h3>
  1005. <ul class="simple">
  1006. <li><p>On macOS, toplevel windows automatically include a built-in size grip
  1007. by default. Adding a <code class="xref py py-class docutils literal notranslate"><span class="pre">Sizegrip</span></code> is harmless, since the built-in
  1008. grip will just mask the widget.</p></li>
  1009. </ul>
  1010. </section>
  1011. <section id="bugs">
  1012. <h3>Bugs<a class="headerlink" href="#bugs" title="Link to this heading">¶</a></h3>
  1013. <ul class="simple">
  1014. <li><p>If the containing toplevel’s position was specified relative to the right
  1015. or bottom of the screen (e.g. ….), the <code class="xref py py-class docutils literal notranslate"><span class="pre">Sizegrip</span></code> widget will
  1016. not resize the window.</p></li>
  1017. <li><p>This widget supports only “southeast” resizing.</p></li>
  1018. </ul>
  1019. </section>
  1020. </section>
  1021. <section id="treeview">
  1022. <h2>Treeview<a class="headerlink" href="#treeview" title="Link to this heading">¶</a></h2>
  1023. <p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Treeview</span></code> widget displays a hierarchical collection of items.
  1024. Each item has a textual label, an optional image, and an optional list of data
  1025. values. The data values are displayed in successive columns after the tree
  1026. label.</p>
  1027. <p>The order in which data values are displayed may be controlled by setting
  1028. the widget option <code class="docutils literal notranslate"><span class="pre">displaycolumns</span></code>. The tree widget can also display column
  1029. headings. Columns may be accessed by number or symbolic names listed in the
  1030. widget option columns. See <a class="reference internal" href="#column-identifiers">Column Identifiers</a>.</p>
  1031. <p>Each item is identified by a unique name. The widget will generate item IDs
  1032. if they are not supplied by the caller. There is a distinguished root item,
  1033. named <code class="docutils literal notranslate"><span class="pre">{}</span></code>. The root item itself is not displayed; its children appear at the
  1034. top level of the hierarchy.</p>
  1035. <p>Each item also has a list of tags, which can be used to associate event bindings
  1036. with individual items and control the appearance of the item.</p>
  1037. <p>The Treeview widget supports horizontal and vertical scrolling, according to
  1038. the options described in <a class="reference internal" href="#scrollable-widget-options">Scrollable Widget Options</a> and the methods
  1039. <a class="reference internal" href="#tkinter.ttk.Treeview.xview" title="tkinter.ttk.Treeview.xview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Treeview.xview()</span></code></a> and <a class="reference internal" href="#tkinter.ttk.Treeview.yview" title="tkinter.ttk.Treeview.yview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Treeview.yview()</span></code></a>.</p>
  1040. <section id="id7">
  1041. <h3>Options<a class="headerlink" href="#id7" title="Link to this heading">¶</a></h3>
  1042. <p>This widget accepts the following specific options:</p>
  1043. <table class="docutils align-default">
  1044. <thead>
  1045. <tr class="row-odd"><th class="head"><p>Option</p></th>
  1046. <th class="head"><p>Description</p></th>
  1047. </tr>
  1048. </thead>
  1049. <tbody>
  1050. <tr class="row-even"><td><p>columns</p></td>
  1051. <td><p>A list of column identifiers, specifying the number of
  1052. columns and their names.</p></td>
  1053. </tr>
  1054. <tr class="row-odd"><td><p>displaycolumns</p></td>
  1055. <td><p>A list of column identifiers (either symbolic or
  1056. integer indices) specifying which data columns are
  1057. displayed and the order in which they appear, or the
  1058. string “#all”.</p></td>
  1059. </tr>
  1060. <tr class="row-even"><td><p>height</p></td>
  1061. <td><p>Specifies the number of rows which should be visible.
  1062. Note: the requested width is determined from the sum
  1063. of the column widths.</p></td>
  1064. </tr>
  1065. <tr class="row-odd"><td><p>padding</p></td>
  1066. <td><p>Specifies the internal padding for the widget. The
  1067. padding is a list of up to four length specifications.</p></td>
  1068. </tr>
  1069. <tr class="row-even"><td><p>selectmode</p></td>
  1070. <td><p>Controls how the built-in class bindings manage the
  1071. selection. One of “extended”, “browse” or “none”.
  1072. If set to “extended” (the default), multiple items may
  1073. be selected. If “browse”, only a single item will be
  1074. selected at a time. If “none”, the selection will not
  1075. be changed.</p>
  1076. <p>Note that the application code and tag bindings can set
  1077. the selection however they wish, regardless of the
  1078. value of this option.</p>
  1079. </td>
  1080. </tr>
  1081. <tr class="row-odd"><td><p>show</p></td>
  1082. <td><p>A list containing zero or more of the following values,
  1083. specifying which elements of the tree to display.</p>
  1084. <ul class="simple">
  1085. <li><p>tree: display tree labels in column #0.</p></li>
  1086. <li><p>headings: display the heading row.</p></li>
  1087. </ul>
  1088. <p>The default is “tree headings”, i.e., show all
  1089. elements.</p>
  1090. <p><strong>Note</strong>: Column #0 always refers to the tree column,
  1091. even if show=”tree” is not specified.</p>
  1092. </td>
  1093. </tr>
  1094. </tbody>
  1095. </table>
  1096. </section>
  1097. <section id="item-options">
  1098. <h3>Item Options<a class="headerlink" href="#item-options" title="Link to this heading">¶</a></h3>
  1099. <p>The following item options may be specified for items in the insert and item
  1100. widget commands.</p>
  1101. <table class="docutils align-default">
  1102. <thead>
  1103. <tr class="row-odd"><th class="head"><p>Option</p></th>
  1104. <th class="head"><p>Description</p></th>
  1105. </tr>
  1106. </thead>
  1107. <tbody>
  1108. <tr class="row-even"><td><p>text</p></td>
  1109. <td><p>The textual label to display for the item.</p></td>
  1110. </tr>
  1111. <tr class="row-odd"><td><p>image</p></td>
  1112. <td><p>A Tk Image, displayed to the left of the label.</p></td>
  1113. </tr>
  1114. <tr class="row-even"><td><p>values</p></td>
  1115. <td><p>The list of values associated with the item.</p>
  1116. <p>Each item should have the same number of values as the widget
  1117. option columns. If there are fewer values than columns, the
  1118. remaining values are assumed empty. If there are more values
  1119. than columns, the extra values are ignored.</p>
  1120. </td>
  1121. </tr>
  1122. <tr class="row-odd"><td><p>open</p></td>
  1123. <td><p><code class="docutils literal notranslate"><span class="pre">True</span></code>/<code class="docutils literal notranslate"><span class="pre">False</span></code> value indicating whether the item’s
  1124. children should be displayed or hidden.</p></td>
  1125. </tr>
  1126. <tr class="row-even"><td><p>tags</p></td>
  1127. <td><p>A list of tags associated with this item.</p></td>
  1128. </tr>
  1129. </tbody>
  1130. </table>
  1131. </section>
  1132. <section id="tag-options">
  1133. <h3>Tag Options<a class="headerlink" href="#tag-options" title="Link to this heading">¶</a></h3>
  1134. <p>The following options may be specified on tags:</p>
  1135. <table class="docutils align-default">
  1136. <thead>
  1137. <tr class="row-odd"><th class="head"><p>Option</p></th>
  1138. <th class="head"><p>Description</p></th>
  1139. </tr>
  1140. </thead>
  1141. <tbody>
  1142. <tr class="row-even"><td><p>foreground</p></td>
  1143. <td><p>Specifies the text foreground color.</p></td>
  1144. </tr>
  1145. <tr class="row-odd"><td><p>background</p></td>
  1146. <td><p>Specifies the cell or item background color.</p></td>
  1147. </tr>
  1148. <tr class="row-even"><td><p>font</p></td>
  1149. <td><p>Specifies the font to use when drawing text.</p></td>
  1150. </tr>
  1151. <tr class="row-odd"><td><p>image</p></td>
  1152. <td><p>Specifies the item image, in case the item’s image option
  1153. is empty.</p></td>
  1154. </tr>
  1155. </tbody>
  1156. </table>
  1157. </section>
  1158. <section id="column-identifiers">
  1159. <h3>Column Identifiers<a class="headerlink" href="#column-identifiers" title="Link to this heading">¶</a></h3>
  1160. <p>Column identifiers take any of the following forms:</p>
  1161. <ul class="simple">
  1162. <li><p>A symbolic name from the list of columns option.</p></li>
  1163. <li><p>An integer n, specifying the nth data column.</p></li>
  1164. <li><p>A string of the form #n, where n is an integer, specifying the nth display
  1165. column.</p></li>
  1166. </ul>
  1167. <p>Notes:</p>
  1168. <ul class="simple">
  1169. <li><p>Item’s option values may be displayed in a different order than the order
  1170. in which they are stored.</p></li>
  1171. <li><p>Column #0 always refers to the tree column, even if show=”tree” is not
  1172. specified.</p></li>
  1173. </ul>
  1174. <p>A data column number is an index into an item’s option values list; a display
  1175. column number is the column number in the tree where the values are displayed.
  1176. Tree labels are displayed in column #0. If option displaycolumns is not set,
  1177. then data column n is displayed in column #n+1. Again, <strong>column #0 always
  1178. refers to the tree column</strong>.</p>
  1179. </section>
  1180. <section id="id8">
  1181. <h3>Virtual Events<a class="headerlink" href="#id8" title="Link to this heading">¶</a></h3>
  1182. <p>The Treeview widget generates the following virtual events.</p>
  1183. <table class="docutils align-default">
  1184. <thead>
  1185. <tr class="row-odd"><th class="head"><p>Event</p></th>
  1186. <th class="head"><p>Description</p></th>
  1187. </tr>
  1188. </thead>
  1189. <tbody>
  1190. <tr class="row-even"><td><p>&lt;&lt;TreeviewSelect&gt;&gt;</p></td>
  1191. <td><p>Generated whenever the selection changes.</p></td>
  1192. </tr>
  1193. <tr class="row-odd"><td><p>&lt;&lt;TreeviewOpen&gt;&gt;</p></td>
  1194. <td><p>Generated just before settings the focus item to
  1195. open=True.</p></td>
  1196. </tr>
  1197. <tr class="row-even"><td><p>&lt;&lt;TreeviewClose&gt;&gt;</p></td>
  1198. <td><p>Generated just after setting the focus item to
  1199. open=False.</p></td>
  1200. </tr>
  1201. </tbody>
  1202. </table>
  1203. <p>The <a class="reference internal" href="#tkinter.ttk.Treeview.focus" title="tkinter.ttk.Treeview.focus"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Treeview.focus()</span></code></a> and <a class="reference internal" href="#tkinter.ttk.Treeview.selection" title="tkinter.ttk.Treeview.selection"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Treeview.selection()</span></code></a> methods can be used
  1204. to determine the affected item or items.</p>
  1205. </section>
  1206. <section id="ttk-treeview">
  1207. <h3>ttk.Treeview<a class="headerlink" href="#ttk-treeview" title="Link to this heading">¶</a></h3>
  1208. <dl class="py class">
  1209. <dt class="sig sig-object py" id="tkinter.ttk.Treeview">
  1210. <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.ttk.</span></span><span class="sig-name descname"><span class="pre">Treeview</span></span><a class="headerlink" href="#tkinter.ttk.Treeview" title="Link to this definition">¶</a></dt>
  1211. <dd><dl class="py method">
  1212. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.bbox">
  1213. <span class="sig-name descname"><span class="pre">bbox</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">column</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.bbox" title="Link to this definition">¶</a></dt>
  1214. <dd><p>Returns the bounding box (relative to the treeview widget’s window) of
  1215. the specified <em>item</em> in the form (x, y, width, height).</p>
  1216. <p>If <em>column</em> is specified, returns the bounding box of that cell. If the
  1217. <em>item</em> is not visible (i.e., if it is a descendant of a closed item or is
  1218. scrolled offscreen), returns an empty string.</p>
  1219. </dd></dl>
  1220. <dl class="py method">
  1221. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.get_children">
  1222. <span class="sig-name descname"><span class="pre">get_children</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.get_children" title="Link to this definition">¶</a></dt>
  1223. <dd><p>Returns the list of children belonging to <em>item</em>.</p>
  1224. <p>If <em>item</em> is not specified, returns root children.</p>
  1225. </dd></dl>
  1226. <dl class="py method">
  1227. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.set_children">
  1228. <span class="sig-name descname"><span class="pre">set_children</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">newchildren</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.set_children" title="Link to this definition">¶</a></dt>
  1229. <dd><p>Replaces <em>item</em>’s child with <em>newchildren</em>.</p>
  1230. <p>Children present in <em>item</em> that are not present in <em>newchildren</em> are
  1231. detached from the tree. No items in <em>newchildren</em> may be an ancestor of
  1232. <em>item</em>. Note that not specifying <em>newchildren</em> results in detaching
  1233. <em>item</em>’s children.</p>
  1234. </dd></dl>
  1235. <dl class="py method">
  1236. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.column">
  1237. <span class="sig-name descname"><span class="pre">column</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">column</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">option</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.column" title="Link to this definition">¶</a></dt>
  1238. <dd><p>Query or modify the options for the specified <em>column</em>.</p>
  1239. <p>If <em>kw</em> is not given, returns a dict of the column option values. If
  1240. <em>option</em> is specified then the value for that <em>option</em> is returned.
  1241. Otherwise, sets the options to the corresponding values.</p>
  1242. <p>The valid options/values are:</p>
  1243. <dl class="simple">
  1244. <dt><em>id</em></dt><dd><p>Returns the column name. This is a read-only option.</p>
  1245. </dd>
  1246. <dt><em>anchor</em>: One of the standard Tk anchor values.</dt><dd><p>Specifies how the text in this column should be aligned with respect
  1247. to the cell.</p>
  1248. </dd>
  1249. <dt><em>minwidth</em>: width</dt><dd><p>The minimum width of the column in pixels. The treeview widget will
  1250. not make the column any smaller than specified by this option when
  1251. the widget is resized or the user drags a column.</p>
  1252. </dd>
  1253. <dt><em>stretch</em>: <code class="docutils literal notranslate"><span class="pre">True</span></code>/<code class="docutils literal notranslate"><span class="pre">False</span></code></dt><dd><p>Specifies whether the column’s width should be adjusted when
  1254. the widget is resized.</p>
  1255. </dd>
  1256. <dt><em>width</em>: width</dt><dd><p>The width of the column in pixels.</p>
  1257. </dd>
  1258. </dl>
  1259. <p>To configure the tree column, call this with column = “#0”</p>
  1260. </dd></dl>
  1261. <dl class="py method">
  1262. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.delete">
  1263. <span class="sig-name descname"><span class="pre">delete</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">items</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.delete" title="Link to this definition">¶</a></dt>
  1264. <dd><p>Delete all specified <em>items</em> and all their descendants.</p>
  1265. <p>The root item may not be deleted.</p>
  1266. </dd></dl>
  1267. <dl class="py method">
  1268. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.detach">
  1269. <span class="sig-name descname"><span class="pre">detach</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">items</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.detach" title="Link to this definition">¶</a></dt>
  1270. <dd><p>Unlinks all of the specified <em>items</em> from the tree.</p>
  1271. <p>The items and all of their descendants are still present, and may be
  1272. reinserted at another point in the tree, but will not be displayed.</p>
  1273. <p>The root item may not be detached.</p>
  1274. </dd></dl>
  1275. <dl class="py method">
  1276. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.exists">
  1277. <span class="sig-name descname"><span class="pre">exists</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.exists" title="Link to this definition">¶</a></dt>
  1278. <dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if the specified <em>item</em> is present in the tree.</p>
  1279. </dd></dl>
  1280. <dl class="py method">
  1281. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.focus">
  1282. <span class="sig-name descname"><span class="pre">focus</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.focus" title="Link to this definition">¶</a></dt>
  1283. <dd><p>If <em>item</em> is specified, sets the focus item to <em>item</em>. Otherwise, returns
  1284. the current focus item, or ‘’ if there is none.</p>
  1285. </dd></dl>
  1286. <dl class="py method">
  1287. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.heading">
  1288. <span class="sig-name descname"><span class="pre">heading</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">column</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">option</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.heading" title="Link to this definition">¶</a></dt>
  1289. <dd><p>Query or modify the heading options for the specified <em>column</em>.</p>
  1290. <p>If <em>kw</em> is not given, returns a dict of the heading option values. If
  1291. <em>option</em> is specified then the value for that <em>option</em> is returned.
  1292. Otherwise, sets the options to the corresponding values.</p>
  1293. <p>The valid options/values are:</p>
  1294. <dl class="simple">
  1295. <dt><em>text</em>: text</dt><dd><p>The text to display in the column heading.</p>
  1296. </dd>
  1297. <dt><em>image</em>: imageName</dt><dd><p>Specifies an image to display to the right of the column heading.</p>
  1298. </dd>
  1299. <dt><em>anchor</em>: anchor</dt><dd><p>Specifies how the heading text should be aligned. One of the standard
  1300. Tk anchor values.</p>
  1301. </dd>
  1302. <dt><em>command</em>: callback</dt><dd><p>A callback to be invoked when the heading label is pressed.</p>
  1303. </dd>
  1304. </dl>
  1305. <p>To configure the tree column heading, call this with column = “#0”.</p>
  1306. </dd></dl>
  1307. <dl class="py method">
  1308. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.identify">
  1309. <span class="sig-name descname"><span class="pre">identify</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">component</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.identify" title="Link to this definition">¶</a></dt>
  1310. <dd><p>Returns a description of the specified <em>component</em> under the point given
  1311. by <em>x</em> and <em>y</em>, or the empty string if no such <em>component</em> is present at
  1312. that position.</p>
  1313. </dd></dl>
  1314. <dl class="py method">
  1315. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.identify_row">
  1316. <span class="sig-name descname"><span class="pre">identify_row</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">y</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.identify_row" title="Link to this definition">¶</a></dt>
  1317. <dd><p>Returns the item ID of the item at position <em>y</em>.</p>
  1318. </dd></dl>
  1319. <dl class="py method">
  1320. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.identify_column">
  1321. <span class="sig-name descname"><span class="pre">identify_column</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.identify_column" title="Link to this definition">¶</a></dt>
  1322. <dd><p>Returns the data column identifier of the cell at position <em>x</em>.</p>
  1323. <p>The tree column has ID #0.</p>
  1324. </dd></dl>
  1325. <dl class="py method">
  1326. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.identify_region">
  1327. <span class="sig-name descname"><span class="pre">identify_region</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.identify_region" title="Link to this definition">¶</a></dt>
  1328. <dd><p>Returns one of:</p>
  1329. <table class="docutils align-default">
  1330. <thead>
  1331. <tr class="row-odd"><th class="head"><p>region</p></th>
  1332. <th class="head"><p>meaning</p></th>
  1333. </tr>
  1334. </thead>
  1335. <tbody>
  1336. <tr class="row-even"><td><p>heading</p></td>
  1337. <td><p>Tree heading area.</p></td>
  1338. </tr>
  1339. <tr class="row-odd"><td><p>separator</p></td>
  1340. <td><p>Space between two columns headings.</p></td>
  1341. </tr>
  1342. <tr class="row-even"><td><p>tree</p></td>
  1343. <td><p>The tree area.</p></td>
  1344. </tr>
  1345. <tr class="row-odd"><td><p>cell</p></td>
  1346. <td><p>A data cell.</p></td>
  1347. </tr>
  1348. </tbody>
  1349. </table>
  1350. <p>Availability: Tk 8.6.</p>
  1351. </dd></dl>
  1352. <dl class="py method">
  1353. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.identify_element">
  1354. <span class="sig-name descname"><span class="pre">identify_element</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.identify_element" title="Link to this definition">¶</a></dt>
  1355. <dd><p>Returns the element at position <em>x</em>, <em>y</em>.</p>
  1356. <p>Availability: Tk 8.6.</p>
  1357. </dd></dl>
  1358. <dl class="py method">
  1359. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.index">
  1360. <span class="sig-name descname"><span class="pre">index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.index" title="Link to this definition">¶</a></dt>
  1361. <dd><p>Returns the integer index of <em>item</em> within its parent’s list of children.</p>
  1362. </dd></dl>
  1363. <dl class="py method">
  1364. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.insert">
  1365. <span class="sig-name descname"><span class="pre">insert</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parent</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">iid</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.insert" title="Link to this definition">¶</a></dt>
  1366. <dd><p>Creates a new item and returns the item identifier of the newly created
  1367. item.</p>
  1368. <p><em>parent</em> is the item ID of the parent item, or the empty string to create
  1369. a new top-level item. <em>index</em> is an integer, or the value “end”,
  1370. specifying where in the list of parent’s children to insert the new item.
  1371. If <em>index</em> is less than or equal to zero, the new node is inserted at
  1372. the beginning; if <em>index</em> is greater than or equal to the current number
  1373. of children, it is inserted at the end. If <em>iid</em> is specified, it is used
  1374. as the item identifier; <em>iid</em> must not already exist in the tree.
  1375. Otherwise, a new unique identifier is generated.</p>
  1376. <p>See <a class="reference internal" href="#item-options">Item Options</a> for the list of available options.</p>
  1377. </dd></dl>
  1378. <dl class="py method">
  1379. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.item">
  1380. <span class="sig-name descname"><span class="pre">item</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">option</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.item" title="Link to this definition">¶</a></dt>
  1381. <dd><p>Query or modify the options for the specified <em>item</em>.</p>
  1382. <p>If no options are given, a dict with options/values for the item is
  1383. returned.
  1384. If <em>option</em> is specified then the value for that option is returned.
  1385. Otherwise, sets the options to the corresponding values as given by <em>kw</em>.</p>
  1386. </dd></dl>
  1387. <dl class="py method">
  1388. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.move">
  1389. <span class="sig-name descname"><span class="pre">move</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parent</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.move" title="Link to this definition">¶</a></dt>
  1390. <dd><p>Moves <em>item</em> to position <em>index</em> in <em>parent</em>’s list of children.</p>
  1391. <p>It is illegal to move an item under one of its descendants. If <em>index</em> is
  1392. less than or equal to zero, <em>item</em> is moved to the beginning; if greater
  1393. than or equal to the number of children, it is moved to the end. If <em>item</em>
  1394. was detached it is reattached.</p>
  1395. </dd></dl>
  1396. <dl class="py method">
  1397. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.next">
  1398. <span class="sig-name descname"><span class="pre">next</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.next" title="Link to this definition">¶</a></dt>
  1399. <dd><p>Returns the identifier of <em>item</em>’s next sibling, or ‘’ if <em>item</em> is the
  1400. last child of its parent.</p>
  1401. </dd></dl>
  1402. <dl class="py method">
  1403. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.parent">
  1404. <span class="sig-name descname"><span class="pre">parent</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.parent" title="Link to this definition">¶</a></dt>
  1405. <dd><p>Returns the ID of the parent of <em>item</em>, or ‘’ if <em>item</em> is at the top
  1406. level of the hierarchy.</p>
  1407. </dd></dl>
  1408. <dl class="py method">
  1409. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.prev">
  1410. <span class="sig-name descname"><span class="pre">prev</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.prev" title="Link to this definition">¶</a></dt>
  1411. <dd><p>Returns the identifier of <em>item</em>’s previous sibling, or ‘’ if <em>item</em> is
  1412. the first child of its parent.</p>
  1413. </dd></dl>
  1414. <dl class="py method">
  1415. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.reattach">
  1416. <span class="sig-name descname"><span class="pre">reattach</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parent</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.reattach" title="Link to this definition">¶</a></dt>
  1417. <dd><p>An alias for <a class="reference internal" href="#tkinter.ttk.Treeview.move" title="tkinter.ttk.Treeview.move"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Treeview.move()</span></code></a>.</p>
  1418. </dd></dl>
  1419. <dl class="py method">
  1420. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.see">
  1421. <span class="sig-name descname"><span class="pre">see</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.see" title="Link to this definition">¶</a></dt>
  1422. <dd><p>Ensure that <em>item</em> is visible.</p>
  1423. <p>Sets all of <em>item</em>’s ancestors open option to <code class="docutils literal notranslate"><span class="pre">True</span></code>, and scrolls the
  1424. widget if necessary so that <em>item</em> is within the visible portion of
  1425. the tree.</p>
  1426. </dd></dl>
  1427. <dl class="py method">
  1428. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.selection">
  1429. <span class="sig-name descname"><span class="pre">selection</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.selection" title="Link to this definition">¶</a></dt>
  1430. <dd><p>Returns a tuple of selected items.</p>
  1431. <div class="versionchanged">
  1432. <p><span class="versionmodified changed">Changed in version 3.8: </span><code class="docutils literal notranslate"><span class="pre">selection()</span></code> no longer takes arguments. For changing the selection
  1433. state use the following selection methods.</p>
  1434. </div>
  1435. </dd></dl>
  1436. <dl class="py method">
  1437. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.selection_set">
  1438. <span class="sig-name descname"><span class="pre">selection_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">items</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.selection_set" title="Link to this definition">¶</a></dt>
  1439. <dd><p><em>items</em> becomes the new selection.</p>
  1440. <div class="versionchanged">
  1441. <p><span class="versionmodified changed">Changed in version 3.6: </span><em>items</em> can be passed as separate arguments, not just as a single tuple.</p>
  1442. </div>
  1443. </dd></dl>
  1444. <dl class="py method">
  1445. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.selection_add">
  1446. <span class="sig-name descname"><span class="pre">selection_add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">items</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.selection_add" title="Link to this definition">¶</a></dt>
  1447. <dd><p>Add <em>items</em> to the selection.</p>
  1448. <div class="versionchanged">
  1449. <p><span class="versionmodified changed">Changed in version 3.6: </span><em>items</em> can be passed as separate arguments, not just as a single tuple.</p>
  1450. </div>
  1451. </dd></dl>
  1452. <dl class="py method">
  1453. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.selection_remove">
  1454. <span class="sig-name descname"><span class="pre">selection_remove</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">items</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.selection_remove" title="Link to this definition">¶</a></dt>
  1455. <dd><p>Remove <em>items</em> from the selection.</p>
  1456. <div class="versionchanged">
  1457. <p><span class="versionmodified changed">Changed in version 3.6: </span><em>items</em> can be passed as separate arguments, not just as a single tuple.</p>
  1458. </div>
  1459. </dd></dl>
  1460. <dl class="py method">
  1461. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.selection_toggle">
  1462. <span class="sig-name descname"><span class="pre">selection_toggle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">items</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.selection_toggle" title="Link to this definition">¶</a></dt>
  1463. <dd><p>Toggle the selection state of each item in <em>items</em>.</p>
  1464. <div class="versionchanged">
  1465. <p><span class="versionmodified changed">Changed in version 3.6: </span><em>items</em> can be passed as separate arguments, not just as a single tuple.</p>
  1466. </div>
  1467. </dd></dl>
  1468. <dl class="py method">
  1469. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.set">
  1470. <span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">column</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.set" title="Link to this definition">¶</a></dt>
  1471. <dd><p>With one argument, returns a dictionary of column/value pairs for the
  1472. specified <em>item</em>. With two arguments, returns the current value of the
  1473. specified <em>column</em>. With three arguments, sets the value of given
  1474. <em>column</em> in given <em>item</em> to the specified <em>value</em>.</p>
  1475. </dd></dl>
  1476. <dl class="py method">
  1477. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.tag_bind">
  1478. <span class="sig-name descname"><span class="pre">tag_bind</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sequence</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">callback</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.tag_bind" title="Link to this definition">¶</a></dt>
  1479. <dd><p>Bind a callback for the given event <em>sequence</em> to the tag <em>tagname</em>.
  1480. When an event is delivered to an item, the callbacks for each of the
  1481. item’s tags option are called.</p>
  1482. </dd></dl>
  1483. <dl class="py method">
  1484. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.tag_configure">
  1485. <span class="sig-name descname"><span class="pre">tag_configure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">option</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.tag_configure" title="Link to this definition">¶</a></dt>
  1486. <dd><p>Query or modify the options for the specified <em>tagname</em>.</p>
  1487. <p>If <em>kw</em> is not given, returns a dict of the option settings for
  1488. <em>tagname</em>. If <em>option</em> is specified, returns the value for that <em>option</em>
  1489. for the specified <em>tagname</em>. Otherwise, sets the options to the
  1490. corresponding values for the given <em>tagname</em>.</p>
  1491. </dd></dl>
  1492. <dl class="py method">
  1493. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.tag_has">
  1494. <span class="sig-name descname"><span class="pre">tag_has</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">item</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.tag_has" title="Link to this definition">¶</a></dt>
  1495. <dd><p>If <em>item</em> is specified, returns 1 or 0 depending on whether the specified
  1496. <em>item</em> has the given <em>tagname</em>. Otherwise, returns a list of all items
  1497. that have the specified tag.</p>
  1498. <p>Availability: Tk 8.6</p>
  1499. </dd></dl>
  1500. <dl class="py method">
  1501. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.xview">
  1502. <span class="sig-name descname"><span class="pre">xview</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.xview" title="Link to this definition">¶</a></dt>
  1503. <dd><p>Query or modify horizontal position of the treeview.</p>
  1504. </dd></dl>
  1505. <dl class="py method">
  1506. <dt class="sig sig-object py" id="tkinter.ttk.Treeview.yview">
  1507. <span class="sig-name descname"><span class="pre">yview</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Treeview.yview" title="Link to this definition">¶</a></dt>
  1508. <dd><p>Query or modify vertical position of the treeview.</p>
  1509. </dd></dl>
  1510. </dd></dl>
  1511. </section>
  1512. </section>
  1513. <section id="ttk-styling">
  1514. <span id="ttkstyling"></span><h2>Ttk Styling<a class="headerlink" href="#ttk-styling" title="Link to this heading">¶</a></h2>
  1515. <p>Each widget in <code class="xref py py-mod docutils literal notranslate"><span class="pre">ttk</span></code> is assigned a style, which specifies the set of
  1516. elements making up the widget and how they are arranged, along with dynamic
  1517. and default settings for element options. By default the style name is the
  1518. same as the widget’s class name, but it may be overridden by the widget’s style
  1519. option. If you don’t know the class name of a widget, use the method
  1520. <code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.winfo_class()</span></code> (somewidget.winfo_class()).</p>
  1521. <div class="admonition seealso">
  1522. <p class="admonition-title">See also</p>
  1523. <dl class="simple">
  1524. <dt><a class="reference external" href="https://tktable.sourceforge.net/tile/tile-tcl2004.pdf">Tcl’2004 conference presentation</a></dt><dd><p>This document explains how the theme engine works</p>
  1525. </dd>
  1526. </dl>
  1527. </div>
  1528. <dl class="py class">
  1529. <dt class="sig sig-object py" id="tkinter.ttk.Style">
  1530. <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.ttk.</span></span><span class="sig-name descname"><span class="pre">Style</span></span><a class="headerlink" href="#tkinter.ttk.Style" title="Link to this definition">¶</a></dt>
  1531. <dd><p>This class is used to manipulate the style database.</p>
  1532. <dl class="py method">
  1533. <dt class="sig sig-object py" id="tkinter.ttk.Style.configure">
  1534. <span class="sig-name descname"><span class="pre">configure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">style</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">query_opt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Style.configure" title="Link to this definition">¶</a></dt>
  1535. <dd><p>Query or set the default value of the specified option(s) in <em>style</em>.</p>
  1536. <p>Each key in <em>kw</em> is an option and each value is a string identifying
  1537. the value for that option.</p>
  1538. <p>For example, to change every default button to be a flat button with
  1539. some padding and a different background color:</p>
  1540. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">tkinter</span> <span class="kn">import</span> <span class="n">ttk</span>
  1541. <span class="kn">import</span> <span class="nn">tkinter</span>
  1542. <span class="n">root</span> <span class="o">=</span> <span class="n">tkinter</span><span class="o">.</span><span class="n">Tk</span><span class="p">()</span>
  1543. <span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">()</span><span class="o">.</span><span class="n">configure</span><span class="p">(</span><span class="s2">&quot;TButton&quot;</span><span class="p">,</span> <span class="n">padding</span><span class="o">=</span><span class="mi">6</span><span class="p">,</span> <span class="n">relief</span><span class="o">=</span><span class="s2">&quot;flat&quot;</span><span class="p">,</span>
  1544. <span class="n">background</span><span class="o">=</span><span class="s2">&quot;#ccc&quot;</span><span class="p">)</span>
  1545. <span class="n">btn</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Button</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s2">&quot;Sample&quot;</span><span class="p">)</span>
  1546. <span class="n">btn</span><span class="o">.</span><span class="n">pack</span><span class="p">()</span>
  1547. <span class="n">root</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span>
  1548. </pre></div>
  1549. </div>
  1550. </dd></dl>
  1551. <dl class="py method">
  1552. <dt class="sig sig-object py" id="tkinter.ttk.Style.map">
  1553. <span class="sig-name descname"><span class="pre">map</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">style</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">query_opt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Style.map" title="Link to this definition">¶</a></dt>
  1554. <dd><p>Query or sets dynamic values of the specified option(s) in <em>style</em>.</p>
  1555. <p>Each key in <em>kw</em> is an option and each value should be a list or a
  1556. tuple (usually) containing statespecs grouped in tuples, lists, or
  1557. some other preference. A statespec is a compound of one
  1558. or more states and then a value.</p>
  1559. <p>An example may make it more understandable:</p>
  1560. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">tkinter</span>
  1561. <span class="kn">from</span> <span class="nn">tkinter</span> <span class="kn">import</span> <span class="n">ttk</span>
  1562. <span class="n">root</span> <span class="o">=</span> <span class="n">tkinter</span><span class="o">.</span><span class="n">Tk</span><span class="p">()</span>
  1563. <span class="n">style</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">()</span>
  1564. <span class="n">style</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="s2">&quot;C.TButton&quot;</span><span class="p">,</span>
  1565. <span class="n">foreground</span><span class="o">=</span><span class="p">[(</span><span class="s1">&#39;pressed&#39;</span><span class="p">,</span> <span class="s1">&#39;red&#39;</span><span class="p">),</span> <span class="p">(</span><span class="s1">&#39;active&#39;</span><span class="p">,</span> <span class="s1">&#39;blue&#39;</span><span class="p">)],</span>
  1566. <span class="n">background</span><span class="o">=</span><span class="p">[(</span><span class="s1">&#39;pressed&#39;</span><span class="p">,</span> <span class="s1">&#39;!disabled&#39;</span><span class="p">,</span> <span class="s1">&#39;black&#39;</span><span class="p">),</span> <span class="p">(</span><span class="s1">&#39;active&#39;</span><span class="p">,</span> <span class="s1">&#39;white&#39;</span><span class="p">)]</span>
  1567. <span class="p">)</span>
  1568. <span class="n">colored_btn</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Button</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s2">&quot;Test&quot;</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="s2">&quot;C.TButton&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">pack</span><span class="p">()</span>
  1569. <span class="n">root</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span>
  1570. </pre></div>
  1571. </div>
  1572. <p>Note that the order of the (states, value) sequences for an option does
  1573. matter, if the order is changed to <code class="docutils literal notranslate"><span class="pre">[('active',</span> <span class="pre">'blue'),</span> <span class="pre">('pressed',</span>
  1574. <span class="pre">'red')]</span></code> in the foreground option, for example, the result would be a
  1575. blue foreground when the widget were in active or pressed states.</p>
  1576. </dd></dl>
  1577. <dl class="py method">
  1578. <dt class="sig sig-object py" id="tkinter.ttk.Style.lookup">
  1579. <span class="sig-name descname"><span class="pre">lookup</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">style</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">option</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">state</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Style.lookup" title="Link to this definition">¶</a></dt>
  1580. <dd><p>Returns the value specified for <em>option</em> in <em>style</em>.</p>
  1581. <p>If <em>state</em> is specified, it is expected to be a sequence of one or more
  1582. states. If the <em>default</em> argument is set, it is used as a fallback value
  1583. in case no specification for option is found.</p>
  1584. <p>To check what font a Button uses by default:</p>
  1585. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">tkinter</span> <span class="kn">import</span> <span class="n">ttk</span>
  1586. <span class="nb">print</span><span class="p">(</span><span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">()</span><span class="o">.</span><span class="n">lookup</span><span class="p">(</span><span class="s2">&quot;TButton&quot;</span><span class="p">,</span> <span class="s2">&quot;font&quot;</span><span class="p">))</span>
  1587. </pre></div>
  1588. </div>
  1589. </dd></dl>
  1590. <dl class="py method">
  1591. <dt class="sig sig-object py" id="tkinter.ttk.Style.layout">
  1592. <span class="sig-name descname"><span class="pre">layout</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">style</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layoutspec</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Style.layout" title="Link to this definition">¶</a></dt>
  1593. <dd><p>Define the widget layout for given <em>style</em>. If <em>layoutspec</em> is omitted,
  1594. return the layout specification for given style.</p>
  1595. <p><em>layoutspec</em>, if specified, is expected to be a list or some other
  1596. sequence type (excluding strings), where each item should be a tuple and
  1597. the first item is the layout name and the second item should have the
  1598. format described in <a class="reference internal" href="#layouts">Layouts</a>.</p>
  1599. <p>To understand the format, see the following example (it is not
  1600. intended to do anything useful):</p>
  1601. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">tkinter</span> <span class="kn">import</span> <span class="n">ttk</span>
  1602. <span class="kn">import</span> <span class="nn">tkinter</span>
  1603. <span class="n">root</span> <span class="o">=</span> <span class="n">tkinter</span><span class="o">.</span><span class="n">Tk</span><span class="p">()</span>
  1604. <span class="n">style</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">()</span>
  1605. <span class="n">style</span><span class="o">.</span><span class="n">layout</span><span class="p">(</span><span class="s2">&quot;TMenubutton&quot;</span><span class="p">,</span> <span class="p">[</span>
  1606. <span class="p">(</span><span class="s2">&quot;Menubutton.background&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">),</span>
  1607. <span class="p">(</span><span class="s2">&quot;Menubutton.button&quot;</span><span class="p">,</span> <span class="p">{</span><span class="s2">&quot;children&quot;</span><span class="p">:</span>
  1608. <span class="p">[(</span><span class="s2">&quot;Menubutton.focus&quot;</span><span class="p">,</span> <span class="p">{</span><span class="s2">&quot;children&quot;</span><span class="p">:</span>
  1609. <span class="p">[(</span><span class="s2">&quot;Menubutton.padding&quot;</span><span class="p">,</span> <span class="p">{</span><span class="s2">&quot;children&quot;</span><span class="p">:</span>
  1610. <span class="p">[(</span><span class="s2">&quot;Menubutton.label&quot;</span><span class="p">,</span> <span class="p">{</span><span class="s2">&quot;side&quot;</span><span class="p">:</span> <span class="s2">&quot;left&quot;</span><span class="p">,</span> <span class="s2">&quot;expand&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">})]</span>
  1611. <span class="p">})]</span>
  1612. <span class="p">})]</span>
  1613. <span class="p">}),</span>
  1614. <span class="p">])</span>
  1615. <span class="n">mbtn</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Menubutton</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s1">&#39;Text&#39;</span><span class="p">)</span>
  1616. <span class="n">mbtn</span><span class="o">.</span><span class="n">pack</span><span class="p">()</span>
  1617. <span class="n">root</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span>
  1618. </pre></div>
  1619. </div>
  1620. </dd></dl>
  1621. <dl class="py method">
  1622. <dt class="sig sig-object py" id="tkinter.ttk.Style.element_create">
  1623. <span class="sig-name descname"><span class="pre">element_create</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">elementname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">etype</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Style.element_create" title="Link to this definition">¶</a></dt>
  1624. <dd><p>Create a new element in the current theme, of the given <em>etype</em> which is
  1625. expected to be either “image” or “from”.</p>
  1626. <p>If “image” is used, <em>args</em> should contain the default image name followed
  1627. by statespec/value pairs (this is the imagespec), and <em>kw</em> may have the
  1628. following options:</p>
  1629. <dl class="simple">
  1630. <dt>border=padding</dt><dd><p>padding is a list of up to four integers, specifying the left, top,
  1631. right, and bottom borders, respectively.</p>
  1632. </dd>
  1633. <dt>height=height</dt><dd><p>Specifies a minimum height for the element. If less than zero, the
  1634. base image’s height is used as a default.</p>
  1635. </dd>
  1636. <dt>padding=padding</dt><dd><p>Specifies the element’s interior padding. Defaults to border’s value
  1637. if not specified.</p>
  1638. </dd>
  1639. <dt>sticky=spec</dt><dd><p>Specifies how the image is placed within the final parcel. spec
  1640. contains zero or more characters “n”, “s”, “w”, or “e”.</p>
  1641. </dd>
  1642. <dt>width=width</dt><dd><p>Specifies a minimum width for the element. If less than zero, the
  1643. base image’s width is used as a default.</p>
  1644. </dd>
  1645. </dl>
  1646. <p>Example:</p>
  1647. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">img1</span> <span class="o">=</span> <span class="n">tkinter</span><span class="o">.</span><span class="n">PhotoImage</span><span class="p">(</span><span class="n">master</span><span class="o">=</span><span class="n">root</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="s1">&#39;button.png&#39;</span><span class="p">)</span>
  1648. <span class="n">img1</span> <span class="o">=</span> <span class="n">tkinter</span><span class="o">.</span><span class="n">PhotoImage</span><span class="p">(</span><span class="n">master</span><span class="o">=</span><span class="n">root</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="s1">&#39;button-pressed.png&#39;</span><span class="p">)</span>
  1649. <span class="n">img1</span> <span class="o">=</span> <span class="n">tkinter</span><span class="o">.</span><span class="n">PhotoImage</span><span class="p">(</span><span class="n">master</span><span class="o">=</span><span class="n">root</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="s1">&#39;button-active.png&#39;</span><span class="p">)</span>
  1650. <span class="n">style</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">(</span><span class="n">root</span><span class="p">)</span>
  1651. <span class="n">style</span><span class="o">.</span><span class="n">element_create</span><span class="p">(</span><span class="s1">&#39;Button.button&#39;</span><span class="p">,</span> <span class="s1">&#39;image&#39;</span><span class="p">,</span>
  1652. <span class="n">img1</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;pressed&#39;</span><span class="p">,</span> <span class="n">img2</span><span class="p">),</span> <span class="p">(</span><span class="s1">&#39;active&#39;</span><span class="p">,</span> <span class="n">img3</span><span class="p">),</span>
  1653. <span class="n">border</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span> <span class="n">sticky</span><span class="o">=</span><span class="s1">&#39;we&#39;</span><span class="p">)</span>
  1654. </pre></div>
  1655. </div>
  1656. <p>If “from” is used as the value of <em>etype</em>,
  1657. <a class="reference internal" href="#tkinter.ttk.Style.element_create" title="tkinter.ttk.Style.element_create"><code class="xref py py-meth docutils literal notranslate"><span class="pre">element_create()</span></code></a> will clone an existing
  1658. element. <em>args</em> is expected to contain a themename, from which
  1659. the element will be cloned, and optionally an element to clone from.
  1660. If this element to clone from is not specified, an empty element will
  1661. be used. <em>kw</em> is discarded.</p>
  1662. <p>Example:</p>
  1663. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">style</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">(</span><span class="n">root</span><span class="p">)</span>
  1664. <span class="n">style</span><span class="o">.</span><span class="n">element_create</span><span class="p">(</span><span class="s1">&#39;plain.background&#39;</span><span class="p">,</span> <span class="s1">&#39;from&#39;</span><span class="p">,</span> <span class="s1">&#39;default&#39;</span><span class="p">)</span>
  1665. </pre></div>
  1666. </div>
  1667. </dd></dl>
  1668. <dl class="py method">
  1669. <dt class="sig sig-object py" id="tkinter.ttk.Style.element_names">
  1670. <span class="sig-name descname"><span class="pre">element_names</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Style.element_names" title="Link to this definition">¶</a></dt>
  1671. <dd><p>Returns the list of elements defined in the current theme.</p>
  1672. </dd></dl>
  1673. <dl class="py method">
  1674. <dt class="sig sig-object py" id="tkinter.ttk.Style.element_options">
  1675. <span class="sig-name descname"><span class="pre">element_options</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">elementname</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Style.element_options" title="Link to this definition">¶</a></dt>
  1676. <dd><p>Returns the list of <em>elementname</em>’s options.</p>
  1677. </dd></dl>
  1678. <dl class="py method">
  1679. <dt class="sig sig-object py" id="tkinter.ttk.Style.theme_create">
  1680. <span class="sig-name descname"><span class="pre">theme_create</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">themename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parent</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">settings</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Style.theme_create" title="Link to this definition">¶</a></dt>
  1681. <dd><p>Create a new theme.</p>
  1682. <p>It is an error if <em>themename</em> already exists. If <em>parent</em> is specified,
  1683. the new theme will inherit styles, elements and layouts from the parent
  1684. theme. If <em>settings</em> are present they are expected to have the same
  1685. syntax used for <a class="reference internal" href="#tkinter.ttk.Style.theme_settings" title="tkinter.ttk.Style.theme_settings"><code class="xref py py-meth docutils literal notranslate"><span class="pre">theme_settings()</span></code></a>.</p>
  1686. </dd></dl>
  1687. <dl class="py method">
  1688. <dt class="sig sig-object py" id="tkinter.ttk.Style.theme_settings">
  1689. <span class="sig-name descname"><span class="pre">theme_settings</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">themename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">settings</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Style.theme_settings" title="Link to this definition">¶</a></dt>
  1690. <dd><p>Temporarily sets the current theme to <em>themename</em>, apply specified
  1691. <em>settings</em> and then restore the previous theme.</p>
  1692. <p>Each key in <em>settings</em> is a style and each value may contain the keys
  1693. ‘configure’, ‘map’, ‘layout’ and ‘element create’ and they are expected
  1694. to have the same format as specified by the methods
  1695. <a class="reference internal" href="#tkinter.ttk.Style.configure" title="tkinter.ttk.Style.configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Style.configure()</span></code></a>, <a class="reference internal" href="#tkinter.ttk.Style.map" title="tkinter.ttk.Style.map"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Style.map()</span></code></a>, <a class="reference internal" href="#tkinter.ttk.Style.layout" title="tkinter.ttk.Style.layout"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Style.layout()</span></code></a> and
  1696. <a class="reference internal" href="#tkinter.ttk.Style.element_create" title="tkinter.ttk.Style.element_create"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Style.element_create()</span></code></a> respectively.</p>
  1697. <p>As an example, let’s change the Combobox for the default theme a bit:</p>
  1698. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">tkinter</span> <span class="kn">import</span> <span class="n">ttk</span>
  1699. <span class="kn">import</span> <span class="nn">tkinter</span>
  1700. <span class="n">root</span> <span class="o">=</span> <span class="n">tkinter</span><span class="o">.</span><span class="n">Tk</span><span class="p">()</span>
  1701. <span class="n">style</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">()</span>
  1702. <span class="n">style</span><span class="o">.</span><span class="n">theme_settings</span><span class="p">(</span><span class="s2">&quot;default&quot;</span><span class="p">,</span> <span class="p">{</span>
  1703. <span class="s2">&quot;TCombobox&quot;</span><span class="p">:</span> <span class="p">{</span>
  1704. <span class="s2">&quot;configure&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;padding&quot;</span><span class="p">:</span> <span class="mi">5</span><span class="p">},</span>
  1705. <span class="s2">&quot;map&quot;</span><span class="p">:</span> <span class="p">{</span>
  1706. <span class="s2">&quot;background&quot;</span><span class="p">:</span> <span class="p">[(</span><span class="s2">&quot;active&quot;</span><span class="p">,</span> <span class="s2">&quot;green2&quot;</span><span class="p">),</span>
  1707. <span class="p">(</span><span class="s2">&quot;!disabled&quot;</span><span class="p">,</span> <span class="s2">&quot;green4&quot;</span><span class="p">)],</span>
  1708. <span class="s2">&quot;fieldbackground&quot;</span><span class="p">:</span> <span class="p">[(</span><span class="s2">&quot;!disabled&quot;</span><span class="p">,</span> <span class="s2">&quot;green3&quot;</span><span class="p">)],</span>
  1709. <span class="s2">&quot;foreground&quot;</span><span class="p">:</span> <span class="p">[(</span><span class="s2">&quot;focus&quot;</span><span class="p">,</span> <span class="s2">&quot;OliveDrab1&quot;</span><span class="p">),</span>
  1710. <span class="p">(</span><span class="s2">&quot;!disabled&quot;</span><span class="p">,</span> <span class="s2">&quot;OliveDrab2&quot;</span><span class="p">)]</span>
  1711. <span class="p">}</span>
  1712. <span class="p">}</span>
  1713. <span class="p">})</span>
  1714. <span class="n">combo</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Combobox</span><span class="p">()</span><span class="o">.</span><span class="n">pack</span><span class="p">()</span>
  1715. <span class="n">root</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span>
  1716. </pre></div>
  1717. </div>
  1718. </dd></dl>
  1719. <dl class="py method">
  1720. <dt class="sig sig-object py" id="tkinter.ttk.Style.theme_names">
  1721. <span class="sig-name descname"><span class="pre">theme_names</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Style.theme_names" title="Link to this definition">¶</a></dt>
  1722. <dd><p>Returns a list of all known themes.</p>
  1723. </dd></dl>
  1724. <dl class="py method">
  1725. <dt class="sig sig-object py" id="tkinter.ttk.Style.theme_use">
  1726. <span class="sig-name descname"><span class="pre">theme_use</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">themename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.ttk.Style.theme_use" title="Link to this definition">¶</a></dt>
  1727. <dd><p>If <em>themename</em> is not given, returns the theme in use. Otherwise, sets
  1728. the current theme to <em>themename</em>, refreshes all widgets and emits a
  1729. &lt;&lt;ThemeChanged&gt;&gt; event.</p>
  1730. </dd></dl>
  1731. </dd></dl>
  1732. <section id="layouts">
  1733. <h3>Layouts<a class="headerlink" href="#layouts" title="Link to this heading">¶</a></h3>
  1734. <p>A layout can be just <code class="docutils literal notranslate"><span class="pre">None</span></code>, if it takes no options, or a dict of
  1735. options specifying how to arrange the element. The layout mechanism
  1736. uses a simplified version of the pack geometry manager: given an
  1737. initial cavity, each element is allocated a parcel.</p>
  1738. <p>The valid options/values are:</p>
  1739. <dl class="simple">
  1740. <dt><em>side</em>: whichside</dt><dd><p>Specifies which side of the cavity to place the element; one of
  1741. top, right, bottom or left. If omitted, the element occupies the
  1742. entire cavity.</p>
  1743. </dd>
  1744. <dt><em>sticky</em>: nswe</dt><dd><p>Specifies where the element is placed inside its allocated parcel.</p>
  1745. </dd>
  1746. <dt><em>unit</em>: 0 or 1</dt><dd><p>If set to 1, causes the element and all of its descendants to be treated as
  1747. a single element for the purposes of <a class="reference internal" href="#tkinter.ttk.Widget.identify" title="tkinter.ttk.Widget.identify"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Widget.identify()</span></code></a> et al. It’s
  1748. used for things like scrollbar thumbs with grips.</p>
  1749. </dd>
  1750. <dt><em>children</em>: [sublayout… ]</dt><dd><p>Specifies a list of elements to place inside the element. Each
  1751. element is a tuple (or other sequence type) where the first item is
  1752. the layout name, and the other is a <a class="reference internal" href="#layouts">Layout</a>.</p>
  1753. </dd>
  1754. </dl>
  1755. </section>
  1756. </section>
  1757. </section>
  1758. <div class="clearer"></div>
  1759. </div>
  1760. </div>
  1761. </div>
  1762. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  1763. <div class="sphinxsidebarwrapper">
  1764. <div>
  1765. <h3><a href="../contents.html">Table of Contents</a></h3>
  1766. <ul>
  1767. <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.ttk</span></code> — Tk themed widgets</a><ul>
  1768. <li><a class="reference internal" href="#using-ttk">Using Ttk</a></li>
  1769. <li><a class="reference internal" href="#ttk-widgets">Ttk Widgets</a></li>
  1770. <li><a class="reference internal" href="#widget">Widget</a><ul>
  1771. <li><a class="reference internal" href="#standard-options">Standard Options</a></li>
  1772. <li><a class="reference internal" href="#scrollable-widget-options">Scrollable Widget Options</a></li>
  1773. <li><a class="reference internal" href="#label-options">Label Options</a></li>
  1774. <li><a class="reference internal" href="#compatibility-options">Compatibility Options</a></li>
  1775. <li><a class="reference internal" href="#widget-states">Widget States</a></li>
  1776. <li><a class="reference internal" href="#ttk-widget">ttk.Widget</a></li>
  1777. </ul>
  1778. </li>
  1779. <li><a class="reference internal" href="#combobox">Combobox</a><ul>
  1780. <li><a class="reference internal" href="#options">Options</a></li>
  1781. <li><a class="reference internal" href="#virtual-events">Virtual events</a></li>
  1782. <li><a class="reference internal" href="#ttk-combobox">ttk.Combobox</a></li>
  1783. </ul>
  1784. </li>
  1785. <li><a class="reference internal" href="#spinbox">Spinbox</a><ul>
  1786. <li><a class="reference internal" href="#id1">Options</a></li>
  1787. <li><a class="reference internal" href="#id2">Virtual events</a></li>
  1788. <li><a class="reference internal" href="#ttk-spinbox">ttk.Spinbox</a></li>
  1789. </ul>
  1790. </li>
  1791. <li><a class="reference internal" href="#notebook">Notebook</a><ul>
  1792. <li><a class="reference internal" href="#id3">Options</a></li>
  1793. <li><a class="reference internal" href="#tab-options">Tab Options</a></li>
  1794. <li><a class="reference internal" href="#tab-identifiers">Tab Identifiers</a></li>
  1795. <li><a class="reference internal" href="#id4">Virtual Events</a></li>
  1796. <li><a class="reference internal" href="#ttk-notebook">ttk.Notebook</a></li>
  1797. </ul>
  1798. </li>
  1799. <li><a class="reference internal" href="#progressbar">Progressbar</a><ul>
  1800. <li><a class="reference internal" href="#id5">Options</a></li>
  1801. <li><a class="reference internal" href="#ttk-progressbar">ttk.Progressbar</a></li>
  1802. </ul>
  1803. </li>
  1804. <li><a class="reference internal" href="#separator">Separator</a><ul>
  1805. <li><a class="reference internal" href="#id6">Options</a></li>
  1806. </ul>
  1807. </li>
  1808. <li><a class="reference internal" href="#sizegrip">Sizegrip</a><ul>
  1809. <li><a class="reference internal" href="#platform-specific-notes">Platform-specific notes</a></li>
  1810. <li><a class="reference internal" href="#bugs">Bugs</a></li>
  1811. </ul>
  1812. </li>
  1813. <li><a class="reference internal" href="#treeview">Treeview</a><ul>
  1814. <li><a class="reference internal" href="#id7">Options</a></li>
  1815. <li><a class="reference internal" href="#item-options">Item Options</a></li>
  1816. <li><a class="reference internal" href="#tag-options">Tag Options</a></li>
  1817. <li><a class="reference internal" href="#column-identifiers">Column Identifiers</a></li>
  1818. <li><a class="reference internal" href="#id8">Virtual Events</a></li>
  1819. <li><a class="reference internal" href="#ttk-treeview">ttk.Treeview</a></li>
  1820. </ul>
  1821. </li>
  1822. <li><a class="reference internal" href="#ttk-styling">Ttk Styling</a><ul>
  1823. <li><a class="reference internal" href="#layouts">Layouts</a></li>
  1824. </ul>
  1825. </li>
  1826. </ul>
  1827. </li>
  1828. </ul>
  1829. </div>
  1830. <div>
  1831. <h4>Previous topic</h4>
  1832. <p class="topless"><a href="tkinter.dnd.html"
  1833. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.dnd</span></code> — Drag and drop support</a></p>
  1834. </div>
  1835. <div>
  1836. <h4>Next topic</h4>
  1837. <p class="topless"><a href="tkinter.tix.html"
  1838. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.tix</span></code> — Extension widgets for Tk</a></p>
  1839. </div>
  1840. <div role="note" aria-label="source link">
  1841. <h3>This Page</h3>
  1842. <ul class="this-page-menu">
  1843. <li><a href="../bugs.html">Report a Bug</a></li>
  1844. <li>
  1845. <a href="https://github.com/python/cpython/blob/main/Doc/library/tkinter.ttk.rst"
  1846. rel="nofollow">Show Source
  1847. </a>
  1848. </li>
  1849. </ul>
  1850. </div>
  1851. </div>
  1852. <div id="sidebarbutton" title="Collapse sidebar">
  1853. <span>«</span>
  1854. </div>
  1855. </div>
  1856. <div class="clearer"></div>
  1857. </div>
  1858. <div class="related" role="navigation" aria-label="related navigation">
  1859. <h3>Navigation</h3>
  1860. <ul>
  1861. <li class="right" style="margin-right: 10px">
  1862. <a href="../genindex.html" title="General Index"
  1863. >index</a></li>
  1864. <li class="right" >
  1865. <a href="../py-modindex.html" title="Python Module Index"
  1866. >modules</a> |</li>
  1867. <li class="right" >
  1868. <a href="tkinter.tix.html" title="tkinter.tix — Extension widgets for Tk"
  1869. >next</a> |</li>
  1870. <li class="right" >
  1871. <a href="tkinter.dnd.html" title="tkinter.dnd — Drag and drop support"
  1872. >previous</a> |</li>
  1873. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  1874. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  1875. <li class="switchers">
  1876. <div class="language_switcher_placeholder"></div>
  1877. <div class="version_switcher_placeholder"></div>
  1878. </li>
  1879. <li>
  1880. </li>
  1881. <li id="cpython-language-and-version">
  1882. <a href="../index.html">3.12.3 Documentation</a> &#187;
  1883. </li>
  1884. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  1885. <li class="nav-item nav-item-2"><a href="tk.html" >Graphical User Interfaces with Tk</a> &#187;</li>
  1886. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.ttk</span></code> — Tk themed widgets</a></li>
  1887. <li class="right">
  1888. <div class="inline-search" role="search">
  1889. <form class="inline-search" action="../search.html" method="get">
  1890. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  1891. <input type="submit" value="Go" />
  1892. </form>
  1893. </div>
  1894. |
  1895. </li>
  1896. <li class="right">
  1897. <label class="theme-selector-label">
  1898. Theme
  1899. <select class="theme-selector" oninput="activateTheme(this.value)">
  1900. <option value="auto" selected>Auto</option>
  1901. <option value="light">Light</option>
  1902. <option value="dark">Dark</option>
  1903. </select>
  1904. </label> |</li>
  1905. </ul>
  1906. </div>
  1907. <div class="footer">
  1908. &copy;
  1909. <a href="../copyright.html">
  1910. Copyright
  1911. </a>
  1912. 2001-2024, Python Software Foundation.
  1913. <br />
  1914. This page is licensed under the Python Software Foundation License Version 2.
  1915. <br />
  1916. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  1917. <br />
  1918. See <a href="/license.html">History and License</a> for more information.<br />
  1919. <br />
  1920. The Python Software Foundation is a non-profit corporation.
  1921. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  1922. <br />
  1923. <br />
  1924. Last updated on Apr 09, 2024 (13:47 UTC).
  1925. <a href="/bugs.html">Found a bug</a>?
  1926. <br />
  1927. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  1928. </div>
  1929. </body>
  1930. </html>
上海开阖软件有限公司 沪ICP备12045867号-1