| Server IP : 121.121.20.254 / Your IP : 216.73.216.145 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Python315/Doc/html/library/ |
Upload File : |
<!DOCTYPE html>
<html lang="en" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:title" content="tkinter — Python interface to Tcl/Tk" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://docs.python.org/3/library/tkinter.html" />
<meta property="og:site_name" content="Python documentation" />
<meta property="og:description" content="Source code: Lib/tkinter/__init__.py The tkinter package (“Tk interface”) is the standard Python interface to the Tcl/Tk GUI toolkit. Both Tk and tkinter are available on most Unix platforms, inclu..." />
<meta property="og:image" content="_static/og-image.png" />
<meta property="og:image:alt" content="Python documentation" />
<meta name="description" content="Source code: Lib/tkinter/__init__.py The tkinter package (“Tk interface”) is the standard Python interface to the Tcl/Tk GUI toolkit. Both Tk and tkinter are available on most Unix platforms, inclu..." />
<meta name="theme-color" content="#3776ab">
<meta property="og:image:width" content="200">
<meta property="og:image:height" content="200">
<title>tkinter — Python interface to Tcl/Tk — Python 3.15.0rc1 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />
<link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=4365c8fe" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=0fc419ee" />
<script src="../_static/documentation_options.js?v=791e38b1"></script>
<script src="../_static/doctools.js?v=9bcbadda"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Python 3.15.0rc1 documentation"
href="../_static/opensearch.xml"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="next" title="tkinter.colorchooser — Color choosing dialog" href="tkinter.colorchooser.html" />
<link rel="prev" title="Graphical user interfaces with Tk" href="tk.html" />
<link rel="canonical" href="https://docs.python.org/3/library/tkinter.html">
<style>
@media only screen {
table.full-width-table {
width: 100%;
}
}
</style>
<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
<link rel="shortcut icon" type="image/png" href="../_static/py.svg">
<script type="text/javascript" src="../_static/copybutton.js"></script>
<script type="text/javascript" src="../_static/menu.js"></script>
<script type="text/javascript" src="../_static/search-focus.js"></script>
<script type="text/javascript" src="../_static/themetoggle.js"></script>
<script type="text/javascript" src="../_static/rtd_switcher.js"></script>
<meta name="readthedocs-addons-api-version" content="1">
</head>
<body>
<div class="mobile-nav">
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">
<nav class="nav-content" role="navigation">
<label for="menuToggler" class="toggler__label">
<span></span>
</label>
<span class="nav-items-wrapper">
<a href="https://www.python.org/" class="nav-logo">
<img src="../_static/py.svg" alt="Python logo">
</a>
<span class="version_switcher_placeholder"></span>
<form role="search" class="search" action="../search.html" method="get">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
<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>
</svg>
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q">
<input type="submit" value="Go">
</form>
</span>
</nav>
<div class="menu-wrapper">
<nav class="menu" role="navigation" aria-label="main navigation">
<div class="language_switcher_placeholder"></div>
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label>
<div>
<h3><a href="../contents.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> — Python interface to Tcl/Tk</a><ul>
<li><a class="reference internal" href="#architecture">Architecture</a></li>
<li><a class="reference internal" href="#tkinter-modules">Tkinter modules</a></li>
<li><a class="reference internal" href="#tkinter-life-preserver">Tkinter life preserver</a><ul>
<li><a class="reference internal" href="#a-hello-world-program">A Hello World program</a></li>
<li><a class="reference internal" href="#important-tk-concepts">Important Tk concepts</a></li>
<li><a class="reference internal" href="#understanding-how-tkinter-wraps-tcl-tk">Understanding how Tkinter wraps Tcl/Tk</a></li>
<li><a class="reference internal" href="#how-do-i-what-option-does">How do I…? What option does…?</a></li>
<li><a class="reference internal" href="#navigating-the-tcl-tk-reference-manual">Navigating the Tcl/Tk reference manual</a></li>
</ul>
</li>
<li><a class="reference internal" href="#threading-model">Threading model</a></li>
<li><a class="reference internal" href="#handy-reference">Handy reference</a><ul>
<li><a class="reference internal" href="#setting-options">Setting options</a></li>
<li><a class="reference internal" href="#geometry-management">Geometry management</a></li>
<li><a class="reference internal" href="#coupling-widget-variables">Coupling widget variables</a></li>
<li><a class="reference internal" href="#the-window-manager">The window manager</a></li>
<li><a class="reference internal" href="#tk-option-data-types">Tk option data types</a></li>
<li><a class="reference internal" href="#bindings-and-events">Bindings and events</a></li>
<li><a class="reference internal" href="#the-index-parameter">The index parameter</a></li>
<li><a class="reference internal" href="#images">Images</a></li>
</ul>
</li>
<li><a class="reference internal" href="#reference">Reference</a><ul>
<li><a class="reference internal" href="#base-and-mixin-classes">Base and mixin classes</a></li>
<li><a class="reference internal" href="#toplevel-widgets">Toplevel widgets</a></li>
<li><a class="reference internal" href="#widget-classes">Widget classes</a></li>
<li><a class="reference internal" href="#variable-classes">Variable classes</a></li>
<li><a class="reference internal" href="#image-classes">Image classes</a></li>
<li><a class="reference internal" href="#other-classes">Other classes</a></li>
<li><a class="reference internal" href="#module-level-functions">Module-level functions</a></li>
<li><a class="reference internal" href="#file-handlers">File handlers</a></li>
<li><a class="reference internal" href="#constants">Constants</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="tk.html"
title="previous chapter">Graphical user interfaces with Tk</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="tkinter.colorchooser.html"
title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.colorchooser</span></code> — Color choosing dialog</a></p>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const title = document.querySelector('meta[property="og:title"]').content;
const elements = document.querySelectorAll('.improvepage');
const pageurl = window.location.href.split('?')[0];
elements.forEach(element => {
const url = new URL(element.href.split('?')[0].replace("-nojs", ""));
url.searchParams.set('pagetitle', title);
url.searchParams.set('pageurl', pageurl);
url.searchParams.set('pagesource', "library/tkinter.rst");
element.href = url.toString();
});
});
</script>
<div role="note" aria-label="source link">
<h3>This page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a bug</a></li>
<li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>
<li>
<a href="https://github.com/python/cpython/blob/main/Doc/library/tkinter.rst?plain=1"
rel="nofollow">Show source
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="tkinter.colorchooser.html" title="tkinter.colorchooser — Color choosing dialog"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="tk.html" title="Graphical user interfaces with Tk"
accesskey="P">previous</a> |</li>
<li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>
<li><a href="https://www.python.org/">Python</a> »</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.15.0rc1 Documentation</a> »
</li>
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>
<li class="nav-item nav-item-2"><a href="tk.html" accesskey="U">Graphical user interfaces with Tk</a> »</li>
<li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> — Python interface to Tcl/Tk</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">
<input type="submit" value="Go">
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="module-tkinter">
<span id="tkinter-python-interface-to-tcl-tk"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> — Python interface to Tcl/Tk<a class="headerlink" href="#module-tkinter" title="Link to this heading">¶</a></h1>
<p><strong>Source code:</strong> <a class="extlink-source reference external" href="https://github.com/python/cpython/tree/3.15/Lib/tkinter/__init__.py">Lib/tkinter/__init__.py</a></p>
<hr class="docutils" />
<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> package (“Tk interface”) is the standard Python interface to
the Tcl/Tk GUI toolkit. Both Tk and <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> are available on most Unix
platforms, including macOS, as well as on Windows systems.</p>
<p>Running <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">tkinter</span></code> from the command line should open a window
demonstrating a simple Tk interface, letting you know that <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> is
properly installed on your system, and also showing what version of Tcl/Tk is
installed, so you can read the Tcl/Tk documentation specific to that version.</p>
<p>Tkinter supports a range of Tcl/Tk versions, built either with or without
thread support.
Tcl/Tk 8.5.12 is the minimum supported version; the official Python binary
release bundles Tcl/Tk 9.0.
See the source code for the <a class="reference internal" href="#module-_tkinter" title="_tkinter: A binary module that contains the low-level interface to Tcl/Tk."><code class="xref py py-mod docutils literal notranslate"><span class="pre">_tkinter</span></code></a> module for more information about
supported versions.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.11: </span>Support for Tcl/Tk versions older than 8.5.12 was removed.</p>
</div>
<p>Tkinter is not a thin wrapper, but adds a fair amount of its own logic to
make the experience more pythonic. This documentation will concentrate on these
additions and changes, and refer to the official Tcl/Tk documentation for
details that are unchanged.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Tcl/Tk 8.5 (2007) introduced a modern set of themed user interface components
along with a new API to use them (see <a class="reference internal" href="tkinter.ttk.html#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>).
Both old and new APIs are still available.
Most documentation you will find online still uses the old API and
can be woefully outdated.</p>
</div>
<p>This is an <a class="reference internal" href="../glossary.html#term-optional-module"><span class="xref std std-term">optional module</span></a>.
If it is missing from your copy of CPython,
look for documentation from your distributor (that is,
whoever provided Python to you).
If you are the distributor, see <a class="reference internal" href="../using/configure.html#optional-module-requirements"><span class="std std-ref">Requirements for optional modules</span></a>.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><dl class="simple">
<dt><a class="reference external" href="https://tkdocs.com/">TkDocs</a></dt><dd><p>Extensive tutorial on creating user interfaces with Tkinter. Explains key concepts,
and illustrates recommended approaches using the modern API.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference external" href="https://www.tkdocs.com/shipman/">Tkinter 8.5 reference: a GUI for Python</a></dt><dd><p>Reference documentation for Tkinter 8.5 detailing available classes, methods, and options.</p>
</dd>
</dl>
</li>
</ul>
<p>Tcl/Tk Resources:</p>
<ul class="simple">
<li><dl class="simple">
<dt><a class="reference external" href="https://www.tcl-lang.org/man/tcl9.0/TkCmd/index.html">Tk commands</a></dt><dd><p>Comprehensive reference to each of the underlying Tcl/Tk commands used by Tkinter.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference external" href="https://www.tcl.tk">Tcl/Tk Home Page</a></dt><dd><p>Additional documentation, and links to Tcl/Tk core development.</p>
</dd>
</dl>
</li>
</ul>
<p>Books:</p>
<ul class="simple">
<li><dl class="simple">
<dt><a class="reference external" href="https://tkdocs.com/book.html">Modern Tkinter for Busy Python Developers</a></dt><dd><p>By Mark Roseman. (ISBN 978-1999149567)</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference external" href="https://www.packtpub.com/en-us/product/python-gui-programming-with-tkinter-9781788835886">Python GUI programming with Tkinter</a></dt><dd><p>By Alan D. Moore. (ISBN 978-1788835886)</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference external" href="https://learning-python.com/about-pp4e.html">Programming Python</a></dt><dd><p>By Mark Lutz; has excellent coverage of Tkinter. (ISBN 978-0596158101)</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference external" href="https://www.amazon.com/exec/obidos/ASIN/032133633X">Tcl and the Tk Toolkit (2nd edition)</a></dt><dd><p>By John Ousterhout, inventor of Tcl/Tk, and Ken Jones; does not cover Tkinter. (ISBN 978-0321336330)</p>
</dd>
</dl>
</li>
</ul>
</div>
<section id="architecture">
<h2>Architecture<a class="headerlink" href="#architecture" title="Link to this heading">¶</a></h2>
<p>Tcl/Tk is not a single library but rather consists of a few distinct
modules, each with separate functionality and its own official
documentation. Python’s binary releases also ship an add-on module
together with it.</p>
<dl class="simple">
<dt>Tcl</dt><dd><p>Tcl is a dynamic interpreted programming language, just like Python. Though
it can be used on its own as a general-purpose programming language, it is
most commonly embedded into C applications as a scripting engine or an
interface to the Tk toolkit. The Tcl library has a C interface to
create and manage one or more instances of a Tcl interpreter, run Tcl
commands and scripts in those instances, and add custom commands
implemented in either Tcl or C. Each interpreter has an event queue,
and there are facilities to send events to it and process them.
Unlike Python, Tcl’s execution model is designed around cooperative
multitasking, and Tkinter bridges this difference
(see <a class="reference internal" href="#threading-model">Threading model</a> for details).</p>
</dd>
<dt>Tk</dt><dd><p>Tk is a <a class="reference external" href="https://wiki.tcl-lang.org/37432">Tcl package</a> implemented in C
that adds custom commands to create and manipulate GUI widgets. Each
<a class="reference internal" href="#tkinter.Tk" title="tkinter.Tk"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code></a> object embeds its own Tcl interpreter instance with Tk loaded into
it. Tk’s widgets are very customizable, though at the cost of a dated appearance.
Tk uses Tcl’s event queue to generate and process GUI events.</p>
</dd>
<dt>Ttk</dt><dd><p>Themed Tk (Ttk) is a newer family of Tk widgets that provide a much better
appearance on different platforms than many of the classic Tk widgets.
Ttk is distributed as part of Tk, starting with Tk version 8.5. Python
bindings are provided in a separate module, <a class="reference internal" href="tkinter.ttk.html#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>.</p>
</dd>
</dl>
<p>Internally, Tk and Ttk use facilities of the underlying operating system,
that is, Xlib on Unix/X11, Cocoa on macOS, GDI on Windows.</p>
<p>When your Python application uses a class in Tkinter, for example, to create a widget,
the <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> module first assembles a Tcl/Tk command string. It passes that
Tcl command string to an internal <a class="reference internal" href="#module-_tkinter" title="_tkinter: A binary module that contains the low-level interface to Tcl/Tk."><code class="xref py py-mod docutils literal notranslate"><span class="pre">_tkinter</span></code></a> binary module, which then
calls the Tcl interpreter to evaluate it. The Tcl interpreter will then call into the
Tk and/or Ttk packages, which will in turn make calls to Xlib, Cocoa, or GDI.</p>
</section>
<section id="tkinter-modules">
<h2>Tkinter modules<a class="headerlink" href="#tkinter-modules" title="Link to this heading">¶</a></h2>
<p>Support for Tkinter is spread across several modules. Most applications will need the
main <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> module, as well as the <a class="reference internal" href="tkinter.ttk.html#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, which provides
the modern themed widget set and API:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">tkinter</span><span class="w"> </span><span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">tkinter</span><span class="w"> </span><span class="kn">import</span> <span class="n">ttk</span>
</pre></div>
</div>
<p>The modules that provide Tk support include:</p>
<dl class="simple">
<dt><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code></dt><dd><p>Main Tkinter module.</p>
</dd>
<dt><a class="reference internal" href="tkinter.colorchooser.html#module-tkinter.colorchooser" title="tkinter.colorchooser: Color choosing dialog"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.colorchooser</span></code></a></dt><dd><p>Dialog to let the user choose a color.</p>
</dd>
<dt><a class="reference internal" href="dialog.html#module-tkinter.commondialog" title="tkinter.commondialog: Tkinter base class for dialogs"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.commondialog</span></code></a></dt><dd><p>Base class for the dialogs defined in the other modules listed here.</p>
</dd>
<dt><a class="reference internal" href="dialog.html#module-tkinter.filedialog" title="tkinter.filedialog: Dialog classes for file selection"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.filedialog</span></code></a></dt><dd><p>Common dialogs to allow the user to specify a file to open or save.</p>
</dd>
<dt><a class="reference internal" href="tkinter.font.html#module-tkinter.font" title="tkinter.font: Tkinter font-wrapping class"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.font</span></code></a></dt><dd><p>Utilities to help work with fonts.</p>
</dd>
<dt><a class="reference internal" href="tkinter.messagebox.html#module-tkinter.messagebox" title="tkinter.messagebox: Various types of alert dialogs"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.messagebox</span></code></a></dt><dd><p>Access to standard Tk dialog boxes.</p>
</dd>
<dt><a class="reference internal" href="tkinter.scrolledtext.html#module-tkinter.scrolledtext" title="tkinter.scrolledtext: Text widget with a vertical scroll bar."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.scrolledtext</span></code></a></dt><dd><p>Text widget with a vertical scroll bar built in.</p>
</dd>
<dt><a class="reference internal" href="dialog.html#module-tkinter.simpledialog" title="tkinter.simpledialog: Simple dialog windows"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.simpledialog</span></code></a></dt><dd><p>Basic dialogs and convenience functions.</p>
</dd>
<dt><a class="reference internal" href="tkinter.ttk.html#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></dt><dd><p>Themed widget set introduced in Tk 8.5, providing modern alternatives
for many of the classic widgets in the main <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> module.</p>
</dd>
</dl>
<p>Additional modules:</p>
<dl class="simple" id="module-_tkinter">
<dt><a class="reference internal" href="#module-_tkinter" title="_tkinter: A binary module that contains the low-level interface to Tcl/Tk."><code class="xref py py-mod docutils literal notranslate"><span class="pre">_tkinter</span></code></a></dt><dd><p>A binary module that contains the low-level interface to Tcl/Tk.
It is automatically imported by the main <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> module,
and should never be used directly by application programmers.
It is usually a shared library (or DLL), but might in some cases be
statically linked with the Python interpreter.</p>
</dd>
<dt><a class="reference internal" href="idle.html#module-idlelib" title="idlelib: Implementation package for the IDLE shell/editor."><code class="xref py py-mod docutils literal notranslate"><span class="pre">idlelib</span></code></a></dt><dd><p>Python’s Integrated Development and Learning Environment (IDLE). Based
on <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code>.</p>
</dd>
<dt><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.constants</span></code></dt><dd><p>Symbolic constants that can be used in place of strings when passing
various parameters to Tkinter calls. Automatically imported by the
main <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> module.</p>
</dd>
<dt><a class="reference internal" href="tkinter.dnd.html#module-tkinter.dnd" title="tkinter.dnd: Tkinter drag-and-drop interface"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.dnd</span></code></a></dt><dd><p>(experimental) Drag-and-drop support for <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code>. This will
become deprecated when it is replaced with the Tk DND.</p>
</dd>
<dt><a class="reference internal" href="turtle.html#module-turtle" title="turtle: An educational framework for simple graphics applications"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a></dt><dd><p>Turtle graphics in a Tk window.</p>
</dd>
</dl>
</section>
<section id="tkinter-life-preserver">
<h2>Tkinter life preserver<a class="headerlink" href="#tkinter-life-preserver" title="Link to this heading">¶</a></h2>
<p>This section is not designed to be an exhaustive tutorial on either Tk or
Tkinter. For that, refer to one of the external resources noted earlier.
Instead, this section provides a very quick orientation to what a Tkinter
application looks like, identifies foundational Tk concepts, and
explains how the Tkinter wrapper is structured.</p>
<p>The remainder of this section will help you to identify the classes,
methods, and options you’ll need in your Tkinter application, and where to
find more detailed documentation on them, including in the official Tcl/Tk
reference manual.</p>
<section id="a-hello-world-program">
<h3>A Hello World program<a class="headerlink" href="#a-hello-world-program" title="Link to this heading">¶</a></h3>
<p>We’ll start by walking through a “Hello World” application in Tkinter. This
isn’t the smallest one we could write, but has enough to illustrate some
key concepts you’ll need to know.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">tkinter</span><span class="w"> </span><span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">tkinter</span><span class="w"> </span><span class="kn">import</span> <span class="n">ttk</span>
<span class="n">root</span> <span class="o">=</span> <span class="n">Tk</span><span class="p">()</span>
<span class="n">frm</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Frame</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="n">padding</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
<span class="n">frm</span><span class="o">.</span><span class="n">grid</span><span class="p">()</span>
<span class="n">ttk</span><span class="o">.</span><span class="n">Label</span><span class="p">(</span><span class="n">frm</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="s2">"Hello World!"</span><span class="p">)</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">column</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">row</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="n">ttk</span><span class="o">.</span><span class="n">Button</span><span class="p">(</span><span class="n">frm</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="s2">"Quit"</span><span class="p">,</span> <span class="n">command</span><span class="o">=</span><span class="n">root</span><span class="o">.</span><span class="n">destroy</span><span class="p">)</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">column</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">row</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="n">root</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span>
</pre></div>
</div>
<p>After the imports, the next line creates an instance of the <a class="reference internal" href="#tkinter.Tk" title="tkinter.Tk"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code></a> class,
which initializes Tk and creates its associated Tcl interpreter. It also
creates a toplevel window, known as the root window, which serves as the main
window of the application.</p>
<p>The following line creates a frame widget, which in this case will contain
a label and a button we’ll create next. The frame is fit inside the root
window.</p>
<p>The next line creates a label widget holding a static text string.
The <a class="reference internal" href="#tkinter.Grid.grid" title="tkinter.Grid.grid"><code class="xref py py-meth docutils literal notranslate"><span class="pre">grid()</span></code></a> method is used to specify the relative layout (position)
of the label within its containing frame widget, similar to how tables in HTML
work.</p>
<p>A button widget is then created, and placed to the right of the label.
When pressed, it will call the <a class="reference internal" href="#tkinter.Misc.destroy" title="tkinter.Misc.destroy"><code class="xref py py-meth docutils literal notranslate"><span class="pre">destroy()</span></code></a> method of the root window.</p>
<p>Finally, the <a class="reference internal" href="#tkinter.mainloop" title="tkinter.mainloop"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mainloop()</span></code></a> method puts everything on the display, and
responds to user input until the program terminates.</p>
</section>
<section id="important-tk-concepts">
<h3>Important Tk concepts<a class="headerlink" href="#important-tk-concepts" title="Link to this heading">¶</a></h3>
<p>Even this simple program illustrates the following key Tk concepts:</p>
<dl class="simple">
<dt>widgets</dt><dd><p>A Tkinter user interface is made up of individual <em>widgets</em>. Each widget is
represented as a Python object, instantiated from classes like
<a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.Frame" title="tkinter.ttk.Frame"><code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Frame</span></code></a>, <a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.Label" title="tkinter.ttk.Label"><code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Label</span></code></a>, and <a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.Button" title="tkinter.ttk.Button"><code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Button</span></code></a>.</p>
</dd>
<dt>widget hierarchy</dt><dd><p>Widgets are arranged in a <em>hierarchy</em>. The label and button were contained
within a frame, which in turn was contained within the root window. When
creating each <em>child</em> widget, its <em>parent</em> widget is passed as the first
argument to the widget constructor.</p>
</dd>
<dt>configuration options</dt><dd><p>Widgets have <em>configuration options</em>, which modify their appearance and
behavior, such as the text to display in a label or button. Different
classes of widgets will have different sets of options.</p>
</dd>
<dt>geometry management</dt><dd><p>Widgets aren’t automatically added to the user interface when they are
created. A <em>geometry manager</em> like <code class="docutils literal notranslate"><span class="pre">grid</span></code> controls where in the
user interface they are placed.</p>
</dd>
<dt>event loop</dt><dd><p>Tkinter reacts to user input, changes from your program, and even refreshes
the display only when actively running an <em>event loop</em>. If your program
isn’t running the event loop, your user interface won’t update.</p>
</dd>
</dl>
</section>
<section id="understanding-how-tkinter-wraps-tcl-tk">
<h3>Understanding how Tkinter wraps Tcl/Tk<a class="headerlink" href="#understanding-how-tkinter-wraps-tcl-tk" title="Link to this heading">¶</a></h3>
<p>When your application uses Tkinter’s classes and methods, internally Tkinter
is assembling strings representing Tcl/Tk commands, and executing those
commands in the Tcl interpreter attached to your application’s <a class="reference internal" href="#tkinter.Tk" title="tkinter.Tk"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code></a>
instance.</p>
<p>Whether it’s trying to navigate reference documentation, trying to find
the right method or option, adapting some existing code, or debugging your
Tkinter application, there are times that it will be useful to understand
what those underlying Tcl/Tk commands look like.</p>
<p>To illustrate, here is the Tcl/Tk equivalent of the main part of the Tkinter
script above.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">ttk</span><span class="p">::</span><span class="n">frame</span> <span class="o">.</span><span class="n">frm</span> <span class="o">-</span><span class="n">padding</span> <span class="mi">10</span>
<span class="n">grid</span> <span class="o">.</span><span class="n">frm</span>
<span class="n">grid</span> <span class="p">[</span><span class="n">ttk</span><span class="p">::</span><span class="n">label</span> <span class="o">.</span><span class="n">frm</span><span class="o">.</span><span class="n">lbl</span> <span class="o">-</span><span class="n">text</span> <span class="s2">"Hello World!"</span><span class="p">]</span> <span class="o">-</span><span class="n">column</span> <span class="mi">0</span> <span class="o">-</span><span class="n">row</span> <span class="mi">0</span>
<span class="n">grid</span> <span class="p">[</span><span class="n">ttk</span><span class="p">::</span><span class="n">button</span> <span class="o">.</span><span class="n">frm</span><span class="o">.</span><span class="n">btn</span> <span class="o">-</span><span class="n">text</span> <span class="s2">"Quit"</span> <span class="o">-</span><span class="n">command</span> <span class="s2">"destroy ."</span><span class="p">]</span> <span class="o">-</span><span class="n">column</span> <span class="mi">1</span> <span class="o">-</span><span class="n">row</span> <span class="mi">0</span>
</pre></div>
</div>
<p>Tcl’s syntax is similar to many shell languages, where the first word is the
command to be executed, with arguments to that command following it, separated
by spaces. Without getting into too many details, notice the following:</p>
<ul class="simple">
<li><p>The commands used to create widgets (like <code class="docutils literal notranslate"><span class="pre">ttk::frame</span></code>) correspond to
widget classes in Tkinter.</p></li>
<li><p>Tcl widget options (like <code class="docutils literal notranslate"><span class="pre">-text</span></code>) correspond to keyword arguments in
Tkinter.</p></li>
<li><p>Widgets are referred to by a <em>pathname</em> in Tcl (like <code class="docutils literal notranslate"><span class="pre">.frm.btn</span></code>),
whereas Tkinter doesn’t use names but object references.</p></li>
<li><p>A widget’s place in the widget hierarchy is encoded in its (hierarchical)
pathname, which uses a <code class="docutils literal notranslate"><span class="pre">.</span></code> (dot) as a path separator. The pathname for
the root window is just <code class="docutils literal notranslate"><span class="pre">.</span></code> (dot). In Tkinter, the hierarchy is defined
not by pathname but by specifying the parent widget when creating each
child widget.</p></li>
<li><p>Operations which are implemented as separate <em>commands</em> in Tcl (like
<code class="docutils literal notranslate"><span class="pre">grid</span></code> or <code class="docutils literal notranslate"><span class="pre">destroy</span></code>) are represented as <em>methods</em> on Tkinter widget
objects. As you’ll see shortly, at other times Tcl uses what appear to be
method calls on widget objects, which more closely mirror what is
used in Tkinter.</p></li>
</ul>
</section>
<section id="how-do-i-what-option-does">
<h3>How do I…? What option does…?<a class="headerlink" href="#how-do-i-what-option-does" title="Link to this heading">¶</a></h3>
<p>If you’re not sure how to do something in Tkinter, and you can’t immediately
find it in the tutorial or reference documentation you’re using, there are a
few strategies that can be helpful.</p>
<p>First, remember that the details of how individual widgets work may vary
across different versions of both Tkinter and Tcl/Tk. If you’re searching
documentation, make sure it corresponds to the Python and Tcl/Tk versions
installed on your system.</p>
<p>When searching for how to use an API, it helps to know the exact name of the
class, option, or method that you’re using. Introspection, either in an
interactive Python shell or with <a class="reference internal" href="functions.html#print" title="print"><code class="xref py py-func docutils literal notranslate"><span class="pre">print()</span></code></a>, can help you identify what
you need.</p>
<p>To find out what configuration options are available on any widget, call its
<a class="reference internal" href="#tkinter.Misc.configure" title="tkinter.Misc.configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code></a> method, which returns a dictionary containing a variety
of information about each object, including its default and current values.
Use <a class="reference internal" href="#tkinter.Misc.keys" title="tkinter.Misc.keys"><code class="xref py py-meth docutils literal notranslate"><span class="pre">keys()</span></code></a> to get just the names of each option.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><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">frm</span><span class="p">,</span> <span class="o">...</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">btn</span><span class="o">.</span><span class="n">configure</span><span class="p">()</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
</pre></div>
</div>
<p>As most widgets have many configuration options in common, it can be useful
to find out which are specific to a particular widget class. Comparing the
list of options to that of a simpler widget, like a frame, is one way to
do that.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">btn</span><span class="o">.</span><span class="n">configure</span><span class="p">()</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">frm</span><span class="o">.</span><span class="n">configure</span><span class="p">()</span><span class="o">.</span><span class="n">keys</span><span class="p">()))</span>
</pre></div>
</div>
<p>Similarly, you can find the available methods for a widget object using the
standard <a class="reference internal" href="functions.html#dir" title="dir"><code class="xref py py-func docutils literal notranslate"><span class="pre">dir()</span></code></a> function. If you try it, you’ll see there are over 200
common widget methods, so again identifying those specific to a widget class
is helpful.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="nb">dir</span><span class="p">(</span><span class="n">btn</span><span class="p">))</span>
<span class="nb">print</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="nb">dir</span><span class="p">(</span><span class="n">btn</span><span class="p">))</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="nb">dir</span><span class="p">(</span><span class="n">frm</span><span class="p">)))</span>
</pre></div>
</div>
</section>
<section id="navigating-the-tcl-tk-reference-manual">
<h3>Navigating the Tcl/Tk reference manual<a class="headerlink" href="#navigating-the-tcl-tk-reference-manual" title="Link to this heading">¶</a></h3>
<p>As noted, the official
<a class="reference external" href="https://www.tcl-lang.org/man/tcl9.0/TkCmd/index.html">Tk commands</a> reference
manual (man pages) is often the most accurate description of what specific
operations on widgets do.
Even when you know the name of the option or method that you need, you may
still have a few places to look.</p>
<p>While all operations in Tkinter are implemented as method calls on widget
objects, you’ve seen that many Tcl/Tk operations appear as commands that
take a widget pathname as its first parameter, followed by optional
parameters, for example</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">destroy</span> <span class="o">.</span>
<span class="n">grid</span> <span class="o">.</span><span class="n">frm</span><span class="o">.</span><span class="n">btn</span> <span class="o">-</span><span class="n">column</span> <span class="mi">0</span> <span class="o">-</span><span class="n">row</span> <span class="mi">0</span>
</pre></div>
</div>
<p>Others, however, look more like methods called on a widget object (in fact,
when you create a widget in Tcl/Tk, it creates a Tcl command with the name
of the widget pathname, with the first parameter to that command being the
name of a method to call).</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="o">.</span><span class="n">frm</span><span class="o">.</span><span class="n">btn</span> <span class="n">invoke</span>
<span class="o">.</span><span class="n">frm</span><span class="o">.</span><span class="n">lbl</span> <span class="n">configure</span> <span class="o">-</span><span class="n">text</span> <span class="s2">"Goodbye"</span>
</pre></div>
</div>
<p>In the official Tcl/Tk reference documentation, you’ll find most operations
that look like method calls on the man page for a specific widget (for example,
you’ll find the <a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.Button.invoke" title="tkinter.ttk.Button.invoke"><code class="xref py py-meth docutils literal notranslate"><span class="pre">invoke()</span></code></a> method on the
<a class="reference external" href="https://www.tcl-lang.org/man/tcl9.0/TkCmd/ttk_button.html">ttk::button</a>
man page), while functions that take a widget as a parameter often have
their own man page (for example,
<a class="reference external" href="https://www.tcl-lang.org/man/tcl9.0/TkCmd/grid.html">grid</a>).</p>
<p>You’ll find many common options and methods in the
<a class="reference external" href="https://www.tcl-lang.org/man/tcl9.0/TkCmd/options.html">options</a> or
<a class="reference external" href="https://www.tcl-lang.org/man/tcl9.0/TkCmd/ttk_widget.html">ttk::widget</a> man
pages, while others are found in the man page for a specific widget class.</p>
<p>You’ll also find that many Tkinter methods have compound names, for example,
<a class="reference internal" href="#tkinter.Misc.winfo_x" title="tkinter.Misc.winfo_x"><code class="xref py py-meth docutils literal notranslate"><span class="pre">winfo_x()</span></code></a>, <a class="reference internal" href="#tkinter.Misc.winfo_height" title="tkinter.Misc.winfo_height"><code class="xref py py-meth docutils literal notranslate"><span class="pre">winfo_height()</span></code></a>,
<a class="reference internal" href="#tkinter.Misc.winfo_viewable" title="tkinter.Misc.winfo_viewable"><code class="xref py py-meth docutils literal notranslate"><span class="pre">winfo_viewable()</span></code></a>.
You’d find documentation for all of these in the
<a class="reference external" href="https://www.tcl-lang.org/man/tcl9.0/TkCmd/winfo.html">winfo</a> man page.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Somewhat confusingly, there are also methods on all Tkinter widgets
that don’t actually operate on the widget, but operate at a global
scope, independent of any widget. Examples are methods for accessing
the clipboard or the system bell. (They happen to be implemented as
methods in the base <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a> class that all Tkinter widgets
inherit from).</p>
</div>
</section>
</section>
<section id="threading-model">
<h2>Threading model<a class="headerlink" href="#threading-model" title="Link to this heading">¶</a></h2>
<p>Python and Tcl/Tk have very different threading models, which <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code>
tries to bridge. If you use threads, you may need to be aware of this.</p>
<p>A Python interpreter may have many threads associated with it. In Tcl, multiple
threads can be created, but each thread has a separate Tcl interpreter instance
associated with it. Threads can also create more than one interpreter instance,
though each interpreter instance can be used only by the one thread that created it.</p>
<p>Each <a class="reference internal" href="#tkinter.Tk" title="tkinter.Tk"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code></a> object created by <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> contains a Tcl interpreter.
It also keeps track of which thread created that interpreter. Calls to
<code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> can be made from any Python thread. Internally, if a call comes
from a thread other than the one that created the <code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code> object, an event
is posted to the interpreter’s event queue, and when executed, the result is
returned to the calling Python thread.</p>
<p>Tcl/Tk applications are normally event-driven, meaning that after
initialization, the interpreter runs an event loop (that is,
<a class="reference internal" href="#tkinter.Misc.mainloop" title="tkinter.Misc.mainloop"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Tk.mainloop</span></code></a>) and responds to events.
Because it is single-threaded, event handlers must respond quickly, otherwise
they will block other events from being processed.
To avoid this, any long-running computations should not run in an event
handler, but are either broken into smaller pieces using timers, or run in
another thread.
This is different from many GUI toolkits where the GUI runs in a completely
separate thread from all application code including event handlers.</p>
<p>If the Tcl interpreter is not running the event loop and processing events, any
<code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> calls made from threads other than the one running the Tcl
interpreter will fail.</p>
<p>A number of special cases exist:</p>
<ul class="simple">
<li><p>Tcl/Tk libraries built without thread support are now rare: Tcl/Tk 9.0 (the
bundled version) is always thread-aware, so this case only arises with some
older 8.x builds. When the library is not thread-aware,
<code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> calls the library from the originating Python thread, even
if this is different than the thread that created the Tcl interpreter. A global
lock ensures only one call occurs at a time.</p></li>
<li><p>While <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> allows you to create more than one instance of a <a class="reference internal" href="#tkinter.Tk" title="tkinter.Tk"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code></a>
object (with its own interpreter), all interpreters that are part of the same
thread share a common event queue, which gets ugly fast. In practice, don’t create
more than one instance of <code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code> at a time. Otherwise, it’s best to create
them in separate threads and ensure you’re running a thread-aware Tcl/Tk build.</p></li>
<li><p>Blocking event handlers are not the only way to prevent the Tcl interpreter from
reentering the event loop. It is even possible to run multiple nested event loops
or abandon the event loop entirely. If you’re doing anything tricky when it comes
to events or threads, be aware of these possibilities.</p></li>
<li><p>There are a few select <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> functions that presently work only when
called from the thread that created the Tcl interpreter.</p></li>
</ul>
</section>
<section id="handy-reference">
<h2>Handy reference<a class="headerlink" href="#handy-reference" title="Link to this heading">¶</a></h2>
<section id="setting-options">
<span id="tkinter-setting-options"></span><h3>Setting options<a class="headerlink" href="#setting-options" title="Link to this heading">¶</a></h3>
<p>Options control things like the color and border width of a widget. Options can
be set in three ways:</p>
<dl>
<dt>At object creation time, using keyword arguments</dt><dd><div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">fred</span> <span class="o">=</span> <span class="n">Button</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fg</span><span class="o">=</span><span class="s2">"red"</span><span class="p">,</span> <span class="n">bg</span><span class="o">=</span><span class="s2">"blue"</span><span class="p">)</span>
</pre></div>
</div>
</dd>
<dt>After object creation, treating the option name like a dictionary index</dt><dd><div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">fred</span><span class="p">[</span><span class="s2">"fg"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"red"</span>
<span class="n">fred</span><span class="p">[</span><span class="s2">"bg"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"blue"</span>
</pre></div>
</div>
</dd>
<dt>Use the config() method to update multiple attrs subsequent to object creation</dt><dd><div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">fred</span><span class="o">.</span><span class="n">config</span><span class="p">(</span><span class="n">fg</span><span class="o">=</span><span class="s2">"red"</span><span class="p">,</span> <span class="n">bg</span><span class="o">=</span><span class="s2">"blue"</span><span class="p">)</span>
</pre></div>
</div>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The <code class="docutils literal notranslate"><span class="pre">fg</span></code> and <code class="docutils literal notranslate"><span class="pre">bg</span></code> options used here,
and other options that control a widget’s appearance,
belong to the classic <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> widgets.
The themed <a class="reference internal" href="tkinter.ttk.html#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 recommended in the introduction
do not accept them;
style a themed widget through the <a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.Style" title="tkinter.ttk.Style"><code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Style</span></code></a>
class instead.
The three ways of setting an option shown above apply to both widget sets.</p>
</div>
<p>For a complete explanation of a given option and its behavior, see the Tk man
pages for the widget in question.</p>
<p>Note that the man pages list “STANDARD OPTIONS” and “WIDGET SPECIFIC OPTIONS”
for each widget. The former is a list of options that are common to many
widgets, the latter are the options that are idiosyncratic to that particular
widget. The Standard Options are documented on the <em class="manpage"><a class="manpage reference external" href="https://manpages.debian.org/options(3)">options(3)</a></em> man
page.</p>
<p>No distinction between standard and widget-specific options is made in this
document. Some options don’t apply to some kinds of widgets. Whether a given
widget responds to a particular option depends on the class of the widget;
buttons have a <code class="docutils literal notranslate"><span class="pre">command</span></code> option, labels do not.</p>
<p>The options supported by a given widget are listed in that widget’s man page,
or can be queried at runtime by calling the <a class="reference internal" href="#tkinter.Misc.config" title="tkinter.Misc.config"><code class="xref py py-meth docutils literal notranslate"><span class="pre">config()</span></code></a> method without
arguments, or by calling the <a class="reference internal" href="#tkinter.Misc.keys" title="tkinter.Misc.keys"><code class="xref py py-meth docutils literal notranslate"><span class="pre">keys()</span></code></a> method on that widget.
The return value of these calls is a dictionary whose key is the name of the
option as a string (for example, <code class="docutils literal notranslate"><span class="pre">'relief'</span></code>) and whose values are 5-tuples.</p>
<p>Some options, like <code class="docutils literal notranslate"><span class="pre">bg</span></code>, are synonyms for common options with long names
(<code class="docutils literal notranslate"><span class="pre">bg</span></code> is shorthand for “background”).</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Index</p></th>
<th class="head"><p>Meaning</p></th>
<th class="head"><p>Example</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>0</p></td>
<td><p>option name</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">'relief'</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>1</p></td>
<td><p>option name for database lookup</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">'relief'</span></code></p></td>
</tr>
<tr class="row-even"><td><p>2</p></td>
<td><p>option class for database
lookup</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">'Relief'</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>3</p></td>
<td><p>default value</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">'raised'</span></code></p></td>
</tr>
<tr class="row-even"><td><p>4</p></td>
<td><p>current value</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">'groove'</span></code></p></td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">fred</span><span class="o">.</span><span class="n">config</span><span class="p">())</span>
<span class="go">{'relief': ('relief', 'relief', 'Relief', 'raised', 'groove')}</span>
</pre></div>
</div>
<p>Of course, the dictionary printed will include all the options available and
their values. This is meant only as an example.</p>
</section>
<section id="geometry-management">
<span id="packer-options"></span><span id="the-packer"></span><span id="tkinter-geometry-management"></span><span id="pack-the-packer"></span><h3>Geometry management<a class="headerlink" href="#geometry-management" title="Link to this heading">¶</a></h3>
<p id="index-0">Creating a widget does not display it.
A widget appears only after it has been handed to a <em>geometry manager</em>,
which works out its size and position inside its container
and keeps the layout up to date as the container is resized or its content changes.
Forgetting to call a geometry manager is a common early mistake:
the widget is created, but nothing shows up.</p>
<p>Tk provides three geometry managers.
Each is inherited by every widget, so any widget can be managed by any of them
(but see the warning below about the incompatibility of grid and pack).
The choice depends on the kind of layout you want.</p>
<dl>
<dt><a class="reference internal" href="#tkinter.Grid.grid_configure" title="tkinter.Grid.grid_configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">grid</span></code></a></dt><dd><p>Arranges widgets in a two-dimensional table of rows and columns.
It is the most flexible manager and the one to reach for by default:
layouts that would otherwise need several nested frames can often be
expressed as a single grid,
and rows and columns can be told how to absorb extra space.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">ttk</span><span class="o">.</span><span class="n">Label</span><span class="p">(</span><span class="n">frm</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="s2">"Name:"</span><span class="p">)</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">column</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">row</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">sticky</span><span class="o">=</span><span class="s2">"w"</span><span class="p">)</span>
<span class="n">ttk</span><span class="o">.</span><span class="n">Entry</span><span class="p">(</span><span class="n">frm</span><span class="p">)</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">column</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">row</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="n">ttk</span><span class="o">.</span><span class="n">Button</span><span class="p">(</span><span class="n">frm</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="s2">"OK"</span><span class="p">)</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">column</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">row</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">sticky</span><span class="o">=</span><span class="s2">"e"</span><span class="p">)</span>
</pre></div>
</div>
</dd>
<dt><a class="reference internal" href="#tkinter.Pack.pack_configure" title="tkinter.Pack.pack_configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pack</span></code></a></dt><dd><p>Stacks widgets against one side of their container
– <code class="docutils literal notranslate"><span class="pre">"top"</span></code> (the default), <code class="docutils literal notranslate"><span class="pre">"bottom"</span></code>, <code class="docutils literal notranslate"><span class="pre">"left"</span></code> or <code class="docutils literal notranslate"><span class="pre">"right"</span></code> –
and can make them fill or expand into the space that is left.
It is convenient for simple arrangements,
such as a single row or column of widgets
or a content area framed by a toolbar and a status bar.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">toolbar</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">side</span><span class="o">=</span><span class="s2">"top"</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="s2">"x"</span><span class="p">)</span>
<span class="n">status</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">side</span><span class="o">=</span><span class="s2">"bottom"</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="s2">"x"</span><span class="p">)</span>
<span class="n">body</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">side</span><span class="o">=</span><span class="s2">"left"</span><span class="p">,</span> <span class="n">expand</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="s2">"both"</span><span class="p">)</span>
</pre></div>
</div>
</dd>
<dt><a class="reference internal" href="#tkinter.Place.place_configure" title="tkinter.Place.place_configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">place</span></code></a></dt><dd><p>Positions each widget at an explicit spot,
given either as absolute screen distances or as a fraction of the container’s size.
It offers the most control but the least automatic behavior, and is used the least;
it suits special cases such as overlapping widgets or precise custom layouts.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">background</span><span class="o">.</span><span class="n">place</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">y</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">relwidth</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">relheight</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">badge</span><span class="o">.</span><span class="n">place</span><span class="p">(</span><span class="n">relx</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">rely</span><span class="o">=</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">anchor</span><span class="o">=</span><span class="s2">"ne"</span><span class="p">)</span>
</pre></div>
</div>
</dd>
</dl>
<p>Layouts are built up by nesting:
grid or pack widgets, including frames, inside a frame or toplevel.
Toplevels are managed by the OS window manager.
Classic and themed <a class="reference internal" href="tkinter.ttk.html#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 can be managed interchangeably.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Do not apply <code class="xref py py-meth docutils literal notranslate"><span class="pre">pack()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid()</span></code> to two widgets that share the same container.
The two managers negotiate sizes in incompatible ways,
and the application can hang as they repeatedly resize the container against each other.
To combine them, keep each manager’s widgets in a separate frame.</p>
</div>
<p>The full set of options accepted by each manager, with their values and defaults,
is documented under <a class="reference internal" href="#tkinter.Grid.grid_configure" title="tkinter.Grid.grid_configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Grid.grid_configure()</span></code></a>, <a class="reference internal" href="#tkinter.Pack.pack_configure" title="tkinter.Pack.pack_configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Pack.pack_configure()</span></code></a>
and <a class="reference internal" href="#tkinter.Place.place_configure" title="tkinter.Place.place_configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Place.place_configure()</span></code></a>;
see also the <em class="manpage"><a class="manpage reference external" href="https://manpages.debian.org/grid(3tk)">grid(3tk)</a></em>, <em class="manpage"><a class="manpage reference external" href="https://manpages.debian.org/pack(3tk)">pack(3tk)</a></em> and <em class="manpage"><a class="manpage reference external" href="https://manpages.debian.org/place(3tk)">place(3tk)</a></em>
man pages.</p>
</section>
<section id="coupling-widget-variables">
<span id="id2"></span><h3>Coupling widget variables<a class="headerlink" href="#coupling-widget-variables" title="Link to this heading">¶</a></h3>
<p>Some widgets can tie their current value directly to a program variable,
so that the two stay in sync.
Options such as <code class="docutils literal notranslate"><span class="pre">variable</span></code>, <code class="docutils literal notranslate"><span class="pre">textvariable</span></code>, <code class="docutils literal notranslate"><span class="pre">value</span></code>, <code class="docutils literal notranslate"><span class="pre">onvalue</span></code> and
<code class="docutils literal notranslate"><span class="pre">offvalue</span></code> set up this connection:
when the user changes the widget the variable is updated,
and when the variable is set the widget redraws to match.</p>
<p>A widget can be linked only to a <a class="reference internal" href="#tkinter.Variable" title="tkinter.Variable"><code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code></a> object,
not to an ordinary Python variable.
This is not a limitation of <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code>
but a consequence of how the two languages differ:
the link relies on Tcl being notified every time the value changes,
and Python offers no way to react when a plain variable is reassigned.
A <code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code> sidesteps this by keeping its value inside the Tcl interpreter
and exposing it through explicit <a class="reference internal" href="#tkinter.Variable.get" title="tkinter.Variable.get"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get()</span></code></a> and <a class="reference internal" href="#tkinter.Variable.set" title="tkinter.Variable.set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code></a> methods.</p>
<p>Ready-made subclasses cover the common types:
<a class="reference internal" href="#tkinter.StringVar" title="tkinter.StringVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">StringVar</span></code></a>, <a class="reference internal" href="#tkinter.IntVar" title="tkinter.IntVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">IntVar</span></code></a>, <a class="reference internal" href="#tkinter.DoubleVar" title="tkinter.DoubleVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">DoubleVar</span></code></a> and <a class="reference internal" href="#tkinter.BooleanVar" title="tkinter.BooleanVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">BooleanVar</span></code></a>.
Pass one as a widget’s <code class="docutils literal notranslate"><span class="pre">textvariable</span></code> (or <code class="docutils literal notranslate"><span class="pre">variable</span></code>) option,
then read and update it with <a class="reference internal" href="#tkinter.Variable.get" title="tkinter.Variable.get"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get()</span></code></a> and <a class="reference internal" href="#tkinter.Variable.set" title="tkinter.Variable.set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code></a>;
the widget tracks it with no further work on your part.</p>
<p>Keep a reference to the variable for as long as the widget uses it
– for example by storing it as an attribute.
A <a class="reference internal" href="#tkinter.Variable" title="tkinter.Variable"><code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code></a> that is garbage collected removes its underlying Tcl variable,
breaking the connection to the widget (see <code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code>).</p>
<p>For example:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">tkinter</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">tk</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">tkinter</span><span class="w"> </span><span class="kn">import</span> <span class="n">ttk</span>
<span class="n">root</span> <span class="o">=</span> <span class="n">tk</span><span class="o">.</span><span class="n">Tk</span><span class="p">()</span>
<span class="c1"># Create the application variable and give it an initial value.</span>
<span class="n">contents</span> <span class="o">=</span> <span class="n">tk</span><span class="o">.</span><span class="n">StringVar</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="s2">"this is a variable"</span><span class="p">)</span>
<span class="c1"># Tell the entry widget to track the variable.</span>
<span class="n">entry</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Entry</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="n">textvariable</span><span class="o">=</span><span class="n">contents</span><span class="p">)</span>
<span class="n">entry</span><span class="o">.</span><span class="n">pack</span><span class="p">()</span>
<span class="c1"># Print the current value whenever the user presses Return.</span>
<span class="k">def</span><span class="w"> </span><span class="nf">print_contents</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"The current entry content is:"</span><span class="p">,</span> <span class="n">contents</span><span class="o">.</span><span class="n">get</span><span class="p">())</span>
<span class="n">entry</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="s2">"<Return>"</span><span class="p">,</span> <span class="n">print_contents</span><span class="p">)</span>
<span class="c1"># Setting the variable from the program updates the entry through the</span>
<span class="c1"># same link.</span>
<span class="k">def</span><span class="w"> </span><span class="nf">clear</span><span class="p">():</span>
<span class="n">contents</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span>
<span class="n">ttk</span><span class="o">.</span><span class="n">Button</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="s2">"Clear"</span><span class="p">,</span> <span class="n">command</span><span class="o">=</span><span class="n">clear</span><span class="p">)</span><span class="o">.</span><span class="n">pack</span><span class="p">()</span>
<span class="n">root</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span>
</pre></div>
</div>
</section>
<section id="the-window-manager">
<span id="tkinter-window-manager"></span><h3>The window manager<a class="headerlink" href="#the-window-manager" title="Link to this heading">¶</a></h3>
<p id="index-1">The <em>window manager</em> is the part of the desktop responsible for the title bar,
border and controls drawn around each top-level window,
and for such things as its title, position, size and icon.
Tk gives access to these through the <a class="reference internal" href="#tkinter.Wm" title="tkinter.Wm"><code class="xref py py-class docutils literal notranslate"><span class="pre">Wm</span></code></a> mixin,
which is inherited by the <a class="reference internal" href="#tkinter.Tk" title="tkinter.Tk"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code></a> root window and by every <a class="reference internal" href="#tkinter.Toplevel" title="tkinter.Toplevel"><code class="xref py py-class docutils literal notranslate"><span class="pre">Toplevel</span></code></a>.
You therefore call the window-manager methods directly on a top-level window.
Each has a short name and an equivalent <code class="docutils literal notranslate"><span class="pre">wm_</span></code>-prefixed name,
for example <a class="reference internal" href="#tkinter.Wm.title" title="tkinter.Wm.title"><code class="xref py py-meth docutils literal notranslate"><span class="pre">title()</span></code></a> and <a class="reference internal" href="#tkinter.Wm.wm_title" title="tkinter.Wm.wm_title"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_title()</span></code></a>.</p>
<p>These methods act on the top-level window
whether its content is built from the classic widgets or the themed <a class="reference internal" href="tkinter.ttk.html#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.
To reach the top-level window containing an arbitrary widget,
call its <a class="reference internal" href="#tkinter.Misc.winfo_toplevel" title="tkinter.Misc.winfo_toplevel"><code class="xref py py-meth docutils literal notranslate"><span class="pre">winfo_toplevel()</span></code></a> method.</p>
<p>For example:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">tkinter</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">tk</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">tkinter</span><span class="w"> </span><span class="kn">import</span> <span class="n">ttk</span>
<span class="n">root</span> <span class="o">=</span> <span class="n">tk</span><span class="o">.</span><span class="n">Tk</span><span class="p">()</span>
<span class="n">root</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="s2">"My Application"</span><span class="p">)</span>
<span class="n">root</span><span class="o">.</span><span class="n">geometry</span><span class="p">(</span><span class="s2">"640x480"</span><span class="p">)</span>
<span class="n">root</span><span class="o">.</span><span class="n">minsize</span><span class="p">(</span><span class="mi">320</span><span class="p">,</span> <span class="mi">240</span><span class="p">)</span>
<span class="n">ttk</span><span class="o">.</span><span class="n">Label</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="s2">"Hello"</span><span class="p">)</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">padx</span><span class="o">=</span><span class="mi">20</span><span class="p">,</span> <span class="n">pady</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
<span class="n">root</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span>
</pre></div>
</div>
<p>See <a class="reference internal" href="#tkinter.Wm" title="tkinter.Wm"><code class="xref py py-class docutils literal notranslate"><span class="pre">Wm</span></code></a> for the full set of window-manager methods.</p>
</section>
<section id="tk-option-data-types">
<span id="id3"></span><h3>Tk option data types<a class="headerlink" href="#tk-option-data-types" title="Link to this heading">¶</a></h3>
<p id="index-2">Many widget options documented in the reference
accept values of a small number of common types, described here.</p>
<dl>
<dt>anchor</dt><dd><p>Legal values are points of the compass: <code class="docutils literal notranslate"><span class="pre">"n"</span></code>, <code class="docutils literal notranslate"><span class="pre">"ne"</span></code>, <code class="docutils literal notranslate"><span class="pre">"e"</span></code>, <code class="docutils literal notranslate"><span class="pre">"se"</span></code>,
<code class="docutils literal notranslate"><span class="pre">"s"</span></code>, <code class="docutils literal notranslate"><span class="pre">"sw"</span></code>, <code class="docutils literal notranslate"><span class="pre">"w"</span></code>, <code class="docutils literal notranslate"><span class="pre">"nw"</span></code>, and also <code class="docutils literal notranslate"><span class="pre">"center"</span></code>.</p>
</dd>
<dt>bitmap</dt><dd><p>There are ten built-in, named bitmaps: <code class="docutils literal notranslate"><span class="pre">'error'</span></code>, <code class="docutils literal notranslate"><span class="pre">'gray12'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'gray25'</span></code>, <code class="docutils literal notranslate"><span class="pre">'gray50'</span></code>, <code class="docutils literal notranslate"><span class="pre">'gray75'</span></code>, <code class="docutils literal notranslate"><span class="pre">'hourglass'</span></code>, <code class="docutils literal notranslate"><span class="pre">'info'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'questhead'</span></code>, <code class="docutils literal notranslate"><span class="pre">'question'</span></code>, <code class="docutils literal notranslate"><span class="pre">'warning'</span></code>. To specify an X bitmap
filename, give the full path to the file, preceded with an <code class="docutils literal notranslate"><span class="pre">@</span></code>, as in
<code class="docutils literal notranslate"><span class="pre">"@/usr/contrib/bitmap/gumby.bit"</span></code>.</p>
</dd>
<dt>boolean</dt><dd><p>You can pass integers 0 or 1 or the strings <code class="docutils literal notranslate"><span class="pre">"yes"</span></code> or <code class="docutils literal notranslate"><span class="pre">"no"</span></code>.</p>
</dd>
<dt>callback</dt><dd><p>This is any Python function that takes no arguments. For example:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">print_it</span><span class="p">():</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"hi there"</span><span class="p">)</span>
<span class="n">fred</span><span class="p">[</span><span class="s2">"command"</span><span class="p">]</span> <span class="o">=</span> <span class="n">print_it</span>
</pre></div>
</div>
</dd>
<dt>color</dt><dd><p>Colors can be given as the names of X colors in the rgb.txt file, or as strings
representing RGB values in 4 bit: <code class="docutils literal notranslate"><span class="pre">"#RGB"</span></code>, 8 bit: <code class="docutils literal notranslate"><span class="pre">"#RRGGBB"</span></code>, 12 bit:
<code class="docutils literal notranslate"><span class="pre">"#RRRGGGBBB"</span></code>, or 16 bit: <code class="docutils literal notranslate"><span class="pre">"#RRRRGGGGBBBB"</span></code> ranges, where R,G,B here
represent any legal hex digit. See the <em class="manpage"><a class="manpage reference external" href="https://manpages.debian.org/colors(3tk)">colors(3tk)</a></em> man page for
the list of named colors.</p>
</dd>
<dt>cursor</dt><dd><p>The name of the mouse cursor to display while the pointer is over the widget.
Tk provides a portable set of cursor names available on all platforms
(for example <code class="docutils literal notranslate"><span class="pre">"arrow"</span></code>, <code class="docutils literal notranslate"><span class="pre">"watch"</span></code>, <code class="docutils literal notranslate"><span class="pre">"cross"</span></code>, or <code class="docutils literal notranslate"><span class="pre">"hand2"</span></code>);
the standard X cursor names from <code class="file docutils literal notranslate"><span class="pre">cursorfont.h</span></code> may also be used,
without the <code class="docutils literal notranslate"><span class="pre">XC_</span></code> prefix (so <code class="docutils literal notranslate"><span class="pre">XC_hand2</span></code> becomes <code class="docutils literal notranslate"><span class="pre">"hand2"</span></code>).
The full list of names, including the platform-specific ones,
is given in the <em class="manpage"><a class="manpage reference external" href="https://manpages.debian.org/cursors(3tk)">cursors(3tk)</a></em> manual page.
You can also specify a bitmap and mask file of your own.
On Windows a cursor file (<code class="file docutils literal notranslate"><span class="pre">.cur</span></code> or <code class="file docutils literal notranslate"><span class="pre">.ani</span></code>) may be used directly,
giving its path preceded with an <code class="docutils literal notranslate"><span class="pre">@</span></code>, as in <code class="docutils literal notranslate"><span class="pre">"@C:/cursors/bart.ani"</span></code>.</p>
</dd>
<dt>distance</dt><dd><p>Screen distances can be specified in either pixels or absolute distances.
Pixels are given as numbers and absolute distances as strings, with the trailing
character denoting units: <code class="docutils literal notranslate"><span class="pre">c</span></code> for centimetres, <code class="docutils literal notranslate"><span class="pre">i</span></code> for inches, <code class="docutils literal notranslate"><span class="pre">m</span></code> for
millimetres, <code class="docutils literal notranslate"><span class="pre">p</span></code> for printer’s points. For example, 3.5 inches is expressed
as <code class="docutils literal notranslate"><span class="pre">"3.5i"</span></code>.</p>
</dd>
<dt>font</dt><dd><p>Tk uses a font description such as <code class="docutils literal notranslate"><span class="pre">{courier</span> <span class="pre">10</span> <span class="pre">bold}</span></code>; in
<code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> this is most naturally passed as a tuple of
<code class="docutils literal notranslate"><span class="pre">(family,</span> <span class="pre">size,</span> <span class="pre">*styles)</span></code> (or as the equivalent string
<code class="docutils literal notranslate"><span class="pre">"Courier</span> <span class="pre">10</span> <span class="pre">bold"</span></code>). Font sizes with positive numbers are measured in
points; sizes with negative numbers are measured in pixels.</p>
</dd>
<dt>geometry</dt><dd><p>This is a string of the form <code class="docutils literal notranslate"><span class="pre">widthxheight</span></code>, where width and height are
measured in pixels for most widgets (in characters for widgets displaying text).
For example: <code class="docutils literal notranslate"><span class="pre">fred["geometry"]</span> <span class="pre">=</span> <span class="pre">"200x100"</span></code>.</p>
</dd>
<dt>justify</dt><dd><p>Legal values are the strings: <code class="docutils literal notranslate"><span class="pre">"left"</span></code>, <code class="docutils literal notranslate"><span class="pre">"center"</span></code>, and <code class="docutils literal notranslate"><span class="pre">"right"</span></code>.</p>
</dd>
<dt>region</dt><dd><p>This is a string with four space-delimited elements, each of which is a legal
distance (see above). For example: <code class="docutils literal notranslate"><span class="pre">"2</span> <span class="pre">3</span> <span class="pre">4</span> <span class="pre">5"</span></code> and <code class="docutils literal notranslate"><span class="pre">"3i</span> <span class="pre">2i</span> <span class="pre">4.5i</span> <span class="pre">2i"</span></code> and
<code class="docutils literal notranslate"><span class="pre">"3c</span> <span class="pre">2c</span> <span class="pre">4c</span> <span class="pre">10.43c"</span></code> are all legal regions.</p>
</dd>
<dt>relief</dt><dd><p>Determines what the border style of a widget will be. Legal values are:
<code class="docutils literal notranslate"><span class="pre">"raised"</span></code>, <code class="docutils literal notranslate"><span class="pre">"sunken"</span></code>, <code class="docutils literal notranslate"><span class="pre">"flat"</span></code>, <code class="docutils literal notranslate"><span class="pre">"groove"</span></code>, <code class="docutils literal notranslate"><span class="pre">"ridge"</span></code>, and
<code class="docutils literal notranslate"><span class="pre">"solid"</span></code>.</p>
</dd>
<dt>scrollcommand</dt><dd><p>This is almost always the <code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code> method of some scrollbar widget, but can
be any widget method that takes a single argument.</p>
</dd>
<dt>wrap</dt><dd><p>Must be one of: <code class="docutils literal notranslate"><span class="pre">"none"</span></code>, <code class="docutils literal notranslate"><span class="pre">"char"</span></code>, or <code class="docutils literal notranslate"><span class="pre">"word"</span></code>.</p>
</dd>
</dl>
</section>
<section id="bindings-and-events">
<span id="id4"></span><h3>Bindings and events<a class="headerlink" href="#bindings-and-events" title="Link to this heading">¶</a></h3>
<p id="index-3">The bind method from the widget command allows you to watch for certain events
and to have a callback function trigger when that event type occurs. The form
of the bind method is:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">bind</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sequence</span><span class="p">,</span> <span class="n">func</span><span class="p">,</span> <span class="n">add</span><span class="o">=</span><span class="s1">''</span><span class="p">):</span>
</pre></div>
</div>
<p>where:</p>
<dl class="simple">
<dt>sequence</dt><dd><p>is a string that denotes the target kind of event. Physical events use the
<code class="docutils literal notranslate"><span class="pre"><modifier-modifier-type-detail></span></code> form (for example <code class="docutils literal notranslate"><span class="pre">"<Enter>"</span></code> or
<code class="docutils literal notranslate"><span class="pre">"<Control-Button-1>"</span></code>); application-defined virtual events use double angle
brackets, as in <code class="docutils literal notranslate"><span class="pre">"<<Paste>>"</span></code>. (See the
<em class="manpage"><a class="manpage reference external" href="https://manpages.debian.org/bind(3tk)">bind(3tk)</a></em> man page for details.)</p>
</dd>
<dt>func</dt><dd><p>is a Python function, taking one argument, to be invoked when the event occurs.
An Event instance will be passed as the argument. (Functions deployed this way
are commonly known as <em>callbacks</em>.)</p>
</dd>
<dt>add</dt><dd><p>is optional, either <code class="docutils literal notranslate"><span class="pre">''</span></code> or <code class="docutils literal notranslate"><span class="pre">'+'</span></code>. Passing an empty string denotes that
this binding is to replace any other bindings that this event is associated
with. Passing a <code class="docutils literal notranslate"><span class="pre">'+'</span></code> means that this function is to be added to the list
of functions bound to this event type.</p>
</dd>
</dl>
<p>For example:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">turn_red</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
<span class="n">event</span><span class="o">.</span><span class="n">widget</span><span class="p">[</span><span class="s2">"activeforeground"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"red"</span>
<span class="bp">self</span><span class="o">.</span><span class="n">button</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="s2">"<Enter>"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">turn_red</span><span class="p">)</span>
</pre></div>
</div>
<p>Notice how the widget field of the event is being accessed in the
<code class="docutils literal notranslate"><span class="pre">turn_red()</span></code> callback. This field contains the widget that caught the X
event. The following table lists the other event fields you can access, and how
they are denoted in Tk, which can be useful when referring to the Tk man pages.</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Tk</p></th>
<th class="head"><p>Tkinter Event Field</p></th>
<th class="head"><p>Tk</p></th>
<th class="head"><p>Tkinter Event Field</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>%f</p></td>
<td><p>focus</p></td>
<td><p>%A</p></td>
<td><p>char</p></td>
</tr>
<tr class="row-odd"><td><p>%h</p></td>
<td><p>height</p></td>
<td><p>%E</p></td>
<td><p>send_event</p></td>
</tr>
<tr class="row-even"><td><p>%k</p></td>
<td><p>keycode</p></td>
<td><p>%K</p></td>
<td><p>keysym</p></td>
</tr>
<tr class="row-odd"><td><p>%s</p></td>
<td><p>state</p></td>
<td><p>%N</p></td>
<td><p>keysym_num</p></td>
</tr>
<tr class="row-even"><td><p>%t</p></td>
<td><p>time</p></td>
<td><p>%T</p></td>
<td><p>type</p></td>
</tr>
<tr class="row-odd"><td><p>%w</p></td>
<td><p>width</p></td>
<td><p>%W</p></td>
<td><p>widget</p></td>
</tr>
<tr class="row-even"><td><p>%x</p></td>
<td><p>x</p></td>
<td><p>%X</p></td>
<td><p>x_root</p></td>
</tr>
<tr class="row-odd"><td><p>%y</p></td>
<td><p>y</p></td>
<td><p>%Y</p></td>
<td><p>y_root</p></td>
</tr>
<tr class="row-even"><td><p>%#</p></td>
<td><p>serial</p></td>
<td><p>%b</p></td>
<td><p>num</p></td>
</tr>
<tr class="row-odd"><td><p>%d</p></td>
<td><p>detail</p></td>
<td><p>%D</p></td>
<td><p>delta</p></td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal notranslate"><span class="pre">add</span></code> parameter above only affects the bindings you make yourself.
Every widget also inherits <em>class bindings</em>
that implement its standard behavior –
for example a <a class="reference internal" href="#tkinter.Text" title="tkinter.Text"><code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code></a> widget binds <kbd class="kbd docutils literal notranslate">Control</kbd>-<kbd class="kbd docutils literal notranslate">t</kbd>
to transpose two characters.
These are described in the bindings section of the widget’s Tk man page
(such as <em class="manpage"><a class="manpage reference external" href="https://manpages.debian.org/text(3tk)">text(3tk)</a></em> or <em class="manpage"><a class="manpage reference external" href="https://manpages.debian.org/entry(3tk)">entry(3tk)</a></em>).</p>
<p>Class bindings are processed separately from your own,
so binding an event yourself does not replace the default; both run.
To suppress an unwanted default binding,
bind the event on the widget
and return the string <code class="docutils literal notranslate"><span class="pre">"break"</span></code> from your callback.</p>
</section>
<section id="the-index-parameter">
<h3>The index parameter<a class="headerlink" href="#the-index-parameter" title="Link to this heading">¶</a></h3>
<p>A number of widgets require “index” parameters to be passed. These are used to
point at a specific place in a Text widget, or to particular characters in an
Entry widget, or to particular menu items in a Menu widget.</p>
<dl class="simple">
<dt>Entry widget indexes (index, view index, etc.)</dt><dd><p>Entry widgets have methods and options that refer to character positions
in the text being displayed.
Anytime an index is needed, you may pass in:</p>
<ul class="simple">
<li><p>an integer which refers to the numeric position of a character,
counted from the beginning of the text, starting with 0;</p></li>
<li><p>the string <code class="docutils literal notranslate"><span class="pre">"anchor"</span></code>,
which refers to the anchor point of the selection,
set with the widget’s selection methods;</p></li>
<li><p>the string <code class="docutils literal notranslate"><span class="pre">"end"</span></code>,
which refers to the position just after the last character;</p></li>
<li><p>the string <code class="docutils literal notranslate"><span class="pre">"insert"</span></code>,
which refers to the character just after the insertion cursor;</p></li>
<li><p>the strings <code class="docutils literal notranslate"><span class="pre">"sel.first"</span></code> and <code class="docutils literal notranslate"><span class="pre">"sel.last"</span></code>,
which refer to the first character in the selection
and the position just after the last
(it is an error to use these if there is no selection);</p></li>
<li><p>a string consisting of <code class="docutils literal notranslate"><span class="pre">@</span></code> followed by an integer, as in <code class="docutils literal notranslate"><span class="pre">"@6"</span></code>,
where the integer is interpreted as an x pixel coordinate
in the entry’s coordinate system,
selecting the character spanning that point.</p></li>
</ul>
</dd>
<dt>Text widget indexes</dt><dd><p>The index notation for Text widgets is very rich and is best described in the Tk
man pages.</p>
</dd>
<dt>Menu indexes (menu.invoke(), menu.entryconfig(), etc.)</dt><dd><p>Some options and methods for menus manipulate specific menu entries. Anytime a
menu index is needed for an option or a parameter, you may pass in:</p>
<ul class="simple">
<li><p>an integer which refers to the numeric position of the entry in the widget,
counted from the top, starting with 0;</p></li>
<li><p>the string <code class="docutils literal notranslate"><span class="pre">"active"</span></code>, which refers to the menu position that is currently
under the cursor;</p></li>
<li><p>the string <code class="docutils literal notranslate"><span class="pre">"last"</span></code> which refers to the last menu item;</p></li>
<li><p>a string consisting of <code class="docutils literal notranslate"><span class="pre">@</span></code> followed by an integer, as in <code class="docutils literal notranslate"><span class="pre">"@6"</span></code>, where
the integer is interpreted as a y pixel coordinate in the menu’s coordinate
system;</p></li>
<li><p>the string <code class="docutils literal notranslate"><span class="pre">"none"</span></code>, which indicates no menu entry at all, most often used
with menu.activate() to deactivate all entries, and finally,</p></li>
<li><p>a text string that is pattern matched against the label of the menu entry, as
scanned from the top of the menu to the bottom. Note that this index type is
considered after all the others, which means that matches for menu items
labelled <code class="docutils literal notranslate"><span class="pre">last</span></code>, <code class="docutils literal notranslate"><span class="pre">active</span></code>, or <code class="docutils literal notranslate"><span class="pre">none</span></code> may be interpreted as the above
literals, instead.</p></li>
</ul>
</dd>
</dl>
</section>
<section id="images">
<h3>Images<a class="headerlink" href="#images" title="Link to this heading">¶</a></h3>
<p>Images of different formats can be created through the corresponding subclass
of <a class="reference internal" href="#tkinter.Image" title="tkinter.Image"><code class="xref py py-class docutils literal notranslate"><span class="pre">tkinter.Image</span></code></a>:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#tkinter.BitmapImage" title="tkinter.BitmapImage"><code class="xref py py-class docutils literal notranslate"><span class="pre">BitmapImage</span></code></a> for images in XBM format.</p></li>
<li><p><a class="reference internal" href="#tkinter.PhotoImage" title="tkinter.PhotoImage"><code class="xref py py-class docutils literal notranslate"><span class="pre">PhotoImage</span></code></a> for images in PGM, PPM, GIF and PNG formats. The latter
is supported starting with Tk 8.6.</p></li>
</ul>
<p>Either type of image is created through either the <code class="docutils literal notranslate"><span class="pre">file</span></code> or the <code class="docutils literal notranslate"><span class="pre">data</span></code>
option (other options are available as well).</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.13: </span>Added the <code class="xref py py-class docutils literal notranslate"><span class="pre">PhotoImage</span></code> method <code class="xref py py-meth docutils literal notranslate"><span class="pre">copy_replace()</span></code> to copy a region
from one image to other image, possibly with pixel zooming and/or
subsampling.
Add <em>from_coords</em> parameter to <code class="xref py py-class docutils literal notranslate"><span class="pre">PhotoImage</span></code> methods <code class="xref py py-meth docutils literal notranslate"><span class="pre">copy()</span></code>,
<code class="xref py py-meth docutils literal notranslate"><span class="pre">zoom()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">subsample()</span></code>.
Add <em>zoom</em> and <em>subsample</em> parameters to <code class="xref py py-class docutils literal notranslate"><span class="pre">PhotoImage</span></code> method
<code class="xref py py-meth docutils literal notranslate"><span class="pre">copy()</span></code>.</p>
</div>
<p>The image object can then be used wherever an <code class="docutils literal notranslate"><span class="pre">image</span></code> option is supported by
some widget (for example, labels, buttons, menus). In these cases, Tk will not keep a
reference to the image. When the last Python reference to the image object is
deleted, the image data is deleted as well, and Tk will display an empty box
wherever the image was used.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>The <a class="reference external" href="https://python-pillow.org/">Pillow</a> package adds support for
formats such as BMP, JPEG, TIFF, and WebP, among others.</p>
</div>
</section>
</section>
<section id="reference">
<h2>Reference<a class="headerlink" href="#reference" title="Link to this heading">¶</a></h2>
<p>This section documents the classes, methods, functions and constants of the
<code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> module.
Most of them wrap Tcl/Tk commands; consult the official Tcl/Tk manual pages for
the full list of widget options and further details.</p>
<dl class="py exception">
<dt class="sig sig-object py" id="tkinter.TclError">
<em class="property"><span class="k"><span class="pre">exception</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">TclError</span></span><a class="headerlink" href="#tkinter.TclError" title="Link to this definition">¶</a></dt>
<dd><p>The exception raised when a call into the Tcl interpreter fails, for example
when a widget is given an unknown option or an invalid value.</p>
</dd></dl>
<section id="base-and-mixin-classes">
<h3>Base and mixin classes<a class="headerlink" href="#base-and-mixin-classes" title="Link to this heading">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Misc">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Misc</span></span><a class="headerlink" href="#tkinter.Misc" title="Link to this definition">¶</a></dt>
<dd><p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">Misc</span></code> class is a mix-in inherited by <a class="reference internal" href="#tkinter.Tk" title="tkinter.Tk"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code></a> and, through
<a class="reference internal" href="#tkinter.BaseWidget" title="tkinter.BaseWidget"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseWidget</span></code></a>, by every widget.
It provides the large set of methods common to all Tk objects: querying
window information, managing event bindings and the event loop, controlling
the keyboard focus and pointer grabs, accessing the selection, clipboard and
option database, and assorted utility and introspection services.
Because they are inherited, these methods are available on every widget and
on the <code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code> application object, and are documented here once rather
than repeated for each widget.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.cget">
<span class="sig-name descname"><span class="pre">cget</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">key</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.cget" title="Link to this definition">¶</a></dt>
<dd><p>Return the current value of the configuration option named <em>key</em> for this
widget, as a string.
The expression <code class="docutils literal notranslate"><span class="pre">widget[key]</span></code> is equivalent and may be used instead.</p>
</dd></dl>
<dl class="py method" id="tkinter.Misc.config">
<dt class="sig sig-object py" id="tkinter.Misc.configure">
<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">cnf</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.Misc.configure" title="Link to this definition">¶</a></dt>
<dd><p>Query or modify the configuration options of the widget.
With no arguments, return a dictionary mapping every available option
name to a tuple describing it (its name, X resource name, X resource
class, default value and current value).
If a single option name is given as a string, return the tuple for just
that option.
If one or more keyword arguments are given, or a dictionary is passed as
<em>cnf</em>, set each named option to the corresponding value; the expression
<code class="docutils literal notranslate"><span class="pre">widget[key]</span> <span class="pre">=</span> <span class="pre">value</span></code> sets a single option in the same way.</p>
<p><a class="reference internal" href="#tkinter.Misc.config" title="tkinter.Misc.config"><code class="xref py py-meth docutils literal notranslate"><span class="pre">config()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.keys">
<span class="sig-name descname"><span class="pre">keys</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.keys" title="Link to this definition">¶</a></dt>
<dd><p>Return a list of the names of all configuration options of this widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.getboolean">
<span class="sig-name descname"><span class="pre">getboolean</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.getboolean" title="Link to this definition">¶</a></dt>
<dd><p>Interpret the string <em>s</em> as a Tcl boolean and return the corresponding
<a class="reference internal" href="functions.html#bool" title="bool"><code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code></a>.
Tcl accepts values such as <code class="docutils literal notranslate"><span class="pre">'1'</span></code>, <code class="docutils literal notranslate"><span class="pre">'0'</span></code>, <code class="docutils literal notranslate"><span class="pre">'yes'</span></code>, <code class="docutils literal notranslate"><span class="pre">'no'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'true'</span></code> and <code class="docutils literal notranslate"><span class="pre">'false'</span></code>.
Raise <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> if <em>s</em> is not a valid boolean.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.getdouble">
<span class="sig-name descname"><span class="pre">getdouble</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.getdouble" title="Link to this definition">¶</a></dt>
<dd><p>Interpret the string <em>s</em> as a Tcl floating-point number and return it as
a <a class="reference internal" href="functions.html#float" title="float"><code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code></a>.
Raise <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> if <em>s</em> is not a valid number.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.5.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.getint">
<span class="sig-name descname"><span class="pre">getint</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.getint" title="Link to this definition">¶</a></dt>
<dd><p>Interpret the string <em>s</em> as a Tcl integer and return it as an
<a class="reference internal" href="functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>.
Raise <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> if <em>s</em> is not a valid integer.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.getvar">
<span class="sig-name descname"><span class="pre">getvar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.getvar" title="Link to this definition">¶</a></dt>
<dd><p>Return the value of the Tcl global variable named <em>name</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.setvar">
<span class="sig-name descname"><span class="pre">setvar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.setvar" title="Link to this definition">¶</a></dt>
<dd><p>Set the Tcl global variable named <em>name</em> to <em>value</em>.</p>
<p>The <code class="xref py py-meth docutils literal notranslate"><span class="pre">getvar()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">setvar()</span></code> methods give direct access to Tcl
variables.
In most code you will instead use a <a class="reference internal" href="#tkinter.Variable" title="tkinter.Variable"><code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code></a> subclass such as
<a class="reference internal" href="#tkinter.StringVar" title="tkinter.StringVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">StringVar</span></code></a> or <a class="reference internal" href="#tkinter.IntVar" title="tkinter.IntVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">IntVar</span></code></a>, which wraps a Tcl variable and
converts its value to and from a Python type.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.register">
<span class="sig-name descname"><span class="pre">register</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">subst</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">needcleanup</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.register" title="Link to this definition">¶</a></dt>
<dd><p>Register the Python callable <em>func</em> as a Tcl command and return the name
of the new command as a string.
Whenever Tcl invokes that command, <em>func</em> is called; if <em>subst</em> is given,
it is applied to the command’s arguments first.
This is the mechanism used internally to turn Python callbacks into the
command names passed to Tk options such as <em>command</em>.
Unless <em>needcleanup</em> is false, the command is deleted automatically when
the widget is destroyed.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.13: </span>The arguments passed to <em>func</em> are no longer converted to strings.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.deletecommand">
<span class="sig-name descname"><span class="pre">deletecommand</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.deletecommand" title="Link to this definition">¶</a></dt>
<dd><p>Delete the Tcl command named <em>name</em>, such as one previously returned by
<a class="reference internal" href="#tkinter.Misc.register" title="tkinter.Misc.register"><code class="xref py py-meth docutils literal notranslate"><span class="pre">register()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.nametowidget">
<span class="sig-name descname"><span class="pre">nametowidget</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.nametowidget" title="Link to this definition">¶</a></dt>
<dd><p>Return the widget instance corresponding to the Tk pathname <em>name</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.send">
<span class="sig-name descname"><span class="pre">send</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">interp</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmd</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><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.send" title="Link to this definition">¶</a></dt>
<dd><p>Send the Tcl command <em>cmd</em>, with the given <em>args</em>, to the Tcl interpreter
registered under the name <em>interp</em>, and return its result.
This is not available on all platforms.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.destroy">
<span class="sig-name descname"><span class="pre">destroy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.destroy" title="Link to this definition">¶</a></dt>
<dd><p>Destroy this widget and all of its descendant widgets, and delete the Tcl
commands associated with them.</p>
</dd></dl>
<dl class="py method" id="tkinter.Misc.lift">
<dt class="sig sig-object py" id="tkinter.Misc.tkraise">
<span class="sig-name descname"><span class="pre">tkraise</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">aboveThis</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.Misc.tkraise" title="Link to this definition">¶</a></dt>
<dd><p>Raise this widget in the stacking order so that it is drawn on top of its
siblings.
If <em>aboveThis</em> is given, the widget is moved to be just above it in the
stacking order instead.</p>
<p><a class="reference internal" href="#tkinter.Misc.lift" title="tkinter.Misc.lift"><code class="xref py py-meth docutils literal notranslate"><span class="pre">lift()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">tkraise()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.lower">
<span class="sig-name descname"><span class="pre">lower</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">belowThis</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.Misc.lower" title="Link to this definition">¶</a></dt>
<dd><p>Lower this widget in the stacking order so that it is drawn beneath its
siblings.
If <em>belowThis</em> is given, the widget is moved to be just below it in the
stacking order instead.</p>
<p><a class="reference internal" href="#tkinter.Misc.tkraise" title="tkinter.Misc.tkraise"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tkraise()</span></code></a>/<a class="reference internal" href="#tkinter.Misc.lift" title="tkinter.Misc.lift"><code class="xref py py-meth docutils literal notranslate"><span class="pre">lift()</span></code></a> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">lower()</span></code> are overridden by the
<a class="reference internal" href="#tkinter.Canvas" title="tkinter.Canvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code></a> widget,
where they restack canvas items instead.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.image_names">
<span class="sig-name descname"><span class="pre">image_names</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.image_names" title="Link to this definition">¶</a></dt>
<dd><p>Return the names of all images that currently exist in the Tcl
interpreter.</p>
<p>This is overridden by the <a class="reference internal" href="#tkinter.Text" title="tkinter.Text"><code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code></a> widget,
where <code class="xref py py-meth docutils literal notranslate"><span class="pre">image_names()</span></code> returns the names of its embedded images
instead.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.image_types">
<span class="sig-name descname"><span class="pre">image_types</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.image_types" title="Link to this definition">¶</a></dt>
<dd><p>Return the available image types, such as <code class="docutils literal notranslate"><span class="pre">'photo'</span></code> and <code class="docutils literal notranslate"><span class="pre">'bitmap'</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Misc.anchor">
<dt class="sig sig-object py" id="tkinter.Misc.grid_anchor">
<span class="sig-name descname"><span class="pre">grid_anchor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">anchor</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.Misc.grid_anchor" title="Link to this definition">¶</a></dt>
<dd><p>Set the anchor that controls where the grid is placed inside this
container when the container is larger than the grid and no row or column
has a non-zero weight.
<em>anchor</em> is one of the usual anchor strings, such as <code class="docutils literal notranslate"><span class="pre">'nw'</span></code> (the
default) or <code class="docutils literal notranslate"><span class="pre">'center'</span></code>.
Called with no argument, this method has no effect.</p>
<p><a class="reference internal" href="#tkinter.Misc.anchor" title="tkinter.Misc.anchor"><code class="xref py py-meth docutils literal notranslate"><span class="pre">anchor()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_anchor()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.3.</span></p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Misc.bbox">
<dt class="sig sig-object py" id="tkinter.Misc.grid_bbox">
<span class="sig-name descname"><span class="pre">grid_bbox</span></span><span class="sig-paren">(</span><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">row</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">col2</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">row2</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.Misc.grid_bbox" title="Link to this definition">¶</a></dt>
<dd><p>Return the bounding box, in pixels, of a region of the grid laid out in
this container, as a 4-tuple <code class="docutils literal notranslate"><span class="pre">(xoffset,</span> <span class="pre">yoffset,</span> <span class="pre">width,</span> <span class="pre">height)</span></code>.
With no arguments the bounding box of the whole grid is returned.
If <em>column</em> and <em>row</em> are given, the box spans from the cell at row and
column 0 to that cell; if <em>col2</em> and <em>row2</em> are also given, it spans from
the cell (<em>column</em>, <em>row</em>) to the cell (<em>col2</em>, <em>row2</em>).</p>
<p><a class="reference internal" href="#tkinter.Misc.bbox" title="tkinter.Misc.bbox"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bbox()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_bbox()</span></code>,
except on <a class="reference internal" href="#tkinter.Canvas" title="tkinter.Canvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code></a>, <a class="reference internal" href="#tkinter.Listbox" title="tkinter.Listbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Listbox</span></code></a>, <a class="reference internal" href="#tkinter.Spinbox" title="tkinter.Spinbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Spinbox</span></code></a>,
<a class="reference internal" href="#tkinter.Text" title="tkinter.Text"><code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code></a>, <a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.Entry" title="tkinter.ttk.Entry"><code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Entry</span></code></a> and
<a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.Treeview" title="tkinter.ttk.Treeview"><code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Treeview</span></code></a>,
which provide their own <code class="xref py py-meth docutils literal notranslate"><span class="pre">bbox()</span></code> method.</p>
</dd></dl>
<dl class="py method" id="tkinter.Misc.columnconfigure">
<dt class="sig sig-object py" id="tkinter.Misc.grid_columnconfigure">
<span class="sig-name descname"><span class="pre">grid_columnconfigure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Misc.grid_columnconfigure" title="Link to this definition">¶</a></dt>
<dd><p>Query or set the properties of the column (or columns) <em>index</em> of the
grid managed by this container.
<em>index</em> may be a column number; when setting options it may also be a
list of column numbers, the string <code class="docutils literal notranslate"><span class="pre">'all'</span></code> to affect every column, or
a child widget whose occupied columns are affected.
The supported options are:</p>
<dl class="simple">
<dt><em>minsize</em></dt><dd><p>The column’s minimum size, in pixels.</p>
</dd>
<dt><em>weight</em></dt><dd><p>An integer setting how much of any extra space is apportioned to the
column.
A weight of <code class="docutils literal notranslate"><span class="pre">0</span></code> keeps the column at its requested size, and a column
of weight two grows twice as fast as a column of weight one.</p>
</dd>
<dt><em>uniform</em></dt><dd><p>The name of a uniform group.
Columns sharing a non-empty group name are kept in sizes that are
strictly proportional to their weights.</p>
</dd>
<dt><em>pad</em></dt><dd><p>Extra space, in pixels, added to the largest widget in the column when
computing the column’s size.</p>
</dd>
</dl>
<p>With a single option name, return that option’s value; with no options,
return a dictionary of all of them.</p>
<p><a class="reference internal" href="#tkinter.Misc.columnconfigure" title="tkinter.Misc.columnconfigure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">columnconfigure()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_columnconfigure()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Misc.rowconfigure">
<dt class="sig sig-object py" id="tkinter.Misc.grid_rowconfigure">
<span class="sig-name descname"><span class="pre">grid_rowconfigure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Misc.grid_rowconfigure" title="Link to this definition">¶</a></dt>
<dd><p>Query or set the properties of the row (or rows) <em>index</em> of the grid
managed by this container.
<em>index</em> is interpreted as for <a class="reference internal" href="#tkinter.Misc.grid_columnconfigure" title="tkinter.Misc.grid_columnconfigure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_columnconfigure()</span></code></a>, and the
supported options (<em>minsize</em>, <em>weight</em>, <em>uniform</em> and <em>pad</em>) are the
same, applied to a row instead of a column.</p>
<p><a class="reference internal" href="#tkinter.Misc.rowconfigure" title="tkinter.Misc.rowconfigure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">rowconfigure()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_rowconfigure()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.grid_location">
<span class="sig-name descname"><span class="pre">grid_location</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.Misc.grid_location" title="Link to this definition">¶</a></dt>
<dd><p>Return the <code class="docutils literal notranslate"><span class="pre">(column,</span> <span class="pre">row)</span></code> of the grid cell that contains the pixel at
position (<em>x</em>, <em>y</em>), given in pixels relative to this container.
For locations above or to the left of the grid, <code class="docutils literal notranslate"><span class="pre">-1</span></code> is returned for
the corresponding coordinate.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.grid_propagate">
<span class="sig-name descname"><span class="pre">grid_propagate</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.grid_propagate" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">grid_propagate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">flag</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Enable or disable geometry propagation for this container when it manages
its children with the grid geometry manager.
When <em>flag</em> is true, the container resizes itself to fit the requested
sizes of its children; when it is false, its size is left under your
control.
Called with no argument, return the current setting as a boolean.</p>
</dd></dl>
<dl class="py method" id="tkinter.Misc.size">
<dt class="sig sig-object py" id="tkinter.Misc.grid_size">
<span class="sig-name descname"><span class="pre">grid_size</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.grid_size" title="Link to this definition">¶</a></dt>
<dd><p>Return the size of the grid managed by this container as a
<code class="docutils literal notranslate"><span class="pre">(columns,</span> <span class="pre">rows)</span></code> tuple.</p>
<p><a class="reference internal" href="#tkinter.Misc.size" title="tkinter.Misc.size"><code class="xref py py-meth docutils literal notranslate"><span class="pre">size()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_size()</span></code>,
except on the <a class="reference internal" href="#tkinter.Listbox" title="tkinter.Listbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Listbox</span></code></a> widget,
which provides its own <code class="xref py py-meth docutils literal notranslate"><span class="pre">size()</span></code> method.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.grid_slaves">
<span class="sig-name descname"><span class="pre">grid_slaves</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">row</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">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.Misc.grid_slaves" title="Link to this definition">¶</a></dt>
<dd><p>Return a list of the child widgets managed in this container’s grid, most
recently managed first.
If <em>row</em> or <em>column</em> is given, only the children in that row or column
are returned.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.grid_content">
<span class="sig-name descname"><span class="pre">grid_content</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">row</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">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.Misc.grid_content" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.grid_slaves" title="tkinter.Misc.grid_slaves"><code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_slaves()</span></code></a>: return the child widgets managed in this
container’s grid, optionally restricted to a given <em>row</em> or <em>column</em>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15.</span></p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Misc.propagate">
<dt class="sig sig-object py" id="tkinter.Misc.pack_propagate">
<span class="sig-name descname"><span class="pre">pack_propagate</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.pack_propagate" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">pack_propagate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">flag</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Enable or disable geometry propagation for this container when it manages
its children with the pack geometry manager.
When <em>flag</em> is true, the container resizes itself to fit the requested
sizes of its children; when it is false, its size is left under your
control.
Called with no argument, return the current setting as a boolean.</p>
<p><a class="reference internal" href="#tkinter.Misc.propagate" title="tkinter.Misc.propagate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">propagate()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">pack_propagate()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Misc.slaves">
<dt class="sig sig-object py" id="tkinter.Misc.pack_slaves">
<span class="sig-name descname"><span class="pre">pack_slaves</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.pack_slaves" title="Link to this definition">¶</a></dt>
<dd><p>Return a list of the child widgets managed by this container with the
pack geometry manager, in packing order.</p>
<p><a class="reference internal" href="#tkinter.Misc.slaves" title="tkinter.Misc.slaves"><code class="xref py py-meth docutils literal notranslate"><span class="pre">slaves()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">pack_slaves()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Misc.content">
<dt class="sig sig-object py" id="tkinter.Misc.pack_content">
<span class="sig-name descname"><span class="pre">pack_content</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.pack_content" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.pack_slaves" title="tkinter.Misc.pack_slaves"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pack_slaves()</span></code></a>: return the child widgets managed by this
container with the pack geometry manager, in packing order.</p>
<p><a class="reference internal" href="#tkinter.Misc.content" title="tkinter.Misc.content"><code class="xref py py-meth docutils literal notranslate"><span class="pre">content()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">pack_content()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.place_slaves">
<span class="sig-name descname"><span class="pre">place_slaves</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.place_slaves" title="Link to this definition">¶</a></dt>
<dd><p>Return a list of the child widgets managed by this container with the
place geometry manager.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.place_content">
<span class="sig-name descname"><span class="pre">place_content</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.place_content" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.place_slaves" title="tkinter.Misc.place_slaves"><code class="xref py py-meth docutils literal notranslate"><span class="pre">place_slaves()</span></code></a>: return the child widgets managed by this
container with the place geometry manager.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15.</span></p>
</div>
</dd></dl>
<p>The methods with the <code class="docutils literal notranslate"><span class="pre">bind</span></code> and <code class="docutils literal notranslate"><span class="pre">unbind</span></code> prefixes associate event
patterns with callbacks and remove those associations.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.bind">
<span class="sig-name descname"><span class="pre">bind</span></span><span class="sig-paren">(</span><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">func</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">add</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.Misc.bind" title="Link to this definition">¶</a></dt>
<dd><p>Bind the event pattern <em>sequence</em> on this widget to the callable <em>func</em>.</p>
<p><em>sequence</em> is an event pattern, such as <code class="docutils literal notranslate"><span class="pre">'<Button-1>'</span></code> (a mouse click)
or <code class="docutils literal notranslate"><span class="pre">'<KeyPress-a>'</span></code>, optionally a concatenation of several such
patterns that must occur shortly after one another.
When the event occurs, <em>func</em> is called with an <a class="reference internal" href="#tkinter.Event" title="tkinter.Event"><code class="xref py py-class docutils literal notranslate"><span class="pre">Event</span></code></a> instance
describing it as its only argument; if <em>func</em> returns the string
<code class="docutils literal notranslate"><span class="pre">'break'</span></code>, no further bindings for the event are invoked.</p>
<p>If <em>add</em> is true, <em>func</em> is added to any functions already bound to
<em>sequence</em>; otherwise it replaces them.
The binding applies only to this widget.</p>
<p><code class="xref py py-meth docutils literal notranslate"><span class="pre">bind()</span></code> returns a string identifier (a <em>funcid</em>) that can later be
passed to <a class="reference internal" href="#tkinter.Misc.unbind" title="tkinter.Misc.unbind"><code class="xref py py-meth docutils literal notranslate"><span class="pre">unbind()</span></code></a> to remove the binding without leaking the
associated Tcl command.</p>
<p>If <em>func</em> is omitted, return the binding currently associated with
<em>sequence</em>; if <em>sequence</em> is also omitted, return a list of all the
sequences for which bindings exist on this widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.bind_class">
<span class="sig-name descname"><span class="pre">bind_class</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">className</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">func</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">add</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.Misc.bind_class" title="Link to this definition">¶</a></dt>
<dd><p>Like <a class="reference internal" href="#tkinter.Misc.bind" title="tkinter.Misc.bind"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bind()</span></code></a>, but bind <em>func</em> to the binding tag <em>className</em> rather
than to a single widget, so that the binding applies to every widget
having that tag.
<em>className</em> is usually the name of a widget class, such as <code class="docutils literal notranslate"><span class="pre">'Button'</span></code>,
in which case the binding affects all widgets of that class.
The set of binding tags for a widget can be inspected and changed with
<a class="reference internal" href="#tkinter.Misc.bindtags" title="tkinter.Misc.bindtags"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bindtags()</span></code></a>.</p>
<p>The remaining arguments and the return value are as for <a class="reference internal" href="#tkinter.Misc.bind" title="tkinter.Misc.bind"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bind()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.bind_all">
<span class="sig-name descname"><span class="pre">bind_all</span></span><span class="sig-paren">(</span><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">func</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">add</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.Misc.bind_all" title="Link to this definition">¶</a></dt>
<dd><p>Like <a class="reference internal" href="#tkinter.Misc.bind" title="tkinter.Misc.bind"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bind()</span></code></a>, but bind <em>func</em> to the special binding tag <code class="docutils literal notranslate"><span class="pre">'all'</span></code>,
so that the binding applies to every widget in the application.</p>
<p>The remaining arguments and the return value are as for <a class="reference internal" href="#tkinter.Misc.bind" title="tkinter.Misc.bind"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bind()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.unbind">
<span class="sig-name descname"><span class="pre">unbind</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sequence</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">funcid</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.Misc.unbind" title="Link to this definition">¶</a></dt>
<dd><p>Remove bindings for the event pattern <em>sequence</em> on this widget.</p>
<p>If <em>funcid</em> is given, only the function identified by it (a value
returned from a previous call to <a class="reference internal" href="#tkinter.Misc.bind" title="tkinter.Misc.bind"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bind()</span></code></a>) is removed, and its
associated Tcl command is deleted.
Otherwise all bindings for <em>sequence</em> are destroyed, leaving it unbound.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.13: </span>If <em>funcid</em> is given, only that callback is unbound; other callbacks
bound to <em>sequence</em> are kept.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.unbind_class">
<span class="sig-name descname"><span class="pre">unbind_class</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">className</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sequence</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.unbind_class" title="Link to this definition">¶</a></dt>
<dd><p>Remove all bindings for the event pattern <em>sequence</em> from the binding tag
<em>className</em>.
See <a class="reference internal" href="#tkinter.Misc.bind_class" title="tkinter.Misc.bind_class"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bind_class()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.unbind_all">
<span class="sig-name descname"><span class="pre">unbind_all</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sequence</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.unbind_all" title="Link to this definition">¶</a></dt>
<dd><p>Remove all bindings for the event pattern <em>sequence</em> from the special
binding tag <code class="docutils literal notranslate"><span class="pre">'all'</span></code>.
See <a class="reference internal" href="#tkinter.Misc.bind_all" title="tkinter.Misc.bind_all"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bind_all()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.bindtags">
<span class="sig-name descname"><span class="pre">bindtags</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagList</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.Misc.bindtags" title="Link to this definition">¶</a></dt>
<dd><p>If <em>tagList</em> is omitted, return a tuple of the binding tags associated
with this widget.
When an event occurs in a widget, it is applied to each of the widget’s
binding tags in order, and for each tag the most specific matching
binding is executed.
By default a widget has four binding tags: its own pathname, its widget
class, the pathname of its nearest toplevel ancestor, and <code class="docutils literal notranslate"><span class="pre">'all'</span></code>, in
that order.</p>
<p>If <em>tagList</em> is given, it must be a sequence of strings; the widget’s
binding tags are set to its elements, which determines the order in which
bindings are evaluated.</p>
</dd></dl>
<p>The methods with the <code class="docutils literal notranslate"><span class="pre">event_</span></code> prefix define virtual events and generate
events programmatically.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.event_add">
<span class="sig-name descname"><span class="pre">event_add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">virtual</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">sequences</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.event_add" title="Link to this definition">¶</a></dt>
<dd><p>Associate the virtual event <em>virtual</em>, whose name has the form
<code class="docutils literal notranslate"><span class="pre">'<<Paste>>'</span></code>, with each of the physical event patterns given by
<em>sequences</em>, so that the virtual event triggers whenever any of them
occurs.
If <em>virtual</em> is already defined, the new sequences are added to its
existing ones.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.event_delete">
<span class="sig-name descname"><span class="pre">event_delete</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">virtual</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">sequences</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.event_delete" title="Link to this definition">¶</a></dt>
<dd><p>Remove each of <em>sequences</em> from those associated with the virtual event
<em>virtual</em>.
Sequences that are not currently associated with <em>virtual</em> are ignored.
If no <em>sequences</em> are given, all physical event sequences are removed, so
that <em>virtual</em> no longer triggers.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.event_generate">
<span class="sig-name descname"><span class="pre">event_generate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sequence</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.Misc.event_generate" title="Link to this definition">¶</a></dt>
<dd><p>Generate the event <em>sequence</em> on this widget and arrange for it to be
processed just as if it had come from the window system.
<em>sequence</em> must be a single event pattern, such as <code class="docutils literal notranslate"><span class="pre">'<Button-1>'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'<<Paste>>'</span></code>, not a concatenation of several.
Keyword arguments specify additional fields of the event, for example <em>x</em>
and <em>y</em> for the pointer position, or <em>when</em> to control when the event is
processed; refer to the Tk <code class="docutils literal notranslate"><span class="pre">event</span></code> manual page for the full list.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.event_info">
<span class="sig-name descname"><span class="pre">event_info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">virtual</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.Misc.event_info" title="Link to this definition">¶</a></dt>
<dd><p>If <em>virtual</em> is omitted, return a tuple of all the virtual events that
are currently defined.
If <em>virtual</em> is given, return a tuple of the physical event sequences
currently associated with it, or an empty tuple if it is not defined.</p>
</dd></dl>
<p>The methods with the <code class="docutils literal notranslate"><span class="pre">after</span></code> prefix schedule callbacks to run after a
delay or when the application is idle.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.after">
<span class="sig-name descname"><span class="pre">after</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ms</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</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.Misc.after" title="Link to this definition">¶</a></dt>
<dd><p>Schedule the callable <em>func</em> to be called after <em>ms</em> milliseconds, with
<em>args</em> and <em>kw</em> passed to it as positional and keyword arguments.
Return an identifier that can be passed to <a class="reference internal" href="#tkinter.Misc.after_cancel" title="tkinter.Misc.after_cancel"><code class="xref py py-meth docutils literal notranslate"><span class="pre">after_cancel()</span></code></a> to cancel
the call.</p>
<p>If <em>func</em> is omitted, sleep for <em>ms</em> milliseconds instead, processing no
events during that time, and return <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.10: </span><em>func</em> can now be any callable object, not only a function.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.14: </span>Keyword arguments are now passed to <em>func</em>.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.after_cancel">
<span class="sig-name descname"><span class="pre">after_cancel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">id</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.after_cancel" title="Link to this definition">¶</a></dt>
<dd><p>Cancel a callback previously scheduled with <a class="reference internal" href="#tkinter.Misc.after" title="tkinter.Misc.after"><code class="xref py py-meth docutils literal notranslate"><span class="pre">after()</span></code></a> or
<a class="reference internal" href="#tkinter.Misc.after_idle" title="tkinter.Misc.after_idle"><code class="xref py py-meth docutils literal notranslate"><span class="pre">after_idle()</span></code></a>.
<em>id</em> must be an identifier returned by one of those methods; passing a
value that is not such an identifier raises <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>.
If the callback has already run or been cancelled, this has no effect.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.7: </span>Passing <code class="docutils literal notranslate"><span class="pre">None</span></code> (or any false value) as <em>id</em> now raises
<a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.after_idle">
<span class="sig-name descname"><span class="pre">after_idle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</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.Misc.after_idle" title="Link to this definition">¶</a></dt>
<dd><p>Schedule the callable <em>func</em> to be called, with <em>args</em> and <em>kw</em> passed to
it, when the Tk main loop next becomes idle, that is, when it has no
other events to process.
Return an identifier that can be passed to <a class="reference internal" href="#tkinter.Misc.after_cancel" title="tkinter.Misc.after_cancel"><code class="xref py py-meth docutils literal notranslate"><span class="pre">after_cancel()</span></code></a> to cancel
the call.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.14: </span>Keyword arguments are now passed to <em>func</em>.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.after_info">
<span class="sig-name descname"><span class="pre">after_info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">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.Misc.after_info" title="Link to this definition">¶</a></dt>
<dd><p>If <em>id</em> is omitted, return a tuple of the identifiers of all callbacks
currently scheduled with <a class="reference internal" href="#tkinter.Misc.after" title="tkinter.Misc.after"><code class="xref py py-meth docutils literal notranslate"><span class="pre">after()</span></code></a> and <a class="reference internal" href="#tkinter.Misc.after_idle" title="tkinter.Misc.after_idle"><code class="xref py py-meth docutils literal notranslate"><span class="pre">after_idle()</span></code></a> for this
interpreter.</p>
<p>If <em>id</em> is given, it must identify a callback that has not yet run or
been cancelled, and the return value is a tuple <code class="docutils literal notranslate"><span class="pre">(script,</span> <span class="pre">type)</span></code>, where
<em>script</em> refers to the function to be called and <em>type</em> is either
<code class="docutils literal notranslate"><span class="pre">'idle'</span></code> or <code class="docutils literal notranslate"><span class="pre">'timer'</span></code>.
A <a class="reference internal" href="#tkinter.TclError" title="tkinter.TclError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TclError</span></code></a> is raised if <em>id</em> does not exist.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.mainloop">
<span class="sig-name descname"><span class="pre">mainloop</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.mainloop" title="Link to this definition">¶</a></dt>
<dd><p>Enter the Tk event loop, which processes events until all windows are
destroyed.
This is normally called once, on the root window, to run the application.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.quit">
<span class="sig-name descname"><span class="pre">quit</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.quit" title="Link to this definition">¶</a></dt>
<dd><p>Quit the Tcl interpreter, causing <a class="reference internal" href="#tkinter.mainloop" title="tkinter.mainloop"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mainloop()</span></code></a> to return.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.update">
<span class="sig-name descname"><span class="pre">update</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.update" title="Link to this definition">¶</a></dt>
<dd><p>Enter the event loop until all pending events, including idle callbacks,
have been processed.
This brings the display up to date and handles any events that are
already queued, then returns.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.update_idletasks">
<span class="sig-name descname"><span class="pre">update_idletasks</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.update_idletasks" title="Link to this definition">¶</a></dt>
<dd><p>Enter the event loop until all pending idle callbacks have been called.
This updates the display of windows, for example after geometry changes,
but does not process events caused by the user.</p>
</dd></dl>
<dl class="py method" id="tkinter.Misc.waitvar">
<dt class="sig sig-object py" id="tkinter.Misc.wait_variable">
<span class="sig-name descname"><span class="pre">wait_variable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.wait_variable" title="Link to this definition">¶</a></dt>
<dd><p>Wait until the Tcl variable <em>name</em> is modified, continuing to process
events in the meantime so that the application stays responsive.
<em>name</em> is usually a <a class="reference internal" href="#tkinter.Variable" title="tkinter.Variable"><code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code></a> instance, such as an
<a class="reference internal" href="#tkinter.IntVar" title="tkinter.IntVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">IntVar</span></code></a> or <a class="reference internal" href="#tkinter.StringVar" title="tkinter.StringVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">StringVar</span></code></a>.</p>
<p><a class="reference internal" href="#tkinter.Misc.waitvar" title="tkinter.Misc.waitvar"><code class="xref py py-meth docutils literal notranslate"><span class="pre">waitvar()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">wait_variable()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.wait_window">
<span class="sig-name descname"><span class="pre">wait_window</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">window</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.Misc.wait_window" title="Link to this definition">¶</a></dt>
<dd><p>Wait until <em>window</em> is destroyed, continuing to process events in the
meantime.
If <em>window</em> is omitted, this widget is used.
This is typically used to wait for the user to finish interacting with a
dialog box.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.wait_visibility">
<span class="sig-name descname"><span class="pre">wait_visibility</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">window</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.Misc.wait_visibility" title="Link to this definition">¶</a></dt>
<dd><p>Wait until the visibility state of <em>window</em> changes, for example when it
first appears on the screen, continuing to process events in the
meantime.
If <em>window</em> is omitted, this widget is used.
This is typically used to wait for a newly created window to become
visible before acting on it.</p>
</dd></dl>
<p>The methods with the <code class="docutils literal notranslate"><span class="pre">focus_</span></code> prefix manage the keyboard focus.</p>
<dl class="py method" id="tkinter.Misc.focus_set">
<dt class="sig sig-object py" id="tkinter.Misc.focus">
<span class="sig-name descname"><span class="pre">focus</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.focus" title="Link to this definition">¶</a></dt>
<dd><p>Direct the keyboard input focus for this widget’s display to this widget.
If the application does not currently have the input focus on this
widget’s display, the widget is remembered as the focus window for its
top level, and the focus will be redirected to it the next time the
window manager gives the focus to the top level.
<code class="xref py py-meth docutils literal notranslate"><span class="pre">focus()</span></code> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">focus_set()</span></code>,
except on the <a class="reference internal" href="#tkinter.Canvas" title="tkinter.Canvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code></a> and
<a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.Treeview" title="tkinter.ttk.Treeview"><code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Treeview</span></code></a> widgets,
which provide their own <code class="xref py py-meth docutils literal notranslate"><span class="pre">focus()</span></code> method.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.focus_force">
<span class="sig-name descname"><span class="pre">focus_force</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.focus_force" title="Link to this definition">¶</a></dt>
<dd><p>Direct the keyboard input focus to this widget even if the application
does not currently have the input focus for the widget’s display.
This method should be used sparingly, if at all; normally an application
should wait for the window manager to give it the focus rather than
claiming it.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.focus_get">
<span class="sig-name descname"><span class="pre">focus_get</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.focus_get" title="Link to this definition">¶</a></dt>
<dd><p>Return the widget that currently has the keyboard focus in the
application, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if no widget in the application has the focus.
Use <a class="reference internal" href="#tkinter.Misc.focus_displayof" title="tkinter.Misc.focus_displayof"><code class="xref py py-meth docutils literal notranslate"><span class="pre">focus_displayof()</span></code></a> to work correctly with several displays.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.focus_displayof">
<span class="sig-name descname"><span class="pre">focus_displayof</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.focus_displayof" title="Link to this definition">¶</a></dt>
<dd><p>Return the widget that currently has the keyboard focus on the display
where this widget is located, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if no widget in the application
has the focus on that display.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.focus_lastfor">
<span class="sig-name descname"><span class="pre">focus_lastfor</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.focus_lastfor" title="Link to this definition">¶</a></dt>
<dd><p>Return the most recent widget to have had the keyboard focus among all
the widgets in the same top level as this widget; this is the widget that
will receive the focus the next time the window manager gives the focus
to the top level.
If no widget in that top level has ever had the focus, or if the most
recent focus widget has been deleted, the top level itself is returned.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.tk_focusFollowsMouse">
<span class="sig-name descname"><span class="pre">tk_focusFollowsMouse</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.tk_focusFollowsMouse" title="Link to this definition">¶</a></dt>
<dd><p>Reconfigure Tk to use an implicit focus model in which the focus is set
to a widget whenever the mouse pointer enters it.
This cannot easily be disabled once enabled.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.tk_focusNext">
<span class="sig-name descname"><span class="pre">tk_focusNext</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.tk_focusNext" title="Link to this definition">¶</a></dt>
<dd><p>Return the next widget after this one in the keyboard traversal order, or
<code class="docutils literal notranslate"><span class="pre">None</span></code> if there is none.
The traversal order goes first to the next child, then recursively to the
children of that child, and then to the next sibling higher in the
stacking order.
A widget is skipped if its <code class="docutils literal notranslate"><span class="pre">takefocus</span></code> option is set to <code class="docutils literal notranslate"><span class="pre">0</span></code>.
This method is used in the default bindings for the <kbd class="kbd docutils literal notranslate">Tab</kbd> key.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.tk_focusPrev">
<span class="sig-name descname"><span class="pre">tk_focusPrev</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.tk_focusPrev" title="Link to this definition">¶</a></dt>
<dd><p>Return the previous widget before this one in the keyboard traversal
order, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if there is none.
See <a class="reference internal" href="#tkinter.Misc.tk_focusNext" title="tkinter.Misc.tk_focusNext"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tk_focusNext()</span></code></a> for how the order is defined.
This method is used in the default bindings for the <kbd class="kbd docutils literal notranslate">Shift</kbd>-<kbd class="kbd docutils literal notranslate">Tab</kbd> key.</p>
</dd></dl>
<p>The methods with the <code class="docutils literal notranslate"><span class="pre">grab_</span></code> prefix set and query the input grab, which
directs all input events to a single widget.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.grab_set">
<span class="sig-name descname"><span class="pre">grab_set</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.grab_set" title="Link to this definition">¶</a></dt>
<dd><p>Set a local grab on this widget.
A grab confines pointer events to this widget and its descendants: while
the pointer is outside the widget’s subtree, button presses and releases
and pointer motion are reported to the grab widget, and windows outside
the subtree become insensitive until the grab is released.
A local grab affects only the grabbing application.
Any grab previously set by this application on the widget’s display is
automatically released.
Setting a grab is the usual way to make a dialog modal: while the grab is
in effect the user cannot interact with the other windows of the
application.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.grab_set_global">
<span class="sig-name descname"><span class="pre">grab_set_global</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.grab_set_global" title="Link to this definition">¶</a></dt>
<dd><p>Set a global grab on this widget.
A global grab is like the local grab set by <a class="reference internal" href="#tkinter.Misc.grab_set" title="tkinter.Misc.grab_set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">grab_set()</span></code></a>, but it
locks out all other applications on the screen, so that only this
widget’s subtree is sensitive to pointer events, and it also grabs the
keyboard.
Use with caution: it is easy to render a display unusable with a global
grab, since other applications stop receiving events until it is
released.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.grab_release">
<span class="sig-name descname"><span class="pre">grab_release</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.grab_release" title="Link to this definition">¶</a></dt>
<dd><p>Release the grab on this widget if there is one; otherwise do nothing.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.grab_current">
<span class="sig-name descname"><span class="pre">grab_current</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.grab_current" title="Link to this definition">¶</a></dt>
<dd><p>Return the widget that currently holds the grab in this application for
this widget’s display, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if there is no such widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.grab_status">
<span class="sig-name descname"><span class="pre">grab_status</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.grab_status" title="Link to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">None</span></code> if no grab is currently set on this widget, <code class="docutils literal notranslate"><span class="pre">"local"</span></code>
if a local grab is set, or <code class="docutils literal notranslate"><span class="pre">"global"</span></code> if a global grab is set.</p>
</dd></dl>
<p>The methods with the <code class="docutils literal notranslate"><span class="pre">selection_</span></code> prefix retrieve and manage the X
selection.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.selection_clear">
<span class="sig-name descname"><span class="pre">selection_clear</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">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.selection_clear" title="Link to this definition">¶</a></dt>
<dd><p>Clear the X selection, so that no window owns it anymore.
The selection to clear is given by the keyword argument <em>selection</em>, an
atom name such as <code class="docutils literal notranslate"><span class="pre">'PRIMARY'</span></code> or <code class="docutils literal notranslate"><span class="pre">'CLIPBOARD'</span></code>; it defaults to
<code class="docutils literal notranslate"><span class="pre">PRIMARY</span></code>.
The <em>displayof</em> keyword argument names a widget that determines the
display on which to operate, and defaults to this widget.</p>
<p>This is overridden by the <a class="reference internal" href="#tkinter.Entry" title="tkinter.Entry"><code class="xref py py-class docutils literal notranslate"><span class="pre">Entry</span></code></a>, <a class="reference internal" href="#tkinter.Listbox" title="tkinter.Listbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Listbox</span></code></a> and
<a class="reference internal" href="#tkinter.Spinbox" title="tkinter.Spinbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Spinbox</span></code></a> widgets,
where <code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_clear()</span></code> clears the widget’s own selection instead.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.selection_get">
<span class="sig-name descname"><span class="pre">selection_get</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">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.selection_get" title="Link to this definition">¶</a></dt>
<dd><p>Return the contents of the current X selection.
The keyword argument <em>selection</em> names the selection and defaults to
<code class="docutils literal notranslate"><span class="pre">PRIMARY</span></code>.
The keyword argument <em>type</em> specifies the form in which the data is to be
returned (the desired conversion target), an atom name such as
<code class="docutils literal notranslate"><span class="pre">'STRING'</span></code> or <code class="docutils literal notranslate"><span class="pre">'FILE_NAME'</span></code>; it defaults to <code class="docutils literal notranslate"><span class="pre">STRING</span></code>, except on
X11, where <code class="docutils literal notranslate"><span class="pre">UTF8_STRING</span></code> is tried first and <code class="docutils literal notranslate"><span class="pre">STRING</span></code> is used as a
fallback.
The <em>displayof</em> keyword argument names a widget that determines the
display from which to retrieve the selection, and defaults to this
widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.selection_handle">
<span class="sig-name descname"><span class="pre">selection_handle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">command</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.Misc.selection_handle" title="Link to this definition">¶</a></dt>
<dd><p>Register <em>command</em> as a handler to supply the X selection owned by this
widget when another application requests it.
When the selection is retrieved, <em>command</em> is called with two arguments,
the starting character offset and the maximum number of characters to
return, and must return at most that many characters of the selection
starting at that offset; for very long selections it is called repeatedly
with increasing offsets.
The keyword argument <em>selection</em> names the selection (default
<code class="docutils literal notranslate"><span class="pre">PRIMARY</span></code>) and the keyword argument <em>type</em> gives the form of the
selection that the handler supplies (such as <code class="docutils literal notranslate"><span class="pre">'STRING'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'FILE_NAME'</span></code>, default <code class="docutils literal notranslate"><span class="pre">STRING</span></code>).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.selection_own">
<span class="sig-name descname"><span class="pre">selection_own</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">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.selection_own" title="Link to this definition">¶</a></dt>
<dd><p>Make this widget the owner of the X selection on its display.
The previous owner, if any, is notified that it has lost the selection.
The keyword argument <em>selection</em> names the selection and defaults to
<code class="docutils literal notranslate"><span class="pre">PRIMARY</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.selection_own_get">
<span class="sig-name descname"><span class="pre">selection_own_get</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">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.selection_own_get" title="Link to this definition">¶</a></dt>
<dd><p>Return the widget in this application that owns the X selection on the
display containing this widget, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if no widget in this
application owns the selection.
The keyword argument <em>selection</em> names the selection and defaults to
<code class="docutils literal notranslate"><span class="pre">PRIMARY</span></code>.
The <em>displayof</em> keyword argument names a widget that determines the
display to query, and defaults to this widget.</p>
</dd></dl>
<p>The methods with the <code class="docutils literal notranslate"><span class="pre">clipboard_</span></code> prefix manage the clipboard.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.clipboard_append">
<span class="sig-name descname"><span class="pre">clipboard_append</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</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.Misc.clipboard_append" title="Link to this definition">¶</a></dt>
<dd><p>Append <em>string</em> to the Tk clipboard and claim ownership of the clipboard
on this widget’s display.
Before appending, the clipboard should be emptied with
<a class="reference internal" href="#tkinter.Misc.clipboard_clear" title="tkinter.Misc.clipboard_clear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">clipboard_clear()</span></code></a>; all appends should be completed before returning
to the event loop so that the clipboard is updated atomically.
The keyword argument <em>type</em> specifies the form of the data, an atom name
such as <code class="docutils literal notranslate"><span class="pre">'STRING'</span></code> or <code class="docutils literal notranslate"><span class="pre">'FILE_NAME'</span></code> (default <code class="docutils literal notranslate"><span class="pre">STRING</span></code>), and the
keyword argument <em>format</em> specifies the representation used to transmit
it (default <code class="docutils literal notranslate"><span class="pre">STRING</span></code>).
The <em>displayof</em> keyword argument names a widget that determines the
target display, and defaults to this widget.
The contents can be retrieved with <a class="reference internal" href="#tkinter.Misc.clipboard_get" title="tkinter.Misc.clipboard_get"><code class="xref py py-meth docutils literal notranslate"><span class="pre">clipboard_get()</span></code></a> or
<a class="reference internal" href="#tkinter.Misc.selection_get" title="tkinter.Misc.selection_get"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_get()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.clipboard_clear">
<span class="sig-name descname"><span class="pre">clipboard_clear</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">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.clipboard_clear" title="Link to this definition">¶</a></dt>
<dd><p>Claim ownership of the clipboard on this widget’s display and remove any
previous contents.
The <em>displayof</em> keyword argument names a widget that determines the
target display, and defaults to this widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.clipboard_get">
<span class="sig-name descname"><span class="pre">clipboard_get</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">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.clipboard_get" title="Link to this definition">¶</a></dt>
<dd><p>Retrieve data from the clipboard on this widget’s display.
The keyword argument <em>type</em> specifies the form in which the data is to be
returned, an atom name such as <code class="docutils literal notranslate"><span class="pre">'STRING'</span></code> or <code class="docutils literal notranslate"><span class="pre">'FILE_NAME'</span></code>; it
defaults to <code class="docutils literal notranslate"><span class="pre">STRING</span></code>, except on X11, where <code class="docutils literal notranslate"><span class="pre">UTF8_STRING</span></code> is tried
first and <code class="docutils literal notranslate"><span class="pre">STRING</span></code> is used as a fallback.
The <em>displayof</em> keyword argument names a widget that determines the
display, and defaults to the root window of the application.
This is equivalent to <code class="docutils literal notranslate"><span class="pre">selection_get(selection='CLIPBOARD')</span></code>.</p>
</dd></dl>
<p>The methods with the <code class="docutils literal notranslate"><span class="pre">option_</span></code> prefix query and modify the Tk option
database.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.option_add">
<span class="sig-name descname"><span class="pre">option_add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pattern</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">priority</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.Misc.option_add" title="Link to this definition">¶</a></dt>
<dd><p>Add an option to the Tk option database that associates <em>value</em> with
<em>pattern</em>.
<em>pattern</em> consists of names and/or classes separated by asterisks or
dots, in the usual X format.
<em>priority</em> is an integer between 0 and 100, or one of the symbolic names
<code class="docutils literal notranslate"><span class="pre">'widgetDefault'</span></code> (20), <code class="docutils literal notranslate"><span class="pre">'startupFile'</span></code> (40), <code class="docutils literal notranslate"><span class="pre">'userDefault'</span></code> (60),
or <code class="docutils literal notranslate"><span class="pre">'interactive'</span></code> (80); it defaults to <code class="docutils literal notranslate"><span class="pre">interactive</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.option_clear">
<span class="sig-name descname"><span class="pre">option_clear</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.option_clear" title="Link to this definition">¶</a></dt>
<dd><p>Clear the Tk option database.
Default options from the <code class="xref std std-envvar docutils literal notranslate"><span class="pre">RESOURCE_MANAGER</span></code> property or the
<code class="file docutils literal notranslate"><span class="pre">.Xdefaults</span></code> file are reloaded automatically the next time an
option is added to or removed from the database.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.option_get">
<span class="sig-name descname"><span class="pre">option_get</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">className</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.option_get" title="Link to this definition">¶</a></dt>
<dd><p>Return the value of the option matching this widget under <em>name</em> and
<em>className</em> from the Tk option database, or an empty string if there is
no matching entry.
When several entries match, the one with the highest priority is
returned, and among entries of equal priority the most recently added
one.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.option_readfile">
<span class="sig-name descname"><span class="pre">option_readfile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fileName</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">priority</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.Misc.option_readfile" title="Link to this definition">¶</a></dt>
<dd><p>Read the file named <em>fileName</em>, which should have the standard format for
an X resource database such as <code class="file docutils literal notranslate"><span class="pre">.Xdefaults</span></code>, and add all the
options it specifies to the Tk option database.
<em>priority</em> is interpreted as for <a class="reference internal" href="#tkinter.Misc.option_add" title="tkinter.Misc.option_add"><code class="xref py py-meth docutils literal notranslate"><span class="pre">option_add()</span></code></a> and defaults to
<code class="docutils literal notranslate"><span class="pre">interactive</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.bell">
<span class="sig-name descname"><span class="pre">bell</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">displayof</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.bell" title="Link to this definition">¶</a></dt>
<dd><p>Ring the bell on the display for this widget, using the display’s current
bell-related settings, and reset the screen saver for the screen.
If <em>displayof</em> is given as a widget, the bell is rung on that widget’s
display instead.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.tk_setPalette">
<span class="sig-name descname"><span class="pre">tk_setPalette</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">background</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.tk_setPalette" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">tk_setPalette</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>, <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></dt>
<dd><p>Set a new color scheme for all Tk widget elements.
Existing widgets are updated and the option database is changed so that
future widgets use the new colors.
A single color argument is taken as the normal background color, from
which a complete palette is computed.
Alternatively, the arguments may be given as keyword <em>name</em>/<em>value</em> pairs
naming individual options in the option database.
The recognized option names are <code class="docutils literal notranslate"><span class="pre">activeBackground</span></code>,
<code class="docutils literal notranslate"><span class="pre">activeForeground</span></code>, <code class="docutils literal notranslate"><span class="pre">background</span></code>, <code class="docutils literal notranslate"><span class="pre">disabledForeground</span></code>,
<code class="docutils literal notranslate"><span class="pre">foreground</span></code>, <code class="docutils literal notranslate"><span class="pre">highlightBackground</span></code>, <code class="docutils literal notranslate"><span class="pre">highlightColor</span></code>,
<code class="docutils literal notranslate"><span class="pre">insertBackground</span></code>, <code class="docutils literal notranslate"><span class="pre">selectColor</span></code>, <code class="docutils literal notranslate"><span class="pre">selectBackground</span></code>,
<code class="docutils literal notranslate"><span class="pre">selectForeground</span></code>, and <code class="docutils literal notranslate"><span class="pre">troughColor</span></code>; reasonable defaults are
computed for any that are not specified.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.tk_bisque">
<span class="sig-name descname"><span class="pre">tk_bisque</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.tk_bisque" title="Link to this definition">¶</a></dt>
<dd><p>Restore the application’s colors to the light brown (bisque) color scheme
used in Tk 3.6 and earlier versions.
Provided for backward compatibility.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.tk_strictMotif">
<span class="sig-name descname"><span class="pre">tk_strictMotif</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">boolean</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.Misc.tk_strictMotif" title="Link to this definition">¶</a></dt>
<dd><p>Query or set whether Tk’s look and feel should strictly adhere to Motif.
A true <em>boolean</em> value enables strict Motif compliance (for example, no
color change when the mouse passes over a slider).
Return the resulting setting.</p>
</dd></dl>
<p>The methods with the <code class="docutils literal notranslate"><span class="pre">busy_</span></code> prefix manage the busy state of a window,
which shows a busy cursor and ignores user input.</p>
<dl class="py method" id="tkinter.Misc.tk_busy">
<span id="tkinter.Misc.busy_hold"></span><span id="tkinter.Misc.busy"></span><dt class="sig sig-object py" id="tkinter.Misc.tk_busy_hold">
<span class="sig-name descname"><span class="pre">tk_busy_hold</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">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.tk_busy_hold" title="Link to this definition">¶</a></dt>
<dd><p>Make this widget appear busy.
A transparent window is placed in front of the widget, so that it and all
of its descendants in the widget hierarchy are blocked from pointer
events and display a busy cursor.
Normally <a class="reference internal" href="#tkinter.Misc.update" title="tkinter.Misc.update"><code class="xref py py-meth docutils literal notranslate"><span class="pre">update()</span></code></a> should be called immediately afterwards to ensure
that the hold operation is in effect before the application starts its
processing.</p>
<p>The only supported configuration option is <em>cursor</em>, the cursor to be
displayed while the widget is busy; it may have any of the values
accepted by <code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code>.</p>
<p><a class="reference internal" href="#tkinter.Misc.busy_hold" title="tkinter.Misc.busy_hold"><code class="xref py py-meth docutils literal notranslate"><span class="pre">busy_hold()</span></code></a>, <a class="reference internal" href="#tkinter.Misc.busy" title="tkinter.Misc.busy"><code class="xref py py-meth docutils literal notranslate"><span class="pre">busy()</span></code></a> and <a class="reference internal" href="#tkinter.Misc.tk_busy" title="tkinter.Misc.tk_busy"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tk_busy()</span></code></a> are aliases of
<code class="xref py py-meth docutils literal notranslate"><span class="pre">tk_busy_hold()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13.</span></p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Misc.tk_busy_config">
<span id="tkinter.Misc.busy_config"></span><span id="tkinter.Misc.busy_configure"></span><dt class="sig sig-object py" id="tkinter.Misc.tk_busy_configure">
<span class="sig-name descname"><span class="pre">tk_busy_configure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cnf</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.Misc.tk_busy_configure" title="Link to this definition">¶</a></dt>
<dd><p>Query or modify the configuration options of the busy window.
The widget must have been previously made busy by <a class="reference internal" href="#tkinter.Misc.tk_busy_hold" title="tkinter.Misc.tk_busy_hold"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tk_busy_hold()</span></code></a>.
With no arguments, return a dictionary describing all of the available
options; if <em>cnf</em> is the name of an option, return a tuple describing
that one option.
Otherwise set the given options to the given values.
Options may have any of the values accepted by <code class="xref py py-meth docutils literal notranslate"><span class="pre">tk_busy_hold()</span></code>.</p>
<p>The option database is referenced through the widget name or class.
For example, if a <a class="reference internal" href="#tkinter.Frame" title="tkinter.Frame"><code class="xref py py-class docutils literal notranslate"><span class="pre">Frame</span></code></a> widget named <code class="docutils literal notranslate"><span class="pre">frame</span></code> is to be made
busy, the busy cursor can be specified for it by either of the calls:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">w</span><span class="o">.</span><span class="n">option_add</span><span class="p">(</span><span class="s1">'*frame.busyCursor'</span><span class="p">,</span> <span class="s1">'gumby'</span><span class="p">)</span>
<span class="n">w</span><span class="o">.</span><span class="n">option_add</span><span class="p">(</span><span class="s1">'*Frame.BusyCursor'</span><span class="p">,</span> <span class="s1">'gumby'</span><span class="p">)</span>
</pre></div>
</div>
<p><a class="reference internal" href="#tkinter.Misc.busy_configure" title="tkinter.Misc.busy_configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">busy_configure()</span></code></a>, <a class="reference internal" href="#tkinter.Misc.busy_config" title="tkinter.Misc.busy_config"><code class="xref py py-meth docutils literal notranslate"><span class="pre">busy_config()</span></code></a> and <a class="reference internal" href="#tkinter.Misc.tk_busy_config" title="tkinter.Misc.tk_busy_config"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tk_busy_config()</span></code></a>
are aliases of <code class="xref py py-meth docutils literal notranslate"><span class="pre">tk_busy_configure()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13.</span></p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Misc.busy_cget">
<dt class="sig sig-object py" id="tkinter.Misc.tk_busy_cget">
<span class="sig-name descname"><span class="pre">tk_busy_cget</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">option</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.tk_busy_cget" title="Link to this definition">¶</a></dt>
<dd><p>Return the current value of the busy configuration <em>option</em>.
The widget must have been previously made busy by <a class="reference internal" href="#tkinter.Misc.tk_busy_hold" title="tkinter.Misc.tk_busy_hold"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tk_busy_hold()</span></code></a>,
and <em>option</em> may have any of the values accepted by that method.</p>
<p><a class="reference internal" href="#tkinter.Misc.busy_cget" title="tkinter.Misc.busy_cget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">busy_cget()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">tk_busy_cget()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13.</span></p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Misc.busy_forget">
<dt class="sig sig-object py" id="tkinter.Misc.tk_busy_forget">
<span class="sig-name descname"><span class="pre">tk_busy_forget</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.tk_busy_forget" title="Link to this definition">¶</a></dt>
<dd><p>Make this widget no longer busy, releasing the resources (including the
transparent window) allocated when it was made busy.
User events will again be received by the widget.
These resources are also released when the widget is destroyed.</p>
<p><a class="reference internal" href="#tkinter.Misc.busy_forget" title="tkinter.Misc.busy_forget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">busy_forget()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">tk_busy_forget()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13.</span></p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Misc.busy_status">
<dt class="sig sig-object py" id="tkinter.Misc.tk_busy_status">
<span class="sig-name descname"><span class="pre">tk_busy_status</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.tk_busy_status" title="Link to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the widget is currently busy, <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise.</p>
<p><a class="reference internal" href="#tkinter.Misc.busy_status" title="tkinter.Misc.busy_status"><code class="xref py py-meth docutils literal notranslate"><span class="pre">busy_status()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">tk_busy_status()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13.</span></p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Misc.busy_current">
<dt class="sig sig-object py" id="tkinter.Misc.tk_busy_current">
<span class="sig-name descname"><span class="pre">tk_busy_current</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pattern</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.Misc.tk_busy_current" title="Link to this definition">¶</a></dt>
<dd><p>Return a list of widgets that are currently busy.
If <em>pattern</em> is given, only busy widgets whose path names match the
pattern are returned.</p>
<p><a class="reference internal" href="#tkinter.Misc.busy_current" title="tkinter.Misc.busy_current"><code class="xref py py-meth docutils literal notranslate"><span class="pre">busy_current()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">tk_busy_current()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13.</span></p>
</div>
</dd></dl>
<p>The methods with the <code class="docutils literal notranslate"><span class="pre">winfo_</span></code> prefix retrieve information about windows
managed by Tk.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_atom">
<span class="sig-name descname"><span class="pre">winfo_atom</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">displayof</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_atom" title="Link to this definition">¶</a></dt>
<dd><p>Return the integer identifier for the atom whose name is <em>name</em>, creating
a new atom if none exists.
If <em>displayof</em> is given, the atom is looked up on the display of that
window; otherwise it is looked up on the display of the application’s
main window.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_atomname">
<span class="sig-name descname"><span class="pre">winfo_atomname</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">id</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">displayof</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_atomname" title="Link to this definition">¶</a></dt>
<dd><p>Return the textual name for the atom whose integer identifier is <em>id</em>.
This is the inverse of <a class="reference internal" href="#tkinter.Misc.winfo_atom" title="tkinter.Misc.winfo_atom"><code class="xref py py-meth docutils literal notranslate"><span class="pre">winfo_atom()</span></code></a>.
If <em>displayof</em> is given, the identifier is looked up on the display of
that window; otherwise it is looked up on the display of the
application’s main window.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_cells">
<span class="sig-name descname"><span class="pre">winfo_cells</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_cells" title="Link to this definition">¶</a></dt>
<dd><p>Return the number of cells in the colormap for the widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_children">
<span class="sig-name descname"><span class="pre">winfo_children</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_children" title="Link to this definition">¶</a></dt>
<dd><p>Return a list containing the widgets that are children of the widget, in
stacking order from lowest to highest.
Toplevel windows are returned as children of their logical parents.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_class">
<span class="sig-name descname"><span class="pre">winfo_class</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_class" title="Link to this definition">¶</a></dt>
<dd><p>Return the class name of the widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_colormapfull">
<span class="sig-name descname"><span class="pre">winfo_colormapfull</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_colormapfull" title="Link to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the colormap for the widget is known to be full,
<code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_containing">
<span class="sig-name descname"><span class="pre">winfo_containing</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rootX</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rootY</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">displayof</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_containing" title="Link to this definition">¶</a></dt>
<dd><p>Return the widget containing the point given by <em>rootX</em> and <em>rootY</em>, or
<code class="docutils literal notranslate"><span class="pre">None</span></code> if no window in this application contains the point.
The coordinates are in screen units in the coordinate system of the root
window.
If <em>displayof</em> is given, the coordinates refer to the screen containing
that window; otherwise they refer to the screen of the application’s main
window.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_depth">
<span class="sig-name descname"><span class="pre">winfo_depth</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_depth" title="Link to this definition">¶</a></dt>
<dd><p>Return the depth of the widget, that is, the number of bits per pixel.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_exists">
<span class="sig-name descname"><span class="pre">winfo_exists</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_exists" title="Link to this definition">¶</a></dt>
<dd><p>Return true if the widget exists, false otherwise.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_fpixels">
<span class="sig-name descname"><span class="pre">winfo_fpixels</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">number</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_fpixels" title="Link to this definition">¶</a></dt>
<dd><p>Return a floating-point value giving the number of pixels in the widget
corresponding to the screen distance <em>number</em> (for example,
<code class="docutils literal notranslate"><span class="pre">"2.0c"</span></code> or <code class="docutils literal notranslate"><span class="pre">"1i"</span></code>).
The result may be fractional; for a rounded integer value use
<a class="reference internal" href="#tkinter.Misc.winfo_pixels" title="tkinter.Misc.winfo_pixels"><code class="xref py py-meth docutils literal notranslate"><span class="pre">winfo_pixels()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_geometry">
<span class="sig-name descname"><span class="pre">winfo_geometry</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_geometry" title="Link to this definition">¶</a></dt>
<dd><p>Return the geometry of the widget, in the form <code class="docutils literal notranslate"><span class="pre">widthxheight+x+y</span></code>.
All dimensions are in pixels.
An offset can be negative; see <a class="reference internal" href="#tkinter.Wm.geometry" title="tkinter.Wm.geometry"><code class="xref py py-meth docutils literal notranslate"><span class="pre">geometry()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_height">
<span class="sig-name descname"><span class="pre">winfo_height</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_height" title="Link to this definition">¶</a></dt>
<dd><p>Return the height of the widget in pixels.
When a window is first created its height is 1 pixel; it is eventually
changed by a geometry manager.
See also <a class="reference internal" href="#tkinter.Misc.winfo_reqheight" title="tkinter.Misc.winfo_reqheight"><code class="xref py py-meth docutils literal notranslate"><span class="pre">winfo_reqheight()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_id">
<span class="sig-name descname"><span class="pre">winfo_id</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_id" title="Link to this definition">¶</a></dt>
<dd><p>Return a low-level platform-specific identifier for the widget.
On Unix this is the X window identifier, and on Windows it is the window
handle.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_interps">
<span class="sig-name descname"><span class="pre">winfo_interps</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">displayof</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_interps" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of the names of all Tcl interpreters currently registered
for a particular display.
If <em>displayof</em> is given, the return value refers to the display of that
window; otherwise it refers to the display of the application’s main
window.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_ismapped">
<span class="sig-name descname"><span class="pre">winfo_ismapped</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_ismapped" title="Link to this definition">¶</a></dt>
<dd><p>Return true if the widget is currently mapped, false otherwise.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_manager">
<span class="sig-name descname"><span class="pre">winfo_manager</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_manager" title="Link to this definition">¶</a></dt>
<dd><p>Return the name of the geometry manager currently responsible for the
widget, or an empty string if it is not managed by any geometry manager.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_name">
<span class="sig-name descname"><span class="pre">winfo_name</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_name" title="Link to this definition">¶</a></dt>
<dd><p>Return the widget’s name within its parent, as opposed to its full path
name.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_parent">
<span class="sig-name descname"><span class="pre">winfo_parent</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_parent" title="Link to this definition">¶</a></dt>
<dd><p>Return the path name of the widget’s parent, or an empty string if the
widget is the main window of the application.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_pathname">
<span class="sig-name descname"><span class="pre">winfo_pathname</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">id</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">displayof</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_pathname" title="Link to this definition">¶</a></dt>
<dd><p>Return the path name of the window whose identifier is <em>id</em>.
If <em>displayof</em> is given, the identifier is looked up on the display of
that window; otherwise it is looked up on the display of the
application’s main window.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_pixels">
<span class="sig-name descname"><span class="pre">winfo_pixels</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">number</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_pixels" title="Link to this definition">¶</a></dt>
<dd><p>Return the number of pixels in the widget corresponding to the screen
distance <em>number</em> (for example, <code class="docutils literal notranslate"><span class="pre">"2.0c"</span></code> or <code class="docutils literal notranslate"><span class="pre">"1i"</span></code>).
The result is rounded to the nearest integer; for a fractional result use
<a class="reference internal" href="#tkinter.Misc.winfo_fpixels" title="tkinter.Misc.winfo_fpixels"><code class="xref py py-meth docutils literal notranslate"><span class="pre">winfo_fpixels()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_pointerx">
<span class="sig-name descname"><span class="pre">winfo_pointerx</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_pointerx" title="Link to this definition">¶</a></dt>
<dd><p>Return the pointer’s <em>x</em> coordinate, in pixels, relative to the screen’s
root window (or virtual root, if one is in use).
Return <code class="docutils literal notranslate"><span class="pre">-1</span></code> if the pointer is not on the same screen as the widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_pointerxy">
<span class="sig-name descname"><span class="pre">winfo_pointerxy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_pointerxy" title="Link to this definition">¶</a></dt>
<dd><p>Return the pointer’s coordinates as an <code class="docutils literal notranslate"><span class="pre">(x,</span> <span class="pre">y)</span></code> tuple, in pixels,
relative to the screen’s root window (or virtual root, if one is in use).
Both coordinates are <code class="docutils literal notranslate"><span class="pre">-1</span></code> if the pointer is not on the same screen as
the widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_pointery">
<span class="sig-name descname"><span class="pre">winfo_pointery</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_pointery" title="Link to this definition">¶</a></dt>
<dd><p>Return the pointer’s <em>y</em> coordinate, in pixels, relative to the screen’s
root window (or virtual root, if one is in use).
Return <code class="docutils literal notranslate"><span class="pre">-1</span></code> if the pointer is not on the same screen as the widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_reqheight">
<span class="sig-name descname"><span class="pre">winfo_reqheight</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_reqheight" title="Link to this definition">¶</a></dt>
<dd><p>Return the widget’s requested height in pixels.
This is the value used by the widget’s geometry manager to compute its
geometry.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_reqwidth">
<span class="sig-name descname"><span class="pre">winfo_reqwidth</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_reqwidth" title="Link to this definition">¶</a></dt>
<dd><p>Return the widget’s requested width in pixels.
This is the value used by the widget’s geometry manager to compute its
geometry.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_rgb">
<span class="sig-name descname"><span class="pre">winfo_rgb</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">color</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_rgb" title="Link to this definition">¶</a></dt>
<dd><p>Return an <code class="docutils literal notranslate"><span class="pre">(r,</span> <span class="pre">g,</span> <span class="pre">b)</span></code> tuple of the red, green, and blue intensities, in
the range 0 to 65535, that correspond to <em>color</em> in the widget.
<em>color</em> may be specified in any of the forms acceptable for a color
option.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_rootx">
<span class="sig-name descname"><span class="pre">winfo_rootx</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_rootx" title="Link to this definition">¶</a></dt>
<dd><p>Return the <em>x</em> coordinate, in the root window of the screen, of the
upper-left corner of the widget’s border (or of the widget itself if it
has no border).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_rooty">
<span class="sig-name descname"><span class="pre">winfo_rooty</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_rooty" title="Link to this definition">¶</a></dt>
<dd><p>Return the <em>y</em> coordinate, in the root window of the screen, of the
upper-left corner of the widget’s border (or of the widget itself if it
has no border).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_screen">
<span class="sig-name descname"><span class="pre">winfo_screen</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_screen" title="Link to this definition">¶</a></dt>
<dd><p>Return the name of the screen associated with the widget, in the form
<code class="docutils literal notranslate"><span class="pre">displayName.screenIndex</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_screencells">
<span class="sig-name descname"><span class="pre">winfo_screencells</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_screencells" title="Link to this definition">¶</a></dt>
<dd><p>Return the number of cells in the default colormap for the widget’s
screen.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_screendepth">
<span class="sig-name descname"><span class="pre">winfo_screendepth</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_screendepth" title="Link to this definition">¶</a></dt>
<dd><p>Return the depth of the root window of the widget’s screen, that is, the
number of bits per pixel.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_screenheight">
<span class="sig-name descname"><span class="pre">winfo_screenheight</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_screenheight" title="Link to this definition">¶</a></dt>
<dd><p>Return the height of the widget’s screen in pixels.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_screenmmheight">
<span class="sig-name descname"><span class="pre">winfo_screenmmheight</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_screenmmheight" title="Link to this definition">¶</a></dt>
<dd><p>Return the height of the widget’s screen in millimeters.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_screenmmwidth">
<span class="sig-name descname"><span class="pre">winfo_screenmmwidth</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_screenmmwidth" title="Link to this definition">¶</a></dt>
<dd><p>Return the width of the widget’s screen in millimeters.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_screenvisual">
<span class="sig-name descname"><span class="pre">winfo_screenvisual</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_screenvisual" title="Link to this definition">¶</a></dt>
<dd><p>Return the default visual class for the widget’s screen, one of
<code class="docutils literal notranslate"><span class="pre">"directcolor"</span></code>, <code class="docutils literal notranslate"><span class="pre">"grayscale"</span></code>, <code class="docutils literal notranslate"><span class="pre">"pseudocolor"</span></code>, <code class="docutils literal notranslate"><span class="pre">"staticcolor"</span></code>,
<code class="docutils literal notranslate"><span class="pre">"staticgray"</span></code>, or <code class="docutils literal notranslate"><span class="pre">"truecolor"</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_screenwidth">
<span class="sig-name descname"><span class="pre">winfo_screenwidth</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_screenwidth" title="Link to this definition">¶</a></dt>
<dd><p>Return the width of the widget’s screen in pixels.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_server">
<span class="sig-name descname"><span class="pre">winfo_server</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_server" title="Link to this definition">¶</a></dt>
<dd><p>Return a string containing information about the server for the widget’s
display.
The exact format of this string may vary from platform to platform.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_toplevel">
<span class="sig-name descname"><span class="pre">winfo_toplevel</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_toplevel" title="Link to this definition">¶</a></dt>
<dd><p>Return the top-of-hierarchy window containing the widget.
In standard Tk this is always a <a class="reference internal" href="#tkinter.Toplevel" title="tkinter.Toplevel"><code class="xref py py-class docutils literal notranslate"><span class="pre">Toplevel</span></code></a> widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_viewable">
<span class="sig-name descname"><span class="pre">winfo_viewable</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_viewable" title="Link to this definition">¶</a></dt>
<dd><p>Return true if the widget and all of its ancestors up through the
nearest toplevel window are mapped, false otherwise.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_visual">
<span class="sig-name descname"><span class="pre">winfo_visual</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_visual" title="Link to this definition">¶</a></dt>
<dd><p>Return the visual class for the widget, one of <code class="docutils literal notranslate"><span class="pre">"directcolor"</span></code>,
<code class="docutils literal notranslate"><span class="pre">"grayscale"</span></code>, <code class="docutils literal notranslate"><span class="pre">"pseudocolor"</span></code>, <code class="docutils literal notranslate"><span class="pre">"staticcolor"</span></code>, <code class="docutils literal notranslate"><span class="pre">"staticgray"</span></code>,
or <code class="docutils literal notranslate"><span class="pre">"truecolor"</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_visualid">
<span class="sig-name descname"><span class="pre">winfo_visualid</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_visualid" title="Link to this definition">¶</a></dt>
<dd><p>Return the X identifier for the visual for the widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_visualsavailable">
<span class="sig-name descname"><span class="pre">winfo_visualsavailable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">includeids</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_visualsavailable" title="Link to this definition">¶</a></dt>
<dd><p>Return a list describing the visuals available for the widget’s screen.
Each item consists of a visual class (see <a class="reference internal" href="#tkinter.Misc.winfo_visual" title="tkinter.Misc.winfo_visual"><code class="xref py py-meth docutils literal notranslate"><span class="pre">winfo_visual()</span></code></a>) followed
by an integer depth.
If <em>includeids</em> is true, the X identifier for the visual is also
included.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_vrootheight">
<span class="sig-name descname"><span class="pre">winfo_vrootheight</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_vrootheight" title="Link to this definition">¶</a></dt>
<dd><p>Return the height of the virtual root window associated with the widget
if there is one; otherwise return the height of the widget’s screen.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_vrootwidth">
<span class="sig-name descname"><span class="pre">winfo_vrootwidth</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_vrootwidth" title="Link to this definition">¶</a></dt>
<dd><p>Return the width of the virtual root window associated with the widget if
there is one; otherwise return the width of the widget’s screen.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_vrootx">
<span class="sig-name descname"><span class="pre">winfo_vrootx</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_vrootx" title="Link to this definition">¶</a></dt>
<dd><p>Return the <em>x</em> offset of the virtual root window associated with the
widget, relative to the root window of its screen.
This is normally zero or negative, and is <code class="docutils literal notranslate"><span class="pre">0</span></code> if there is no virtual
root window.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_vrooty">
<span class="sig-name descname"><span class="pre">winfo_vrooty</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_vrooty" title="Link to this definition">¶</a></dt>
<dd><p>Return the <em>y</em> offset of the virtual root window associated with the
widget, relative to the root window of its screen.
This is normally zero or negative, and is <code class="docutils literal notranslate"><span class="pre">0</span></code> if there is no virtual
root window.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_width">
<span class="sig-name descname"><span class="pre">winfo_width</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_width" title="Link to this definition">¶</a></dt>
<dd><p>Return the width of the widget in pixels.
When a window is first created its width is 1 pixel; it is eventually
changed by a geometry manager.
See also <a class="reference internal" href="#tkinter.Misc.winfo_reqwidth" title="tkinter.Misc.winfo_reqwidth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">winfo_reqwidth()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_x">
<span class="sig-name descname"><span class="pre">winfo_x</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_x" title="Link to this definition">¶</a></dt>
<dd><p>Return the <em>x</em> coordinate, in the widget’s parent, of the upper-left
corner of the widget’s border (or of the widget itself if it has no
border).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.winfo_y">
<span class="sig-name descname"><span class="pre">winfo_y</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.winfo_y" title="Link to this definition">¶</a></dt>
<dd><p>Return the <em>y</em> coordinate, in the widget’s parent, of the upper-left
corner of the widget’s border (or of the widget itself if it has no
border).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Misc.info_patchlevel">
<span class="sig-name descname"><span class="pre">info_patchlevel</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Misc.info_patchlevel" title="Link to this definition">¶</a></dt>
<dd><p>Return the Tcl/Tk patch level as a named tuple with the same five fields
as <a class="reference internal" href="sys.html#sys.version_info" title="sys.version_info"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.version_info</span></code></a>: <em>major</em>, <em>minor</em>, <em>micro</em>, <em>releaselevel</em>
and <em>serial</em>.
<em>releaselevel</em> is <code class="docutils literal notranslate"><span class="pre">'alpha'</span></code>, <code class="docutils literal notranslate"><span class="pre">'beta'</span></code> or <code class="docutils literal notranslate"><span class="pre">'final'</span></code>.
Converting it to a string gives the version in the usual Tcl/Tk notation,
for example <code class="docutils literal notranslate"><span class="pre">'9.0.3'</span></code> for a final release or <code class="docutils literal notranslate"><span class="pre">'9.1b2'</span></code> for a
pre-release.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.11.</span></p>
</div>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Wm">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Wm</span></span><a class="headerlink" href="#tkinter.Wm" title="Link to this definition">¶</a></dt>
<dd><p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">Wm</span></code> mixin provides access to the window manager, allowing an
application to control such things as the title, geometry and icon of a
top-level window, the way it is resized, and how it responds to window
manager protocols.
It is mixed into <a class="reference internal" href="#tkinter.Tk" title="tkinter.Tk"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code></a> and <a class="reference internal" href="#tkinter.Toplevel" title="tkinter.Toplevel"><code class="xref py py-class docutils literal notranslate"><span class="pre">Toplevel</span></code></a>, so its methods are
available on every top-level window.
Each method has two equivalent spellings: a short name and a
<code class="docutils literal notranslate"><span class="pre">wm_</span></code>-prefixed name (for example, <a class="reference internal" href="#tkinter.Wm.title" title="tkinter.Wm.title"><code class="xref py py-meth docutils literal notranslate"><span class="pre">title()</span></code></a> and <a class="reference internal" href="#tkinter.Wm.wm_title" title="tkinter.Wm.wm_title"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_title()</span></code></a>).
See also <a class="reference internal" href="#tkinter-window-manager"><span class="std std-ref">The window manager</span></a>.</p>
<dl class="py method" id="tkinter.Wm.wm_aspect">
<dt class="sig sig-object py" id="tkinter.Wm.aspect">
<span class="sig-name descname"><span class="pre">aspect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">minNumer</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">minDenom</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">maxNumer</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">maxDenom</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.Wm.aspect" title="Link to this definition">¶</a></dt>
<dd><p>Constrain the aspect ratio (the ratio of width to height) of the window.
If all four arguments are given, the window manager keeps the ratio
between <code class="docutils literal notranslate"><span class="pre">minNumer/minDenom</span></code> and <code class="docutils literal notranslate"><span class="pre">maxNumer/maxDenom</span></code>; passing empty
strings removes any existing restriction.
With no arguments, return a tuple of the four current values, or <code class="docutils literal notranslate"><span class="pre">None</span></code>
if no aspect restriction is in effect.
<a class="reference internal" href="#tkinter.Wm.wm_aspect" title="tkinter.Wm.wm_aspect"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_aspect()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">aspect()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_attributes">
<dt class="sig sig-object py" id="tkinter.Wm.attributes">
<span class="sig-name descname"><span class="pre">attributes</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>, <em class="sig-param"><span class="n"><span class="pre">return_python_dict</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Wm.attributes" title="Link to this definition">¶</a></dt>
<dd><p>Query or set platform-specific attributes of the window.
With no arguments, return the platform-specific flags and their values;
pass <em>return_python_dict</em> as true to get them as a dictionary.
A single option name such as <code class="docutils literal notranslate"><span class="pre">'alpha'</span></code> returns the value of that
option, and options are set using keyword arguments (<code class="docutils literal notranslate"><span class="pre">alpha=0.5</span></code>).</p>
<p>The available attributes differ by platform.
All platforms support:</p>
<dl class="simple">
<dt><em>alpha</em></dt><dd><p>The window’s opacity, from <code class="docutils literal notranslate"><span class="pre">0.0</span></code> (fully transparent) to <code class="docutils literal notranslate"><span class="pre">1.0</span></code>
(opaque).
Where transparency is unsupported the value stays at <code class="docutils literal notranslate"><span class="pre">1.0</span></code>.</p>
</dd>
<dt><em>appearance</em></dt><dd><p>Whether the window is rendered in dark mode on Windows and macOS:
<code class="docutils literal notranslate"><span class="pre">'auto'</span></code>, <code class="docutils literal notranslate"><span class="pre">'light'</span></code> or <code class="docutils literal notranslate"><span class="pre">'dark'</span></code> (this has no effect on X11).</p>
</dd>
<dt><em>fullscreen</em></dt><dd><p>Whether the window takes up the entire screen and has no borders.</p>
</dd>
<dt><em>topmost</em></dt><dd><p>Whether the window is displayed above all other windows.</p>
</dd>
</dl>
<p>Windows additionally supports:</p>
<dl class="simple">
<dt><em>disabled</em></dt><dd><p>Whether the window is in a disabled state.</p>
</dd>
<dt><em>toolwindow</em></dt><dd><p>Whether the window uses the tool window style.</p>
</dd>
<dt><em>transparentcolor</em></dt><dd><p>The color that is made fully transparent, or an empty string for none.</p>
</dd>
</dl>
<p>macOS additionally supports:</p>
<dl class="simple">
<dt><em>class</em></dt><dd><p>Whether the underlying Aqua window is an <code class="docutils literal notranslate"><span class="pre">nswindow</span></code> or an
<code class="docutils literal notranslate"><span class="pre">nspanel</span></code>; this can only be set before the window is created.</p>
</dd>
<dt><em>modified</em></dt><dd><p>The modification state shown by the window’s close button and proxy
icon.</p>
</dd>
<dt><em>notify</em></dt><dd><p>Whether the application’s dock icon bounces to request attention.</p>
</dd>
<dt><em>stylemask</em></dt><dd><p>The style mask of the underlying Aqua window, given as a list of bit
names such as <code class="docutils literal notranslate"><span class="pre">titled</span></code> or <code class="docutils literal notranslate"><span class="pre">resizable</span></code>.</p>
</dd>
<dt><em>tabbingid</em></dt><dd><p>The identifier of the tab group that the window belongs to.</p>
</dd>
<dt><em>tabbingmode</em></dt><dd><p>Whether the window may be opened as a tab: <code class="docutils literal notranslate"><span class="pre">'auto'</span></code>, <code class="docutils literal notranslate"><span class="pre">'preferred'</span></code>
or <code class="docutils literal notranslate"><span class="pre">'disallowed'</span></code>.</p>
</dd>
<dt><em>titlepath</em></dt><dd><p>The path of the file represented by the window’s proxy icon.</p>
</dd>
<dt><em>transparent</em></dt><dd><p>Whether the content area is transparent and the window shadow is
turned off.</p>
</dd>
</dl>
<p>X11 additionally supports:</p>
<dl class="simple">
<dt><em>type</em></dt><dd><p>The window type, or a list of types in order of preference, that the
window manager should use to interpret the window, such as
<code class="docutils literal notranslate"><span class="pre">'dialog'</span></code> or <code class="docutils literal notranslate"><span class="pre">'splash'</span></code>.</p>
</dd>
<dt><em>zoomed</em></dt><dd><p>Whether the window is maximized.</p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Tk 8.6 added the <em>type</em> attribute, and Tk 9.0 added the <em>appearance</em>,
<em>class</em>, <em>stylemask</em>, <em>tabbingid</em> and <em>tabbingmode</em> attributes.</p>
</div>
<p>On X11 changes are applied asynchronously, so a queried value may not yet
reflect the most recent request.
<a class="reference internal" href="#tkinter.Wm.wm_attributes" title="tkinter.Wm.wm_attributes"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_attributes()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">attributes()</span></code>.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.13: </span>A single attribute may now be queried by name without the leading
<code class="docutils literal notranslate"><span class="pre">-</span></code>, and attributes may be set using keyword arguments.
The <em>return_python_dict</em> parameter was added.</p>
</div>
<div class="deprecated">
<p><span class="versionmodified deprecated">Deprecated since version 3.13: </span>Setting an attribute by passing the option name (with a leading
<code class="docutils literal notranslate"><span class="pre">-</span></code>) and its value as two positional arguments, as in
<code class="docutils literal notranslate"><span class="pre">w.attributes('-alpha',</span> <span class="pre">0.5)</span></code>, is deprecated; use keyword arguments
instead.</p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_client">
<dt class="sig sig-object py" id="tkinter.Wm.client">
<span class="sig-name descname"><span class="pre">client</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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.Wm.client" title="Link to this definition">¶</a></dt>
<dd><p>Store <em>name</em>, which should be the name of the host on which the
application is running, in the window’s <code class="docutils literal notranslate"><span class="pre">WM_CLIENT_MACHINE</span></code> property
for use by the window or session manager.
An empty string deletes the property.
With no argument, return the last name set, or an empty string.
<a class="reference internal" href="#tkinter.Wm.wm_client" title="tkinter.Wm.wm_client"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_client()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">client()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_colormapwindows">
<dt class="sig sig-object py" id="tkinter.Wm.colormapwindows">
<span class="sig-name descname"><span class="pre">colormapwindows</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">wlist</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Wm.colormapwindows" title="Link to this definition">¶</a></dt>
<dd><p>Manipulate the <code class="docutils literal notranslate"><span class="pre">WM_COLORMAP_WINDOWS</span></code> property, which tells the window
manager about windows that have private colormaps.
If <em>wlist</em> is given, overwrite the property with those windows (their
order is a priority order for installing colormaps).
With no arguments, return the list of windows currently named in the
property.
<a class="reference internal" href="#tkinter.Wm.wm_colormapwindows" title="tkinter.Wm.wm_colormapwindows"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_colormapwindows()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">colormapwindows()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_command">
<dt class="sig sig-object py" id="tkinter.Wm.command">
<span class="sig-name descname"><span class="pre">command</span></span><span class="sig-paren">(</span><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.Wm.command" title="Link to this definition">¶</a></dt>
<dd><p>Store <em>value</em> in the window’s <code class="docutils literal notranslate"><span class="pre">WM_COMMAND</span></code> property for use by the
window or session manager; it should be a list giving the words of the
command used to invoke the application.
An empty string deletes the property.
With no argument, return the last value set, or an empty string.
<a class="reference internal" href="#tkinter.Wm.wm_command" title="tkinter.Wm.wm_command"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_command()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">command()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_deiconify">
<dt class="sig sig-object py" id="tkinter.Wm.deiconify">
<span class="sig-name descname"><span class="pre">deiconify</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Wm.deiconify" title="Link to this definition">¶</a></dt>
<dd><p>Display the window in normal (non-iconified) form by mapping it.
If the window has never been mapped, this ensures it appears de-iconified
when it is first mapped.
On Windows the window is also raised and given the focus.
<a class="reference internal" href="#tkinter.Wm.wm_deiconify" title="tkinter.Wm.wm_deiconify"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_deiconify()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">deiconify()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_focusmodel">
<dt class="sig sig-object py" id="tkinter.Wm.focusmodel">
<span class="sig-name descname"><span class="pre">focusmodel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">model</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.Wm.focusmodel" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the focus model for the window.
<em>model</em> is either <code class="docutils literal notranslate"><span class="pre">'active'</span></code> (the window claims the input focus for
itself or its descendants, even when the focus is in another application)
or <code class="docutils literal notranslate"><span class="pre">'passive'</span></code> (the window relies on the window manager to give it the
focus).
With no argument, return the current model.
The default is <code class="docutils literal notranslate"><span class="pre">'passive'</span></code>, which is what the <code class="xref py py-meth docutils literal notranslate"><span class="pre">focus()</span></code> command
assumes.
<a class="reference internal" href="#tkinter.Wm.wm_focusmodel" title="tkinter.Wm.wm_focusmodel"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_focusmodel()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">focusmodel()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_forget">
<dt class="sig sig-object py" id="tkinter.Wm.forget">
<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">window</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Wm.forget" title="Link to this definition">¶</a></dt>
<dd><p>Unmap <em>window</em> from the screen so that it is no longer managed by the
window manager.
A <a class="reference internal" href="#tkinter.Toplevel" title="tkinter.Toplevel"><code class="xref py py-class docutils literal notranslate"><span class="pre">Toplevel</span></code></a> is then treated like a <a class="reference internal" href="#tkinter.Frame" title="tkinter.Frame"><code class="xref py py-class docutils literal notranslate"><span class="pre">Frame</span></code></a>, although its
<code class="docutils literal notranslate"><span class="pre">-menu</span></code> configuration is remembered and the menu reappears if the
widget is managed again.
<a class="reference internal" href="#tkinter.Wm.wm_forget" title="tkinter.Wm.wm_forget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_forget()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">forget()</span></code>.</p>
<p>Not to be confused with <a class="reference internal" href="#tkinter.Pack.forget" title="tkinter.Pack.forget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Pack.forget()</span></code></a>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.3.</span></p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_frame">
<dt class="sig sig-object py" id="tkinter.Wm.frame">
<span class="sig-name descname"><span class="pre">frame</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Wm.frame" title="Link to this definition">¶</a></dt>
<dd><p>Return the platform-specific window identifier for the outermost
decorative frame containing the window, if the window manager has
reparented it into such a frame; otherwise return the identifier of the
window itself.
<a class="reference internal" href="#tkinter.Wm.wm_frame" title="tkinter.Wm.wm_frame"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_frame()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">frame()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_geometry">
<dt class="sig sig-object py" id="tkinter.Wm.geometry">
<span class="sig-name descname"><span class="pre">geometry</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newGeometry</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.Wm.geometry" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the geometry of the window.
<em>newGeometry</em> has the form <code class="docutils literal notranslate"><span class="pre">=widthxheight+x+y</span></code>, where any of <code class="docutils literal notranslate"><span class="pre">=</span></code>,
<code class="docutils literal notranslate"><span class="pre">widthxheight</span></code> and the <code class="docutils literal notranslate"><span class="pre">+x+y</span></code> position may be omitted.
<em>width</em> and <em>height</em> are in pixels (or grid units for a gridded window);
a position preceded by <code class="docutils literal notranslate"><span class="pre">+</span></code> is measured from the left or top edge of the
screen and one preceded by <code class="docutils literal notranslate"><span class="pre">-</span></code> from the right or bottom edge.
An offset can be negative, as in <code class="docutils literal notranslate"><span class="pre">'200x100+-9+-8'</span></code>, when the window
edge is positioned beyond the corresponding screen edge.
An empty string cancels any user-specified geometry, letting the window
revert to its natural size.
With no argument, return the current geometry as a string of the form
<code class="docutils literal notranslate"><span class="pre">'200x200+10+10'</span></code>.
<a class="reference internal" href="#tkinter.Wm.wm_geometry" title="tkinter.Wm.wm_geometry"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_geometry()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">geometry()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_grid">
<dt class="sig sig-object py" id="tkinter.Wm.grid">
<span class="sig-name descname"><span class="pre">grid</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">baseWidth</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">baseHeight</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">widthInc</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">heightInc</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.Wm.grid" title="Link to this definition">¶</a></dt>
<dd><p>Manage the window as a gridded window and define the relationship between
grid units and pixels.
<em>baseWidth</em> and <em>baseHeight</em> are the numbers of grid units for the
window’s internally requested size, and <em>widthInc</em> and <em>heightInc</em> are
the pixel sizes of a horizontal and vertical grid unit.
Empty strings turn off gridded management.
With no arguments, return a tuple of the four current values, or <code class="docutils literal notranslate"><span class="pre">None</span></code>
if the window is not gridded.
<a class="reference internal" href="#tkinter.Wm.wm_grid" title="tkinter.Wm.wm_grid"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_grid()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid()</span></code>.</p>
<p>Not to be confused with the grid geometry manager <a class="reference internal" href="#tkinter.Grid.grid" title="tkinter.Grid.grid"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Grid.grid()</span></code></a>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_group">
<dt class="sig sig-object py" id="tkinter.Wm.group">
<span class="sig-name descname"><span class="pre">group</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pathName</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.Wm.group" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the leader of a group of related windows.
<em>pathName</em> gives the path name of the group leader; the window manager
may, for example, unmap all windows in the group when the leader is
iconified.
An empty string removes the window from any group.
With no argument, return the path name of the current group leader, or an
empty string.
<a class="reference internal" href="#tkinter.Wm.wm_group" title="tkinter.Wm.wm_group"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_group()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">group()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_iconbitmap">
<dt class="sig sig-object py" id="tkinter.Wm.iconbitmap">
<span class="sig-name descname"><span class="pre">iconbitmap</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">bitmap</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.Wm.iconbitmap" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the bitmap used by the window manager for the window’s icon.
<em>bitmap</em> names a bitmap in one of the standard forms accepted by Tk; an
empty string cancels the current icon bitmap.
With no argument, return the name of the current icon bitmap, or an empty
string.
On Windows the <em>default</em> argument names an icon (for example an <code class="docutils literal notranslate"><span class="pre">.ico</span></code>
file) applied to all top-level windows that have no icon of their own.
<a class="reference internal" href="#tkinter.Wm.wm_iconbitmap" title="tkinter.Wm.wm_iconbitmap"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_iconbitmap()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">iconbitmap()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_iconify">
<dt class="sig sig-object py" id="tkinter.Wm.iconify">
<span class="sig-name descname"><span class="pre">iconify</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Wm.iconify" title="Link to this definition">¶</a></dt>
<dd><p>Iconify the window.
If the window has not yet been mapped for the first time, arrange for it
to appear in the iconified state when it is eventually mapped.
<a class="reference internal" href="#tkinter.Wm.wm_iconify" title="tkinter.Wm.wm_iconify"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_iconify()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">iconify()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_iconmask">
<dt class="sig sig-object py" id="tkinter.Wm.iconmask">
<span class="sig-name descname"><span class="pre">iconmask</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">bitmap</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.Wm.iconmask" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the bitmap used as a mask for the icon (see
<a class="reference internal" href="#tkinter.Wm.iconbitmap" title="tkinter.Wm.iconbitmap"><code class="xref py py-meth docutils literal notranslate"><span class="pre">iconbitmap()</span></code></a>).
Where the mask is zero no icon is displayed; where it is one, the
corresponding bits of the icon bitmap are shown.
An empty string cancels the current mask.
With no argument, return the name of the current icon mask, or an empty
string.
<a class="reference internal" href="#tkinter.Wm.wm_iconmask" title="tkinter.Wm.wm_iconmask"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_iconmask()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">iconmask()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_iconname">
<dt class="sig sig-object py" id="tkinter.Wm.iconname">
<span class="sig-name descname"><span class="pre">iconname</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newName</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.Wm.iconname" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the name displayed by the window manager inside the window’s
icon.
With no argument, return the current icon name, or an empty string if
none has been set (in which case the window manager normally displays the
window’s title).
<a class="reference internal" href="#tkinter.Wm.wm_iconname" title="tkinter.Wm.wm_iconname"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_iconname()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">iconname()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_iconphoto">
<dt class="sig sig-object py" id="tkinter.Wm.iconphoto">
<span class="sig-name descname"><span class="pre">iconphoto</span></span><span class="sig-paren">(</span><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">False</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">images</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Wm.iconphoto" title="Link to this definition">¶</a></dt>
<dd><p>Set the titlebar icon for the window from one or more <a class="reference internal" href="#tkinter.PhotoImage" title="tkinter.PhotoImage"><code class="xref py py-class docutils literal notranslate"><span class="pre">PhotoImage</span></code></a>
objects given in <em>images</em>.
Several images of different sizes (for example 16x16 and 32x32) may be
supplied so that the window manager can choose an appropriate one.
The image data is taken as a snapshot at the time of the call; later
changes to the images are not reflected.
If <em>default</em> is true, the icon is also applied to all top-level windows
created in the future.
On macOS only the first image is used.
<a class="reference internal" href="#tkinter.Wm.wm_iconphoto" title="tkinter.Wm.wm_iconphoto"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_iconphoto()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">iconphoto()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.3.</span></p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_iconposition">
<dt class="sig sig-object py" id="tkinter.Wm.iconposition">
<span class="sig-name descname"><span class="pre">iconposition</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</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">y</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.Wm.iconposition" title="Link to this definition">¶</a></dt>
<dd><p>Set or query a hint to the window manager about where the window’s icon
should be positioned.
Empty strings cancel an existing hint.
With no arguments, return a tuple of the two current values, or <code class="docutils literal notranslate"><span class="pre">None</span></code>
if no hint is in effect.
<a class="reference internal" href="#tkinter.Wm.wm_iconposition" title="tkinter.Wm.wm_iconposition"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_iconposition()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">iconposition()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_iconwindow">
<dt class="sig sig-object py" id="tkinter.Wm.iconwindow">
<span class="sig-name descname"><span class="pre">iconwindow</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pathName</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.Wm.iconwindow" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the window used as the icon for the window.
When the window is iconified, <em>pathName</em> is mapped to serve as its icon
and unmapped again when it is de-iconified.
An empty string cancels the association.
With no argument, return the path name of the current icon window, or an
empty string.
Not all window managers support icon windows, and the concept is
meaningless on non-X11 platforms.
<a class="reference internal" href="#tkinter.Wm.wm_iconwindow" title="tkinter.Wm.wm_iconwindow"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_iconwindow()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">iconwindow()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_manage">
<dt class="sig sig-object py" id="tkinter.Wm.manage">
<span class="sig-name descname"><span class="pre">manage</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">widget</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Wm.manage" title="Link to this definition">¶</a></dt>
<dd><p>Make <em>widget</em> a stand-alone top-level window, decorated by the window
manager with a title bar and so on.
Only <a class="reference internal" href="#tkinter.Frame" title="tkinter.Frame"><code class="xref py py-class docutils literal notranslate"><span class="pre">Frame</span></code></a>, <a class="reference internal" href="#tkinter.LabelFrame" title="tkinter.LabelFrame"><code class="xref py py-class docutils literal notranslate"><span class="pre">LabelFrame</span></code></a> and <a class="reference internal" href="#tkinter.Toplevel" title="tkinter.Toplevel"><code class="xref py py-class docutils literal notranslate"><span class="pre">Toplevel</span></code></a> widgets
may be used (the <a class="reference internal" href="tkinter.ttk.html#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> versions are <strong>not</strong> accepted);
passing any other widget type raises an error.
<a class="reference internal" href="#tkinter.Wm.wm_manage" title="tkinter.Wm.wm_manage"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_manage()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">manage()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.3.</span></p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_maxsize">
<dt class="sig sig-object py" id="tkinter.Wm.maxsize">
<span class="sig-name descname"><span class="pre">maxsize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">width</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">height</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.Wm.maxsize" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the maximum permissible dimensions of the window, in pixels
(or grid units for a gridded window).
The window manager restricts the window to be no larger than <em>width</em> and
<em>height</em>.
With no arguments, return a tuple of the current maximum width and
height.
The maximum size defaults to the size of the screen.
<a class="reference internal" href="#tkinter.Wm.wm_maxsize" title="tkinter.Wm.wm_maxsize"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_maxsize()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">maxsize()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_minsize">
<dt class="sig sig-object py" id="tkinter.Wm.minsize">
<span class="sig-name descname"><span class="pre">minsize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">width</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">height</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.Wm.minsize" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the minimum permissible dimensions of the window, in pixels
(or grid units for a gridded window).
The window manager restricts the window to be no smaller than <em>width</em> and
<em>height</em>.
With no arguments, return a tuple of the current minimum width and
height.
The minimum size defaults to one pixel in each dimension.
<a class="reference internal" href="#tkinter.Wm.wm_minsize" title="tkinter.Wm.wm_minsize"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_minsize()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">minsize()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_overrideredirect">
<dt class="sig sig-object py" id="tkinter.Wm.overrideredirect">
<span class="sig-name descname"><span class="pre">overrideredirect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">boolean</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.Wm.overrideredirect" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the override-redirect flag for the window.
When this flag is set, the window is ignored by the window manager: it is
not reparented into a decorative frame and the user cannot manipulate it
through the usual window manager controls.
With no argument, return a boolean indicating whether the flag is set,
or <code class="docutils literal notranslate"><span class="pre">None</span></code> if it has not been set.
The flag is reliably honored only when the window is first mapped or
remapped from the withdrawn state.
<a class="reference internal" href="#tkinter.Wm.wm_overrideredirect" title="tkinter.Wm.wm_overrideredirect"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_overrideredirect()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">overrideredirect()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_positionfrom">
<dt class="sig sig-object py" id="tkinter.Wm.positionfrom">
<span class="sig-name descname"><span class="pre">positionfrom</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">who</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.Wm.positionfrom" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the source of the window’s current position.
<em>who</em> is either <code class="docutils literal notranslate"><span class="pre">'program'</span></code> or <code class="docutils literal notranslate"><span class="pre">'user'</span></code> and indicates whether the
position was requested by the program or by the user; an empty string
cancels the current source.
With no argument, return the current source, or an empty string if none
has been set.
Tk automatically sets the source to <code class="docutils literal notranslate"><span class="pre">'user'</span></code> when <a class="reference internal" href="#tkinter.Wm.geometry" title="tkinter.Wm.geometry"><code class="xref py py-meth docutils literal notranslate"><span class="pre">geometry()</span></code></a> is
called, unless it has been set explicitly to <code class="docutils literal notranslate"><span class="pre">'program'</span></code>.
<a class="reference internal" href="#tkinter.Wm.wm_positionfrom" title="tkinter.Wm.wm_positionfrom"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_positionfrom()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">positionfrom()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_protocol">
<dt class="sig sig-object py" id="tkinter.Wm.protocol">
<span class="sig-name descname"><span class="pre">protocol</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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">func</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.Wm.protocol" title="Link to this definition">¶</a></dt>
<dd><p>Register <em>func</em> as the handler for the window manager protocol <em>name</em>, an
atom such as <code class="docutils literal notranslate"><span class="pre">'WM_DELETE_WINDOW'</span></code>, <code class="docutils literal notranslate"><span class="pre">'WM_SAVE_YOURSELF'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'WM_TAKE_FOCUS'</span></code>; <em>func</em> is then called whenever the window manager
sends a message of that protocol.
Tk installs a default <code class="docutils literal notranslate"><span class="pre">WM_DELETE_WINDOW</span></code> handler that destroys the
window, which this method can replace.
If <em>func</em> is an empty string, the handler is removed.
With only <em>name</em>, return the name of its registered handler command, or
an empty string if none is set (the default <code class="docutils literal notranslate"><span class="pre">WM_DELETE_WINDOW</span></code> handler
is not reported); with no arguments, return a tuple of the protocols that
currently have handlers.
<a class="reference internal" href="#tkinter.Wm.wm_protocol" title="tkinter.Wm.wm_protocol"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_protocol()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">protocol()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_resizable">
<dt class="sig sig-object py" id="tkinter.Wm.resizable">
<span class="sig-name descname"><span class="pre">resizable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">width</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">height</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.Wm.resizable" title="Link to this definition">¶</a></dt>
<dd><p>Control whether the user may interactively resize the window.
<em>width</em> and <em>height</em> are boolean values that determine whether the
window’s width and height may be changed.
With no arguments, return a tuple of two <code class="docutils literal notranslate"><span class="pre">0</span></code>/<code class="docutils literal notranslate"><span class="pre">1</span></code> values indicating
whether each dimension is currently resizable.
By default a window is resizable in both dimensions.
<a class="reference internal" href="#tkinter.Wm.wm_resizable" title="tkinter.Wm.wm_resizable"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_resizable()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">resizable()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_sizefrom">
<dt class="sig sig-object py" id="tkinter.Wm.sizefrom">
<span class="sig-name descname"><span class="pre">sizefrom</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">who</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.Wm.sizefrom" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the source of the window’s current size.
<em>who</em> is either <code class="docutils literal notranslate"><span class="pre">'program'</span></code> or <code class="docutils literal notranslate"><span class="pre">'user'</span></code> and indicates whether the
size was requested by the program or by the user; an empty string cancels
the current source.
With no argument, return the current source, or an empty string if none
has been set.
<a class="reference internal" href="#tkinter.Wm.wm_sizefrom" title="tkinter.Wm.wm_sizefrom"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_sizefrom()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">sizefrom()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_state">
<dt class="sig sig-object py" id="tkinter.Wm.state">
<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">newstate</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.Wm.state" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the state of the window.
With no argument, return the current state: one of <code class="docutils literal notranslate"><span class="pre">'normal'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'iconic'</span></code>, <code class="docutils literal notranslate"><span class="pre">'withdrawn'</span></code>, <code class="docutils literal notranslate"><span class="pre">'icon'</span></code> or, on Windows and macOS only,
<code class="docutils literal notranslate"><span class="pre">'zoomed'</span></code>.
<code class="docutils literal notranslate"><span class="pre">'iconic'</span></code> refers to a window that has been iconified, while <code class="docutils literal notranslate"><span class="pre">'icon'</span></code>
refers to a window serving as the icon for another window (see
<a class="reference internal" href="#tkinter.Wm.iconwindow" title="tkinter.Wm.iconwindow"><code class="xref py py-meth docutils literal notranslate"><span class="pre">iconwindow()</span></code></a>); the <code class="docutils literal notranslate"><span class="pre">'icon'</span></code> state cannot be set.
<a class="reference internal" href="#tkinter.Wm.wm_state" title="tkinter.Wm.wm_state"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_state()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">state()</span></code>.</p>
<p>Not to be confused with <a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.Widget.state" title="tkinter.ttk.Widget.state"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ttk.Widget.state</span></code></a>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_title">
<dt class="sig sig-object py" id="tkinter.Wm.title">
<span class="sig-name descname"><span class="pre">title</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</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.Wm.title" title="Link to this definition">¶</a></dt>
<dd><p>Set or query the title for the window, which the window manager should
display in the window’s title bar.
With no argument, return the current title.
The title defaults to the window’s name.
<a class="reference internal" href="#tkinter.Wm.wm_title" title="tkinter.Wm.wm_title"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_title()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">title()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_transient">
<dt class="sig sig-object py" id="tkinter.Wm.transient">
<span class="sig-name descname"><span class="pre">transient</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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.Wm.transient" title="Link to this definition">¶</a></dt>
<dd><p>Mark the window as a transient window (such as a pull-down menu or
dialog) working on behalf of <em>master</em>, the path name of another top-level
window.
An empty string clears the transient status.
With no argument, return the path name of the current master, or an empty
string.
A transient window mirrors state changes in its master and may be
decorated differently by the window manager; it is an error to make a
window a transient of itself.
<a class="reference internal" href="#tkinter.Wm.wm_transient" title="tkinter.Wm.wm_transient"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_transient()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">transient()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Wm.wm_withdraw">
<dt class="sig sig-object py" id="tkinter.Wm.withdraw">
<span class="sig-name descname"><span class="pre">withdraw</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Wm.withdraw" title="Link to this definition">¶</a></dt>
<dd><p>Withdraw the window from the screen, unmapping it and causing the window
manager to forget about it.
If the window has never been mapped, it is instead mapped in the
withdrawn state.
It is sometimes necessary to withdraw a window and then re-map it (for
example with <a class="reference internal" href="#tkinter.Wm.deiconify" title="tkinter.Wm.deiconify"><code class="xref py py-meth docutils literal notranslate"><span class="pre">deiconify()</span></code></a>) to make some window managers notice
changes to window attributes.
<a class="reference internal" href="#tkinter.Wm.wm_withdraw" title="tkinter.Wm.wm_withdraw"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wm_withdraw()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">withdraw()</span></code>.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Pack">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Pack</span></span><a class="headerlink" href="#tkinter.Pack" title="Link to this definition">¶</a></dt>
<dd><p>Geometry manager that arranges widgets by packing them against the sides of
their container.
The <code class="xref py py-class docutils literal notranslate"><span class="pre">Pack</span></code> mix-in is inherited by all widgets (through
<a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>) and provides the methods for managing a widget with the
<em>pack</em> geometry manager.
See also <a class="reference internal" href="#tkinter-geometry-management"><span class="std std-ref">Geometry management</span></a>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">Pack</span></code>, <a class="reference internal" href="#tkinter.Place" title="tkinter.Place"><code class="xref py py-class docutils literal notranslate"><span class="pre">Place</span></code></a> and <a class="reference internal" href="#tkinter.Grid" title="tkinter.Grid"><code class="xref py py-class docutils literal notranslate"><span class="pre">Grid</span></code></a> all define the short
method names <code class="xref py py-meth docutils literal notranslate"><span class="pre">forget()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">info()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">slaves()</span></code>,
<code class="xref py py-meth docutils literal notranslate"><span class="pre">content()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">propagate()</span></code>.
On a widget the bare names resolve to the <em>pack</em> manager’s versions,
since <code class="xref py py-class docutils literal notranslate"><span class="pre">Pack</span></code> and <a class="reference internal" href="#tkinter.Misc" title="tkinter.Misc"><code class="xref py py-class docutils literal notranslate"><span class="pre">Misc</span></code></a> precede <code class="xref py py-class docutils literal notranslate"><span class="pre">Place</span></code> and
<code class="xref py py-class docutils literal notranslate"><span class="pre">Grid</span></code> in the method resolution order,
whatever manager actually manages the widget;
and <code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code>/<code class="xref py py-meth docutils literal notranslate"><span class="pre">config()</span></code> configure the widget’s options,
not its geometry.
Use the explicit <code class="docutils literal notranslate"><span class="pre">pack_*</span></code>, <code class="docutils literal notranslate"><span class="pre">grid_*</span></code> and <code class="docutils literal notranslate"><span class="pre">place_*</span></code> methods
(and <code class="docutils literal notranslate"><span class="pre">pack</span></code>, <code class="docutils literal notranslate"><span class="pre">grid</span></code>, <code class="docutils literal notranslate"><span class="pre">place</span></code> for geometry configuration)
to act on a specific geometry manager.</p>
</div>
<dl class="py method" id="tkinter.Pack.config">
<span id="tkinter.Pack.configure"></span><dt class="sig sig-object py" id="tkinter.Pack.pack_configure">
<span class="sig-name descname"><span class="pre">pack_configure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Pack.pack_configure" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Pack.pack">
<span class="sig-name descname"><span class="pre">pack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Pack.pack" title="Link to this definition">¶</a></dt>
<dd><p>Pack the widget inside its container, positioning it relative to the
siblings already packed there.
The supported options are:</p>
<dl class="simple">
<dt><em>side</em></dt><dd><p>Which side of the container to pack the widget against: <code class="docutils literal notranslate"><span class="pre">'top'</span></code> (the
default), <code class="docutils literal notranslate"><span class="pre">'bottom'</span></code>, <code class="docutils literal notranslate"><span class="pre">'left'</span></code> or <code class="docutils literal notranslate"><span class="pre">'right'</span></code>.</p>
</dd>
<dt><em>fill</em></dt><dd><p>Whether to stretch the widget to fill its parcel: <code class="docutils literal notranslate"><span class="pre">'none'</span></code> (the
default), <code class="docutils literal notranslate"><span class="pre">'x'</span></code>, <code class="docutils literal notranslate"><span class="pre">'y'</span></code> or <code class="docutils literal notranslate"><span class="pre">'both'</span></code>.</p>
</dd>
<dt><em>expand</em></dt><dd><p>Whether the widget should expand to consume any extra space in its
container (a boolean, default false).</p>
</dd>
<dt><em>anchor</em></dt><dd><p>Where to position the widget in its parcel when the parcel is larger
than the widget: an anchor such as <code class="docutils literal notranslate"><span class="pre">'n'</span></code> or <code class="docutils literal notranslate"><span class="pre">'sw'</span></code> (default
<code class="docutils literal notranslate"><span class="pre">'center'</span></code>).</p>
</dd>
<dt><em>ipadx</em>, <em>ipady</em></dt><dd><p>Internal padding added on the left and right (<em>ipadx</em>) or top and
bottom (<em>ipady</em>) of the widget, as a screen distance (default <code class="docutils literal notranslate"><span class="pre">0</span></code>).</p>
</dd>
<dt><em>padx</em>, <em>pady</em></dt><dd><p>External padding left on the left and right (<em>padx</em>) or top and bottom
(<em>pady</em>) of the widget, as a screen distance or a pair of two
distances for the two sides (default <code class="docutils literal notranslate"><span class="pre">0</span></code>).</p>
</dd>
<dt><em>after</em></dt><dd><p>Pack the widget after the given widget in the packing order, using the
same container.</p>
</dd>
<dt><em>before</em></dt><dd><p>Pack the widget before the given widget in the packing order, using
the same container.</p>
</dd>
<dt><em>in_</em></dt><dd><p>The container in which to pack the widget; it defaults to the parent
widget.</p>
</dd>
</dl>
<p><code class="xref py py-meth docutils literal notranslate"><span class="pre">pack()</span></code>, <a class="reference internal" href="#tkinter.Pack.configure" title="tkinter.Pack.configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code></a> and <a class="reference internal" href="#tkinter.Pack.config" title="tkinter.Pack.config"><code class="xref py py-meth docutils literal notranslate"><span class="pre">config()</span></code></a> are aliases of
<code class="xref py py-meth docutils literal notranslate"><span class="pre">pack_configure()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Pack.forget">
<dt class="sig sig-object py" id="tkinter.Pack.pack_forget">
<span class="sig-name descname"><span class="pre">pack_forget</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Pack.pack_forget" title="Link to this definition">¶</a></dt>
<dd><p>Unmap the widget and remove it from the packing order, forgetting its
packing options.
It can be packed again later with <a class="reference internal" href="#tkinter.Pack.pack_configure" title="tkinter.Pack.pack_configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pack_configure()</span></code></a>.
<a class="reference internal" href="#tkinter.Pack.forget" title="tkinter.Pack.forget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">forget()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">pack_forget()</span></code>,
except on <a class="reference internal" href="#tkinter.PanedWindow" title="tkinter.PanedWindow"><code class="xref py py-class docutils literal notranslate"><span class="pre">PanedWindow</span></code></a>,
<a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.Notebook" title="tkinter.ttk.Notebook"><code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Notebook</span></code></a> and
<a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.PanedWindow" title="tkinter.ttk.PanedWindow"><code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.PanedWindow</span></code></a>,
which provide their own <code class="xref py py-meth docutils literal notranslate"><span class="pre">forget()</span></code> method.</p>
<p>Not to be confused with <a class="reference internal" href="#tkinter.Wm.forget" title="tkinter.Wm.forget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Wm.forget()</span></code></a>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Pack.info">
<dt class="sig sig-object py" id="tkinter.Pack.pack_info">
<span class="sig-name descname"><span class="pre">pack_info</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Pack.pack_info" title="Link to this definition">¶</a></dt>
<dd><p>Return a dictionary of the widget’s current packing options.
<a class="reference internal" href="#tkinter.Pack.info" title="tkinter.Pack.info"><code class="xref py py-meth docutils literal notranslate"><span class="pre">info()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">pack_info()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Pack.propagate">
<dt class="sig sig-object py" id="tkinter.Pack.pack_propagate">
<span class="sig-name descname"><span class="pre">pack_propagate</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Pack.pack_propagate" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">pack_propagate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">flag</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.pack_propagate" title="tkinter.Misc.pack_propagate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.pack_propagate()</span></code></a>, treating this widget as a container:
enable or disable geometry propagation.
<a class="reference internal" href="#tkinter.Pack.propagate" title="tkinter.Pack.propagate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">propagate()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">pack_propagate()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Pack.slaves">
<dt class="sig sig-object py" id="tkinter.Pack.pack_slaves">
<span class="sig-name descname"><span class="pre">pack_slaves</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Pack.pack_slaves" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.pack_slaves" title="tkinter.Misc.pack_slaves"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.pack_slaves()</span></code></a>: return the list of widgets packed in
this widget.
<a class="reference internal" href="#tkinter.Pack.slaves" title="tkinter.Pack.slaves"><code class="xref py py-meth docutils literal notranslate"><span class="pre">slaves()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">pack_slaves()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Pack.content">
<dt class="sig sig-object py" id="tkinter.Pack.pack_content">
<span class="sig-name descname"><span class="pre">pack_content</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Pack.pack_content" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.pack_content" title="tkinter.Misc.pack_content"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.pack_content()</span></code></a>.
<a class="reference internal" href="#tkinter.Pack.content" title="tkinter.Pack.content"><code class="xref py py-meth docutils literal notranslate"><span class="pre">content()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">pack_content()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15.</span></p>
</div>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Place">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Place</span></span><a class="headerlink" href="#tkinter.Place" title="Link to this definition">¶</a></dt>
<dd><p>Geometry manager that places widgets at explicit positions and sizes within
their container.
The <code class="xref py py-class docutils literal notranslate"><span class="pre">Place</span></code> mix-in is inherited by all widgets (through
<a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>).
See also <a class="reference internal" href="#tkinter-geometry-management"><span class="std std-ref">Geometry management</span></a>.</p>
<dl class="py method" id="tkinter.Place.config">
<span id="tkinter.Place.configure"></span><dt class="sig sig-object py" id="tkinter.Place.place_configure">
<span class="sig-name descname"><span class="pre">place_configure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Place.place_configure" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Place.place">
<span class="sig-name descname"><span class="pre">place</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Place.place" title="Link to this definition">¶</a></dt>
<dd><p>Place the widget inside its container at an absolute or relative
position.
The supported options are:</p>
<dl class="simple">
<dt><em>x</em>, <em>y</em></dt><dd><p>The absolute horizontal and vertical position of the widget’s anchor
point, as a screen distance (default <code class="docutils literal notranslate"><span class="pre">0</span></code>).</p>
</dd>
<dt><em>relx</em>, <em>rely</em></dt><dd><p>The horizontal and vertical position of the widget’s anchor point as a
fraction of the container’s width and height, where <code class="docutils literal notranslate"><span class="pre">0.0</span></code> is the
left or top edge and <code class="docutils literal notranslate"><span class="pre">1.0</span></code> is the right or bottom edge.
If both the absolute and the relative option are given, their values
are summed.</p>
</dd>
<dt><em>anchor</em></dt><dd><p>Which point of the widget is placed at the given position: an anchor
such as <code class="docutils literal notranslate"><span class="pre">'n'</span></code> or <code class="docutils literal notranslate"><span class="pre">'se'</span></code> (default <code class="docutils literal notranslate"><span class="pre">'nw'</span></code>).</p>
</dd>
<dt><em>width</em>, <em>height</em></dt><dd><p>The absolute width and height of the widget, as a screen distance.
By default the widget’s requested size is used.</p>
</dd>
<dt><em>relwidth</em>, <em>relheight</em></dt><dd><p>The width and height of the widget as a fraction of the container’s
width and height.
If both the absolute and the relative option are given, their values
are summed.</p>
</dd>
<dt><em>bordermode</em></dt><dd><p>How the container’s border affects placement: <code class="docutils literal notranslate"><span class="pre">'inside'</span></code> (the
default) measures the area inside the border, <code class="docutils literal notranslate"><span class="pre">'outside'</span></code> measures
the area including the border, and <code class="docutils literal notranslate"><span class="pre">'ignore'</span></code> uses the official X
area.</p>
</dd>
<dt><em>in_</em></dt><dd><p>The container relative to which the widget is placed; it must be the
widget’s parent or a descendant of the parent, and defaults to the
parent.</p>
</dd>
</dl>
<p><code class="xref py py-meth docutils literal notranslate"><span class="pre">place()</span></code>, <a class="reference internal" href="#tkinter.Place.configure" title="tkinter.Place.configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code></a> and <a class="reference internal" href="#tkinter.Place.config" title="tkinter.Place.config"><code class="xref py py-meth docutils literal notranslate"><span class="pre">config()</span></code></a> are aliases of
<code class="xref py py-meth docutils literal notranslate"><span class="pre">place_configure()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Place.forget">
<dt class="sig sig-object py" id="tkinter.Place.place_forget">
<span class="sig-name descname"><span class="pre">place_forget</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Place.place_forget" title="Link to this definition">¶</a></dt>
<dd><p>Unmap the widget and remove it from the placement, forgetting its place
options.</p>
</dd></dl>
<dl class="py method" id="tkinter.Place.info">
<dt class="sig sig-object py" id="tkinter.Place.place_info">
<span class="sig-name descname"><span class="pre">place_info</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Place.place_info" title="Link to this definition">¶</a></dt>
<dd><p>Return a dictionary of the widget’s current place options.</p>
</dd></dl>
<dl class="py method" id="tkinter.Place.slaves">
<dt class="sig sig-object py" id="tkinter.Place.place_slaves">
<span class="sig-name descname"><span class="pre">place_slaves</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Place.place_slaves" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.place_slaves" title="tkinter.Misc.place_slaves"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.place_slaves()</span></code></a>: return the list of widgets placed in
this widget.</p>
</dd></dl>
<dl class="py method" id="tkinter.Place.content">
<dt class="sig sig-object py" id="tkinter.Place.place_content">
<span class="sig-name descname"><span class="pre">place_content</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Place.place_content" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.place_content" title="tkinter.Misc.place_content"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.place_content()</span></code></a>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15.</span></p>
</div>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Grid">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Grid</span></span><a class="headerlink" href="#tkinter.Grid" title="Link to this definition">¶</a></dt>
<dd><p>Geometry manager that arranges widgets in a two-dimensional grid of rows and
columns within their container.
The <code class="xref py py-class docutils literal notranslate"><span class="pre">Grid</span></code> mix-in is inherited by all widgets (through
<a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>).
See also <a class="reference internal" href="#tkinter-geometry-management"><span class="std std-ref">Geometry management</span></a>.</p>
<dl class="py method" id="tkinter.Grid.config">
<span id="tkinter.Grid.configure"></span><dt class="sig sig-object py" id="tkinter.Grid.grid_configure">
<span class="sig-name descname"><span class="pre">grid_configure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Grid.grid_configure" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Grid.grid">
<span class="sig-name descname"><span class="pre">grid</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Grid.grid" title="Link to this definition">¶</a></dt>
<dd><p>Position the widget in a cell of its container’s grid.</p>
<p>Not to be confused with <a class="reference internal" href="#tkinter.Wm.grid" title="tkinter.Wm.grid"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Wm.grid()</span></code></a>.</p>
<p>The supported options are:</p>
<dl class="simple">
<dt><em>row</em>, <em>column</em></dt><dd><p>The row and column of the cell to place the widget in, counting from
<code class="docutils literal notranslate"><span class="pre">0</span></code>.
<em>column</em> defaults to the column after the previous widget placed in
the same <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_configure()</span></code> call (or <code class="docutils literal notranslate"><span class="pre">0</span></code>), and <em>row</em> defaults
to the next empty row.</p>
</dd>
<dt><em>rowspan</em>, <em>columnspan</em></dt><dd><p>The number of rows and columns the widget should span (default <code class="docutils literal notranslate"><span class="pre">1</span></code>).</p>
</dd>
<dt><em>sticky</em></dt><dd><p>How to position or stretch the widget when its cell is larger than the
widget: a string containing zero or more of the characters <code class="docutils literal notranslate"><span class="pre">'n'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'s'</span></code>, <code class="docutils literal notranslate"><span class="pre">'e'</span></code> and <code class="docutils literal notranslate"><span class="pre">'w'</span></code>, naming the cell sides the widget sticks
to.
Specifying both <code class="docutils literal notranslate"><span class="pre">'n'</span></code> and <code class="docutils literal notranslate"><span class="pre">'s'</span></code> (or <code class="docutils literal notranslate"><span class="pre">'e'</span></code> and <code class="docutils literal notranslate"><span class="pre">'w'</span></code>) stretches
the widget to fill the height (or width) of the cell.
The default is <code class="docutils literal notranslate"><span class="pre">''</span></code>, which centers the widget at its requested size.</p>
</dd>
<dt><em>ipadx</em>, <em>ipady</em></dt><dd><p>Internal padding added on the left and right (<em>ipadx</em>) or top and
bottom (<em>ipady</em>) of the widget, as a screen distance (default <code class="docutils literal notranslate"><span class="pre">0</span></code>).</p>
</dd>
<dt><em>padx</em>, <em>pady</em></dt><dd><p>External padding left on the left and right (<em>padx</em>) or top and bottom
(<em>pady</em>) of the widget, as a screen distance or a pair of two
distances for the two sides (default <code class="docutils literal notranslate"><span class="pre">0</span></code>).</p>
</dd>
<dt><em>in_</em></dt><dd><p>The container in whose grid to place the widget; it defaults to the
parent widget.</p>
</dd>
</dl>
<p><code class="xref py py-meth docutils literal notranslate"><span class="pre">grid()</span></code>, <a class="reference internal" href="#tkinter.Grid.configure" title="tkinter.Grid.configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code></a> and <a class="reference internal" href="#tkinter.Grid.config" title="tkinter.Grid.config"><code class="xref py py-meth docutils literal notranslate"><span class="pre">config()</span></code></a> are aliases of
<code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_configure()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Grid.forget">
<dt class="sig sig-object py" id="tkinter.Grid.grid_forget">
<span class="sig-name descname"><span class="pre">grid_forget</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Grid.grid_forget" title="Link to this definition">¶</a></dt>
<dd><p>Unmap the widget and remove it from the grid, forgetting its grid
options.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Grid.grid_remove">
<span class="sig-name descname"><span class="pre">grid_remove</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Grid.grid_remove" title="Link to this definition">¶</a></dt>
<dd><p>Unmap the widget and remove it from the grid, but remember its grid
options so that it is restored to the same cell if it is gridded again.</p>
</dd></dl>
<dl class="py method" id="tkinter.Grid.info">
<dt class="sig sig-object py" id="tkinter.Grid.grid_info">
<span class="sig-name descname"><span class="pre">grid_info</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Grid.grid_info" title="Link to this definition">¶</a></dt>
<dd><p>Return a dictionary of the widget’s current grid options.</p>
</dd></dl>
<dl class="py method" id="tkinter.Grid.bbox">
<dt class="sig sig-object py" id="tkinter.Grid.grid_bbox">
<span class="sig-name descname"><span class="pre">grid_bbox</span></span><span class="sig-paren">(</span><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">row</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">col2</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">row2</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.Grid.grid_bbox" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.grid_bbox" title="tkinter.Misc.grid_bbox"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.grid_bbox()</span></code></a>.
<a class="reference internal" href="#tkinter.Grid.bbox" title="tkinter.Grid.bbox"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bbox()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_bbox()</span></code>,
except on <a class="reference internal" href="#tkinter.Canvas" title="tkinter.Canvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code></a>, <a class="reference internal" href="#tkinter.Listbox" title="tkinter.Listbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Listbox</span></code></a>, <a class="reference internal" href="#tkinter.Spinbox" title="tkinter.Spinbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Spinbox</span></code></a>,
<a class="reference internal" href="#tkinter.Text" title="tkinter.Text"><code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code></a>, <a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.Entry" title="tkinter.ttk.Entry"><code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Entry</span></code></a> and
<a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.Treeview" title="tkinter.ttk.Treeview"><code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Treeview</span></code></a>,
which provide their own <code class="xref py py-meth docutils literal notranslate"><span class="pre">bbox()</span></code> method.</p>
</dd></dl>
<dl class="py method" id="tkinter.Grid.columnconfigure">
<dt class="sig sig-object py" id="tkinter.Grid.grid_columnconfigure">
<span class="sig-name descname"><span class="pre">grid_columnconfigure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Grid.grid_columnconfigure" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.grid_columnconfigure" title="tkinter.Misc.grid_columnconfigure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.grid_columnconfigure()</span></code></a>: query or set the options (such
as <em>weight</em>, <em>minsize</em>, <em>pad</em> and <em>uniform</em>) of a grid column.
<a class="reference internal" href="#tkinter.Grid.columnconfigure" title="tkinter.Grid.columnconfigure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">columnconfigure()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_columnconfigure()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Grid.rowconfigure">
<dt class="sig sig-object py" id="tkinter.Grid.grid_rowconfigure">
<span class="sig-name descname"><span class="pre">grid_rowconfigure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Grid.grid_rowconfigure" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.grid_rowconfigure" title="tkinter.Misc.grid_rowconfigure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.grid_rowconfigure()</span></code></a>: query or set the options of a
grid row.
<a class="reference internal" href="#tkinter.Grid.rowconfigure" title="tkinter.Grid.rowconfigure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">rowconfigure()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_rowconfigure()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Grid.location">
<dt class="sig sig-object py" id="tkinter.Grid.grid_location">
<span class="sig-name descname"><span class="pre">grid_location</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.Grid.grid_location" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.grid_location" title="tkinter.Misc.grid_location"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.grid_location()</span></code></a>: return the <code class="docutils literal notranslate"><span class="pre">(column,</span> <span class="pre">row)</span></code> of the
cell that covers the pixel at <em>x</em>, <em>y</em>.
<a class="reference internal" href="#tkinter.Grid.location" title="tkinter.Grid.location"><code class="xref py py-meth docutils literal notranslate"><span class="pre">location()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_location()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Grid.size">
<dt class="sig sig-object py" id="tkinter.Grid.grid_size">
<span class="sig-name descname"><span class="pre">grid_size</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Grid.grid_size" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.grid_size" title="tkinter.Misc.grid_size"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.grid_size()</span></code></a>: return a <code class="docutils literal notranslate"><span class="pre">(columns,</span> <span class="pre">rows)</span></code> tuple giving
the size of the grid.
<a class="reference internal" href="#tkinter.Grid.size" title="tkinter.Grid.size"><code class="xref py py-meth docutils literal notranslate"><span class="pre">size()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_size()</span></code>,
except on the <a class="reference internal" href="#tkinter.Listbox" title="tkinter.Listbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Listbox</span></code></a> widget,
which provides its own <code class="xref py py-meth docutils literal notranslate"><span class="pre">size()</span></code> method.</p>
</dd></dl>
<dl class="py method" id="tkinter.Grid.propagate">
<dt class="sig sig-object py" id="tkinter.Grid.grid_propagate">
<span class="sig-name descname"><span class="pre">grid_propagate</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Grid.grid_propagate" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">grid_propagate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">flag</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.grid_propagate" title="tkinter.Misc.grid_propagate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.grid_propagate()</span></code></a>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Grid.slaves">
<dt class="sig sig-object py" id="tkinter.Grid.grid_slaves">
<span class="sig-name descname"><span class="pre">grid_slaves</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">row</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">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.Grid.grid_slaves" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.grid_slaves" title="tkinter.Misc.grid_slaves"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.grid_slaves()</span></code></a>: return the widgets managed in the grid,
optionally restricted to a <em>row</em> and/or <em>column</em>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Grid.content">
<dt class="sig sig-object py" id="tkinter.Grid.grid_content">
<span class="sig-name descname"><span class="pre">grid_content</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">row</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">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.Grid.grid_content" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Misc.grid_content" title="tkinter.Misc.grid_content"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.grid_content()</span></code></a>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15.</span></p>
</div>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.XView">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">XView</span></span><a class="headerlink" href="#tkinter.XView" title="Link to this definition">¶</a></dt>
<dd><p>Mix-in providing the horizontal-scrolling interface shared by widgets such
as <a class="reference internal" href="#tkinter.Entry" title="tkinter.Entry"><code class="xref py py-class docutils literal notranslate"><span class="pre">Entry</span></code></a>, <a class="reference internal" href="#tkinter.Canvas" title="tkinter.Canvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code></a>, <a class="reference internal" href="#tkinter.Listbox" title="tkinter.Listbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Listbox</span></code></a>, <a class="reference internal" href="#tkinter.Text" title="tkinter.Text"><code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code></a> and
<a class="reference internal" href="#tkinter.Spinbox" title="tkinter.Spinbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Spinbox</span></code></a>.
A widget’s <a class="reference internal" href="#tkinter.XView.xview" title="tkinter.XView.xview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">xview()</span></code></a> method is registered as the <em>command</em> of a
horizontal <a class="reference internal" href="#tkinter.Scrollbar" title="tkinter.Scrollbar"><code class="xref py py-class docutils literal notranslate"><span class="pre">Scrollbar</span></code></a>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.XView.xview">
<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.XView.xview" title="Link to this definition">¶</a></dt>
<dd><p>Query or change the horizontal position of the view.
With no arguments, return a tuple <code class="docutils literal notranslate"><span class="pre">(first,</span> <span class="pre">last)</span></code> of two fractions
between 0 and 1 giving the portion of the document that is currently
visible.
Otherwise the arguments are passed to the Tk <code class="docutils literal notranslate"><span class="pre">xview</span></code> widget command and
are usually generated by a scrollbar; <a class="reference internal" href="#tkinter.XView.xview_moveto" title="tkinter.XView.xview_moveto"><code class="xref py py-meth docutils literal notranslate"><span class="pre">xview_moveto()</span></code></a> and
<a class="reference internal" href="#tkinter.XView.xview_scroll" title="tkinter.XView.xview_scroll"><code class="xref py py-meth docutils literal notranslate"><span class="pre">xview_scroll()</span></code></a> provide a more convenient interface.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.XView.xview_moveto">
<span class="sig-name descname"><span class="pre">xview_moveto</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fraction</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.XView.xview_moveto" title="Link to this definition">¶</a></dt>
<dd><p>Adjust the view so that <em>fraction</em> of the total width of the document is
off-screen to the left.
<em>fraction</em> is a number between 0 and 1.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.XView.xview_scroll">
<span class="sig-name descname"><span class="pre">xview_scroll</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">number</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">what</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.XView.xview_scroll" title="Link to this definition">¶</a></dt>
<dd><p>Shift the view left or right by <em>number</em> units.
<em>what</em> is either <code class="docutils literal notranslate"><span class="pre">'units'</span></code> or <code class="docutils literal notranslate"><span class="pre">'pages'</span></code>; a negative <em>number</em> scrolls
left and a positive one scrolls right.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.YView">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">YView</span></span><a class="headerlink" href="#tkinter.YView" title="Link to this definition">¶</a></dt>
<dd><p>Mix-in providing the vertical-scrolling interface shared by widgets such as
<a class="reference internal" href="#tkinter.Canvas" title="tkinter.Canvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code></a>, <a class="reference internal" href="#tkinter.Listbox" title="tkinter.Listbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Listbox</span></code></a> and <a class="reference internal" href="#tkinter.Text" title="tkinter.Text"><code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code></a>.
A widget’s <a class="reference internal" href="#tkinter.YView.yview" title="tkinter.YView.yview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">yview()</span></code></a> method is registered as the <em>command</em> of a vertical
<a class="reference internal" href="#tkinter.Scrollbar" title="tkinter.Scrollbar"><code class="xref py py-class docutils literal notranslate"><span class="pre">Scrollbar</span></code></a>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.YView.yview">
<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.YView.yview" title="Link to this definition">¶</a></dt>
<dd><p>Query or change the vertical position of the view.
With no arguments, return a tuple <code class="docutils literal notranslate"><span class="pre">(first,</span> <span class="pre">last)</span></code> of two fractions
between 0 and 1 giving the portion of the document that is currently
visible.
Otherwise the arguments are passed to the Tk <code class="docutils literal notranslate"><span class="pre">yview</span></code> widget command,
usually generated by a scrollbar; <a class="reference internal" href="#tkinter.YView.yview_moveto" title="tkinter.YView.yview_moveto"><code class="xref py py-meth docutils literal notranslate"><span class="pre">yview_moveto()</span></code></a> and
<a class="reference internal" href="#tkinter.YView.yview_scroll" title="tkinter.YView.yview_scroll"><code class="xref py py-meth docutils literal notranslate"><span class="pre">yview_scroll()</span></code></a> provide a more convenient interface.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.YView.yview_moveto">
<span class="sig-name descname"><span class="pre">yview_moveto</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fraction</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.YView.yview_moveto" title="Link to this definition">¶</a></dt>
<dd><p>Adjust the view so that <em>fraction</em> of the total height of the document is
off-screen above the top.
<em>fraction</em> is a number between 0 and 1.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.YView.yview_scroll">
<span class="sig-name descname"><span class="pre">yview_scroll</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">number</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">what</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.YView.yview_scroll" title="Link to this definition">¶</a></dt>
<dd><p>Shift the view up or down by <em>number</em> units.
<em>what</em> is either <code class="docutils literal notranslate"><span class="pre">'units'</span></code> or <code class="docutils literal notranslate"><span class="pre">'pages'</span></code>; a negative <em>number</em> scrolls
up and a positive one scrolls down.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.BaseWidget">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">BaseWidget</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">widgetName</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kw</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">extra</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.BaseWidget" title="Link to this definition">¶</a></dt>
<dd><p>Internal base class for all widgets.
It inherits from <a class="reference internal" href="#tkinter.Misc" title="tkinter.Misc"><code class="xref py py-class docutils literal notranslate"><span class="pre">Misc</span></code></a> and adds the machinery that creates the
underlying Tk widget; application code normally uses <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a> or a
concrete widget class rather than instantiating <code class="xref py py-class docutils literal notranslate"><span class="pre">BaseWidget</span></code>
directly.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.BaseWidget.destroy">
<span class="sig-name descname"><span class="pre">destroy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.BaseWidget.destroy" title="Link to this definition">¶</a></dt>
<dd><p>Destroy this widget and all of its children, removing the corresponding
Tk widgets and deleting the associated Tcl commands.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Widget">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Widget</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">widgetName</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kw</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">extra</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Widget" title="Link to this definition">¶</a></dt>
<dd><p>Internal base class for the standard widgets.
It combines <a class="reference internal" href="#tkinter.BaseWidget" title="tkinter.BaseWidget"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseWidget</span></code></a> with the geometry-manager mix-ins
<a class="reference internal" href="#tkinter.Pack" title="tkinter.Pack"><code class="xref py py-class docutils literal notranslate"><span class="pre">Pack</span></code></a>, <a class="reference internal" href="#tkinter.Place" title="tkinter.Place"><code class="xref py py-class docutils literal notranslate"><span class="pre">Place</span></code></a> and <a class="reference internal" href="#tkinter.Grid" title="tkinter.Grid"><code class="xref py py-class docutils literal notranslate"><span class="pre">Grid</span></code></a>, so that every widget can be
managed by any of the three geometry managers.
The concrete widget classes (<a class="reference internal" href="#tkinter.Button" title="tkinter.Button"><code class="xref py py-class docutils literal notranslate"><span class="pre">Button</span></code></a>, <a class="reference internal" href="#tkinter.Label" title="tkinter.Label"><code class="xref py py-class docutils literal notranslate"><span class="pre">Label</span></code></a>, and so on)
derive from <code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code>.</p>
</dd></dl>
</section>
<section id="toplevel-widgets">
<h3>Toplevel widgets<a class="headerlink" href="#toplevel-widgets" title="Link to this heading">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Tk">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Tk</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">screenName</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">baseName</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">className</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'Tk'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">useTk</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sync</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use</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.Tk" title="Link to this definition">¶</a></dt>
<dd><p>Construct a toplevel Tk widget, which is usually the main window of an
application, and initialize a Tcl interpreter for this widget. Each
instance has its own associated Tcl interpreter.
Inherits from <a class="reference internal" href="#tkinter.Misc" title="tkinter.Misc"><code class="xref py py-class docutils literal notranslate"><span class="pre">Misc</span></code></a> and <a class="reference internal" href="#tkinter.Wm" title="tkinter.Wm"><code class="xref py py-class docutils literal notranslate"><span class="pre">Wm</span></code></a>.</p>
<p>To create a Tcl interpreter without initializing the Tk subsystem, use the
<a class="reference internal" href="#tkinter.Tcl" title="tkinter.Tcl"><code class="xref py py-func docutils literal notranslate"><span class="pre">Tcl()</span></code></a> factory function instead.</p>
<p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code> class is typically instantiated using all default values.
However, the following keyword arguments are currently recognized:</p>
<dl>
<dt><em>screenName</em></dt><dd><p>When given (as a string), sets the <span class="target" id="index-4"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">DISPLAY</span></code> environment
variable. (X11 only)</p>
</dd>
<dt><em>baseName</em></dt><dd><p>Name of the profile file. By default, <em>baseName</em> is derived from the
program name (<code class="docutils literal notranslate"><span class="pre">sys.argv[0]</span></code>).</p>
</dd>
<dt><em>className</em></dt><dd><p>Name of the widget class. Used as a profile file and also as the name
with which Tcl is invoked (<em>argv0</em> in <em>interp</em>).</p>
</dd>
<dt><em>useTk</em></dt><dd><p>If <code class="docutils literal notranslate"><span class="pre">True</span></code>, initialize the Tk subsystem. The <a class="reference internal" href="#tkinter.Tcl" title="tkinter.Tcl"><code class="xref py py-func docutils literal notranslate"><span class="pre">tkinter.Tcl()</span></code></a>
function sets this to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p>
</dd>
<dt><em>sync</em></dt><dd><p>If <code class="docutils literal notranslate"><span class="pre">True</span></code>, execute all X server commands synchronously, so that errors
are reported immediately. Can be used for debugging. (X11 only)</p>
</dd>
<dt><em>use</em></dt><dd><p>Specifies the <em>id</em> of the window in which to embed the application,
instead of it being created as an independent toplevel window. <em>id</em> must
be specified in the same way as the value for the -use option for
toplevel widgets (that is, it has a form like that returned by
<a class="reference internal" href="#tkinter.Misc.winfo_id" title="tkinter.Misc.winfo_id"><code class="xref py py-meth docutils literal notranslate"><span class="pre">winfo_id()</span></code></a>).</p>
<p>Note that on some platforms this will only work correctly if <em>id</em> refers
to a Tk frame or toplevel that has its -container option enabled.</p>
</dd>
</dl>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code> reads and interprets profile files, named
<code class="file docutils literal notranslate"><span class="pre">.</span><em><span class="pre">className</span></em><span class="pre">.tcl</span></code> and <code class="file docutils literal notranslate"><span class="pre">.</span><em><span class="pre">baseName</span></em><span class="pre">.tcl</span></code>, into the Tcl
interpreter and calls <a class="reference internal" href="functions.html#exec" title="exec"><code class="xref py py-func docutils literal notranslate"><span class="pre">exec()</span></code></a> on the contents of
<code class="file docutils literal notranslate"><span class="pre">.</span><em><span class="pre">className</span></em><span class="pre">.py</span></code> and <code class="file docutils literal notranslate"><span class="pre">.</span><em><span class="pre">baseName</span></em><span class="pre">.py</span></code>. The path for the
profile files is the <span class="target" id="index-5"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">HOME</span></code> environment variable or, if that
isn’t defined, then <a class="reference internal" href="os.html#os.curdir" title="os.curdir"><code class="xref py py-data docutils literal notranslate"><span class="pre">os.curdir</span></code></a>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>On Windows, creating a Tcl interpreter (by instantiating <code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code> or
calling <a class="reference internal" href="#tkinter.Tcl" title="tkinter.Tcl"><code class="xref py py-func docutils literal notranslate"><span class="pre">Tcl()</span></code></a>) sets the <span class="target" id="index-6"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">HOME</span></code> environment variable for
the process, if it is not already set, to <code class="docutils literal notranslate"><span class="pre">%HOMEDRIVE%%HOMEPATH%</span></code> (or
<span class="target" id="index-7"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">USERPROFILE</span></code>, or <code class="docutils literal notranslate"><span class="pre">c:\</span></code>). This is done by Tcl and can affect
other code that reads <span class="target" id="index-8"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">HOME</span></code>.</p>
</div>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Tk.tk">
<span class="sig-name descname"><span class="pre">tk</span></span><a class="headerlink" href="#tkinter.Tk.tk" title="Link to this definition">¶</a></dt>
<dd><p>The Tk application object created by instantiating <code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code>. This
provides access to the Tcl interpreter. Each widget that is attached
the same instance of <code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code> has the same value for its <a class="reference internal" href="#tkinter.Tk.tk" title="tkinter.Tk.tk"><code class="xref py py-attr docutils literal notranslate"><span class="pre">tk</span></code></a>
attribute.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Tk.master">
<span class="sig-name descname"><span class="pre">master</span></span><a class="headerlink" href="#tkinter.Tk.master" title="Link to this definition">¶</a></dt>
<dd><p>The widget object that contains this widget.
For <code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code>, the <code class="xref py py-attr docutils literal notranslate"><span class="pre">master</span></code> is <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a> because it is the
main window.
The terms <em>master</em> and <em>parent</em> are similar and sometimes used
interchangeably as argument names; however, calling
<a class="reference internal" href="#tkinter.Misc.winfo_parent" title="tkinter.Misc.winfo_parent"><code class="xref py py-meth docutils literal notranslate"><span class="pre">winfo_parent()</span></code></a> returns a string of the widget name whereas
<code class="xref py py-attr docutils literal notranslate"><span class="pre">master</span></code> returns the object.
<em>parent</em>/<em>child</em> reflects the tree-like relationship while <em>master</em> (or
<em>container</em>)/<em>content</em> reflects the container structure.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Tk.children">
<span class="sig-name descname"><span class="pre">children</span></span><a class="headerlink" href="#tkinter.Tk.children" title="Link to this definition">¶</a></dt>
<dd><p>The immediate descendants of this widget as a <a class="reference internal" href="stdtypes.html#dict" title="dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a> with the
child widget names as the keys and the child instance objects as the
values.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Tk.destroy">
<span class="sig-name descname"><span class="pre">destroy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Tk.destroy" title="Link to this definition">¶</a></dt>
<dd><p>Destroy this and all descendant widgets and, for the main window, end the
connection to the underlying Tcl interpreter.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Tk.loadtk">
<span class="sig-name descname"><span class="pre">loadtk</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Tk.loadtk" title="Link to this definition">¶</a></dt>
<dd><p>Finish loading and initializing the Tk subsystem.
This is needed only when the interpreter was created without Tk (for
example through <a class="reference internal" href="#tkinter.Tcl" title="tkinter.Tcl"><code class="xref py py-func docutils literal notranslate"><span class="pre">Tcl()</span></code></a>); it is called automatically when <em>useTk</em> is
true.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Tk.readprofile">
<span class="sig-name descname"><span class="pre">readprofile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">baseName</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">className</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Tk.readprofile" title="Link to this definition">¶</a></dt>
<dd><p>Read and source the user’s profile files <code class="file docutils literal notranslate"><span class="pre">.</span><em><span class="pre">className</span></em><span class="pre">.tcl</span></code> and
<code class="file docutils literal notranslate"><span class="pre">.</span><em><span class="pre">baseName</span></em><span class="pre">.tcl</span></code> into the Tcl interpreter, and execute the
corresponding <code class="file docutils literal notranslate"><span class="pre">.</span><em><span class="pre">className</span></em><span class="pre">.py</span></code> and <code class="file docutils literal notranslate"><span class="pre">.</span><em><span class="pre">baseName</span></em><span class="pre">.py</span></code> files.
This is called during initialization; see the description of the
constructor above.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Tk.report_callback_exception">
<span class="sig-name descname"><span class="pre">report_callback_exception</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">exc</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tb</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Tk.report_callback_exception" title="Link to this definition">¶</a></dt>
<dd><p>Report a callback exception.
This is called when an exception propagates out of a Tkinter callback;
<em>exc</em>, <em>val</em> and <em>tb</em> are the exception type, value and traceback as
returned by <a class="reference internal" href="sys.html#sys.exc_info" title="sys.exc_info"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.exc_info()</span></code></a>.
The default implementation prints a traceback to <a class="reference internal" href="sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stderr</span></code></a>.
It can be overridden to customize error handling, for example to display
the traceback in a dialog.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Toplevel">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Toplevel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Toplevel" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Toplevel</span></code> widget is a top-level window, similar to a
<a class="reference internal" href="#tkinter.Frame" title="tkinter.Frame"><code class="xref py py-class docutils literal notranslate"><span class="pre">Frame</span></code></a> except that its X parent is the root window of a screen
rather than its logical parent.
Its primary purpose is to serve as a container for dialog boxes and other
collections of widgets; its only visible features are its background and an
optional 3-D border.
Notable options include <em>menu</em>, which installs a <a class="reference internal" href="#tkinter.Menu" title="tkinter.Menu"><code class="xref py py-class docutils literal notranslate"><span class="pre">Menu</span></code></a> as the
window’s menubar.
Inherits from <a class="reference internal" href="#tkinter.BaseWidget" title="tkinter.BaseWidget"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseWidget</span></code></a> and <a class="reference internal" href="#tkinter.Wm" title="tkinter.Wm"><code class="xref py py-class docutils literal notranslate"><span class="pre">Wm</span></code></a>, so a toplevel is managed
by the window manager.
Refer to the Tk <code class="docutils literal notranslate"><span class="pre">toplevel</span></code> manual page for the full list of options.</p>
</dd></dl>
</section>
<section id="widget-classes">
<h3>Widget classes<a class="headerlink" href="#widget-classes" title="Link to this heading">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Button">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Button</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Button" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Button</span></code> widget displays a textual string, bitmap or image and
invokes a command when the user presses it (by clicking mouse button 1 over
the button or, when the button has focus, by pressing the space key).
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.
In addition to the standard widget options, a button accepts the options
documented in the Tk <code class="docutils literal notranslate"><span class="pre">button</span></code> manual page, such as <em>command</em> (the callback
invoked when the button is pressed), <em>textvariable</em>, <em>state</em> and <em>default</em>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Button.invoke">
<span class="sig-name descname"><span class="pre">invoke</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Button.invoke" title="Link to this definition">¶</a></dt>
<dd><p>Invoke the command associated with the button, if there is one, and
return its result, or an empty string if no command is associated with
the button.
This is ignored if the button’s state is <code class="docutils literal notranslate"><span class="pre">disabled</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Button.flash">
<span class="sig-name descname"><span class="pre">flash</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Button.flash" title="Link to this definition">¶</a></dt>
<dd><p>Flash the button by redisplaying it several times, alternating between
the active and normal colors.
At the end of the flash the button is left in the same normal or active
state as when the method was called.
This is ignored if the button’s state is <code class="docutils literal notranslate"><span class="pre">disabled</span></code>.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Canvas">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Canvas</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Canvas" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code> widget implements structured graphics.
It displays any number of <em>items</em>, such as arcs, lines, ovals, polygons,
rectangles, text, bitmaps, images and embedded windows, which may be drawn,
moved, re-colored and bound to events.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>, <a class="reference internal" href="#tkinter.XView" title="tkinter.XView"><code class="xref py py-class docutils literal notranslate"><span class="pre">XView</span></code></a> and <a class="reference internal" href="#tkinter.YView" title="tkinter.YView"><code class="xref py py-class docutils literal notranslate"><span class="pre">YView</span></code></a>, so the
view can be scrolled horizontally and vertically with <a class="reference internal" href="#tkinter.XView.xview" title="tkinter.XView.xview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">xview()</span></code></a>
and <a class="reference internal" href="#tkinter.YView.yview" title="tkinter.YView.yview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">yview()</span></code></a>.
Refer to the Tk <code class="docutils literal notranslate"><span class="pre">canvas</span></code> manual page for the full list of widget and item
options.</p>
<p>Each item has a unique integer <em>id</em>, assigned when it is created, and zero
or more string <em>tags</em>.
A tag is an arbitrary string that does not have the form of an integer; the
same tag may be shared by many items, which makes tags convenient for
grouping items.
The special tag <code class="docutils literal notranslate"><span class="pre">'all'</span></code> matches every item in the canvas, and
<code class="docutils literal notranslate"><span class="pre">'current'</span></code> matches the topmost item under the mouse pointer.
Most methods take a <em>tagOrId</em> argument that may be an integer id naming a
single item, or a tag naming zero or more items; as described in the Tk
<code class="docutils literal notranslate"><span class="pre">canvas</span></code> manual page, a tag may also be a logical expression of tags
combined with the operators <code class="docutils literal notranslate"><span class="pre">&&</span></code>, <code class="docutils literal notranslate"><span class="pre">||</span></code>, <code class="docutils literal notranslate"><span class="pre">^</span></code>, <code class="docutils literal notranslate"><span class="pre">!</span></code> and parentheses.
When a method that operates on a single item is given a <em>tagOrId</em> matching
several items, it normally uses the lowest matching item in the display
list.</p>
<p>The items are kept in a <em>display list</em> that determines drawing order: items
later in the list are drawn on top of earlier ones.
A newly created item is placed at the top of the list; the order can be
changed with <a class="reference internal" href="#tkinter.Canvas.tag_raise" title="tkinter.Canvas.tag_raise"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tag_raise()</span></code></a> and <a class="reference internal" href="#tkinter.Canvas.tag_lower" title="tkinter.Canvas.tag_lower"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tag_lower()</span></code></a>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.create_arc">
<span class="sig-name descname"><span class="pre">create_arc</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>, <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.Canvas.create_arc" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Canvas.create_bitmap">
<span class="sig-name descname"><span class="pre">create_bitmap</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>, <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.Canvas.create_bitmap" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Canvas.create_image">
<span class="sig-name descname"><span class="pre">create_image</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>, <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.Canvas.create_image" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Canvas.create_line">
<span class="sig-name descname"><span class="pre">create_line</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>, <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.Canvas.create_line" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Canvas.create_oval">
<span class="sig-name descname"><span class="pre">create_oval</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>, <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.Canvas.create_oval" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Canvas.create_polygon">
<span class="sig-name descname"><span class="pre">create_polygon</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>, <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.Canvas.create_polygon" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Canvas.create_rectangle">
<span class="sig-name descname"><span class="pre">create_rectangle</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>, <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.Canvas.create_rectangle" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Canvas.create_text">
<span class="sig-name descname"><span class="pre">create_text</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>, <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.Canvas.create_text" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Canvas.create_window">
<span class="sig-name descname"><span class="pre">create_window</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>, <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.Canvas.create_window" title="Link to this definition">¶</a></dt>
<dd><p>Create a new item of the corresponding type and return its integer id.
Each method is called as <code class="docutils literal notranslate"><span class="pre">create_TYPE(coord...,</span> <span class="pre">**options)</span></code>: the
leading positional arguments give the coordinates that define the item
(as separate numbers, as a single sequence of numbers, or as coordinate
pairs), and the keyword arguments set item-specific options.
Coordinates and screen distances may be given as numbers (interpreted as
pixels) or as strings with a unit suffix (<code class="docutils literal notranslate"><span class="pre">'m'</span></code>, <code class="docutils literal notranslate"><span class="pre">'c'</span></code>, <code class="docutils literal notranslate"><span class="pre">'i'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'p'</span></code> for millimetres, centimetres, inches or printer’s points), but
are always stored and returned in pixels.</p>
<p>The item types are: <code class="docutils literal notranslate"><span class="pre">arc</span></code> (an arc-shaped region that is a section of an
oval, defined by two diagonally opposite corners <code class="docutils literal notranslate"><span class="pre">x1,</span> <span class="pre">y1,</span> <span class="pre">x2,</span> <span class="pre">y2</span></code> of
the enclosing rectangle); <code class="docutils literal notranslate"><span class="pre">bitmap</span></code> (a two-color bitmap positioned at a
point <code class="docutils literal notranslate"><span class="pre">x,</span> <span class="pre">y</span></code>); <code class="docutils literal notranslate"><span class="pre">image</span></code> (a Tk image positioned at a point <code class="docutils literal notranslate"><span class="pre">x,</span> <span class="pre">y</span></code>);
<code class="docutils literal notranslate"><span class="pre">line</span></code> (a line or curve through the points <code class="docutils literal notranslate"><span class="pre">x1,</span> <span class="pre">y1,</span> <span class="pre">...,</span> <span class="pre">xn,</span> <span class="pre">yn</span></code>);
<code class="docutils literal notranslate"><span class="pre">oval</span></code> (a circle or ellipse inscribed in the rectangle
<code class="docutils literal notranslate"><span class="pre">x1,</span> <span class="pre">y1,</span> <span class="pre">x2,</span> <span class="pre">y2</span></code>); <code class="docutils literal notranslate"><span class="pre">polygon</span></code> (a closed polygon through the points
<code class="docutils literal notranslate"><span class="pre">x1,</span> <span class="pre">y1,</span> <span class="pre">...,</span> <span class="pre">xn,</span> <span class="pre">yn</span></code>); <code class="docutils literal notranslate"><span class="pre">rectangle</span></code> (a rectangle with corners
<code class="docutils literal notranslate"><span class="pre">x1,</span> <span class="pre">y1,</span> <span class="pre">x2,</span> <span class="pre">y2</span></code>); <code class="docutils literal notranslate"><span class="pre">text</span></code> (a string of text positioned at a point
<code class="docutils literal notranslate"><span class="pre">x,</span> <span class="pre">y</span></code>); and <code class="docutils literal notranslate"><span class="pre">window</span></code> (a child widget embedded in the canvas at a
point <code class="docutils literal notranslate"><span class="pre">x,</span> <span class="pre">y</span></code>, specified with the <em>window</em> option).</p>
<p>Most item types accept a common set of <em>standard item options</em>, plus a
few options specific to each type.
Option names are passed as keyword arguments, without the leading
hyphen.</p>
<p>The standard item options are:</p>
<dl class="simple">
<dt><em>fill</em></dt><dd><p>The color used to fill the item’s interior, or to draw a <em>line</em>
item or the characters of a <em>text</em> item.
An empty string (the default for all types except <em>line</em> and <em>text</em>)
leaves the item unfilled.</p>
</dd>
<dt><em>outline</em></dt><dd><p>The color used to draw the item’s outline.
An empty string draws no outline.</p>
</dd>
<dt><em>width</em></dt><dd><p>The width of the outline, defaulting to <code class="docutils literal notranslate"><span class="pre">1.0</span></code>.
Has no effect if <em>outline</em> is empty.</p>
</dd>
<dt><em>dash</em></dt><dd><p>A dash pattern for the outline, given either as a sequence of
segment lengths in pixels or as a string of the characters
<code class="docutils literal notranslate"><span class="pre">'.'</span></code>, <code class="docutils literal notranslate"><span class="pre">','</span></code>, <code class="docutils literal notranslate"><span class="pre">'-'</span></code>, <code class="docutils literal notranslate"><span class="pre">'_'</span></code> and space.
An empty pattern (the default) draws a solid outline.</p>
</dd>
<dt><em>dashoffset</em></dt><dd><p>The starting offset in pixels into the <em>dash</em> pattern.
Ignored if there is no <em>dash</em> pattern.</p>
</dd>
<dt><em>stipple</em></dt><dd><p>A bitmap used as a stipple pattern when filling the item.
Only well supported on X11.</p>
</dd>
<dt><em>outlinestipple</em></dt><dd><p>A bitmap used as a stipple pattern when drawing the outline.
Has no effect if <em>outline</em> is empty.</p>
</dd>
<dt><em>offset</em>, <em>outlineoffset</em></dt><dd><p>The offset of the fill and outline stipple patterns, given as
<code class="docutils literal notranslate"><span class="pre">'x,y'</span></code> or as a side such as <code class="docutils literal notranslate"><span class="pre">'n'</span></code>, <code class="docutils literal notranslate"><span class="pre">'se'</span></code> or <code class="docutils literal notranslate"><span class="pre">'center'</span></code>.
Stipple offsets are only supported on X11.</p>
</dd>
<dt><em>state</em></dt><dd><p>Overrides the canvas state for this item; one of <code class="docutils literal notranslate"><span class="pre">'normal'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'disabled'</span></code> or <code class="docutils literal notranslate"><span class="pre">'hidden'</span></code>.</p>
</dd>
<dt><em>tags</em></dt><dd><p>A single tag or a sequence of tags to associate with the item,
replacing any existing tags.</p>
</dd>
</dl>
<p>Many of these options have <em>active…</em> and <em>disabled…</em> variants
(such as <em>activefill</em>, <em>disabledfill</em>, <em>activewidth</em>, <em>disableddash</em>,
<em>activeoutline</em>, <em>disabledstipple</em>) that override the base option when
the item is the active item (under the mouse pointer) or is in the
disabled state.</p>
<p>The following item types support additional options.</p>
<p>For <code class="docutils literal notranslate"><span class="pre">arc</span></code> items:</p>
<dl class="simple">
<dt><em>start</em></dt><dd><p>The start of the arc’s angular range, in degrees measured
counter-clockwise from the 3-o’clock position.</p>
</dd>
<dt><em>extent</em></dt><dd><p>The size of the angular range, in degrees counter-clockwise from
<em>start</em>.</p>
</dd>
<dt><em>style</em></dt><dd><p>How the arc is drawn: <code class="docutils literal notranslate"><span class="pre">'pieslice'</span></code> (the default), <code class="docutils literal notranslate"><span class="pre">'chord'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'arc'</span></code>.</p>
</dd>
</dl>
<p>For <code class="docutils literal notranslate"><span class="pre">line</span></code> items:</p>
<dl class="simple">
<dt><em>arrow</em></dt><dd><p>Where to draw arrowheads: <code class="docutils literal notranslate"><span class="pre">'none'</span></code> (the default), <code class="docutils literal notranslate"><span class="pre">'first'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'last'</span></code> or <code class="docutils literal notranslate"><span class="pre">'both'</span></code>.</p>
</dd>
<dt><em>arrowshape</em></dt><dd><p>A sequence of three distances describing the shape of the
arrowheads.</p>
</dd>
<dt><em>capstyle</em></dt><dd><p>How line ends are drawn: <code class="docutils literal notranslate"><span class="pre">'butt'</span></code> (the default), <code class="docutils literal notranslate"><span class="pre">'projecting'</span></code>
or <code class="docutils literal notranslate"><span class="pre">'round'</span></code>.</p>
</dd>
<dt><em>joinstyle</em></dt><dd><p>How line vertices are drawn: <code class="docutils literal notranslate"><span class="pre">'round'</span></code> (the default), <code class="docutils literal notranslate"><span class="pre">'bevel'</span></code>
or <code class="docutils literal notranslate"><span class="pre">'miter'</span></code>.</p>
</dd>
<dt><em>smooth</em></dt><dd><p>The smoothing method: a false value (the default) for no smoothing,
or <code class="docutils literal notranslate"><span class="pre">'true'</span></code>/<code class="docutils literal notranslate"><span class="pre">'bezier'</span></code> or <code class="docutils literal notranslate"><span class="pre">'raw'</span></code> to draw the line as a curve.</p>
</dd>
<dt><em>splinesteps</em></dt><dd><p>The number of line segments approximating each spline when
<em>smooth</em> is enabled.</p>
</dd>
</dl>
<p>For <code class="docutils literal notranslate"><span class="pre">polygon</span></code> items:</p>
<dl class="simple">
<dt><em>joinstyle</em>, <em>smooth</em>, <em>splinesteps</em></dt><dd><p>As for <code class="docutils literal notranslate"><span class="pre">line</span></code> items, applied to the polygon’s outline.</p>
</dd>
</dl>
<p>For <code class="docutils literal notranslate"><span class="pre">text</span></code> items:</p>
<dl class="simple">
<dt><em>text</em></dt><dd><p>The string to display; newline characters start new lines.</p>
</dd>
<dt><em>font</em></dt><dd><p>The font used for the text.</p>
</dd>
<dt><em>justify</em></dt><dd><p>How lines are justified: <code class="docutils literal notranslate"><span class="pre">'left'</span></code> (the default), <code class="docutils literal notranslate"><span class="pre">'right'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'center'</span></code>.</p>
</dd>
<dt><em>anchor</em></dt><dd><p>How the text is positioned relative to its point, defaulting to
<code class="docutils literal notranslate"><span class="pre">'center'</span></code>.</p>
</dd>
<dt><em>width</em></dt><dd><p>The maximum line length; if non-zero, lines are wrapped at spaces.</p>
</dd>
<dt><em>angle</em></dt><dd><p>How many degrees to rotate the text counter-clockwise about its
positioning point, from <code class="docutils literal notranslate"><span class="pre">0.0</span></code> to <code class="docutils literal notranslate"><span class="pre">360.0</span></code> (default <code class="docutils literal notranslate"><span class="pre">0.0</span></code>).</p>
</dd>
<dt><em>underline</em></dt><dd><p>The index of a character to underline, or <code class="docutils literal notranslate"><span class="pre">-1</span></code> for none.</p>
</dd>
</dl>
<p>For <code class="docutils literal notranslate"><span class="pre">bitmap</span></code> items:</p>
<dl class="simple">
<dt><em>bitmap</em></dt><dd><p>The bitmap to display.</p>
</dd>
<dt><em>anchor</em></dt><dd><p>How the bitmap is positioned relative to its point.</p>
</dd>
<dt><em>background</em>, <em>foreground</em></dt><dd><p>The colors used for the bitmap’s <code class="docutils literal notranslate"><span class="pre">0</span></code> and <code class="docutils literal notranslate"><span class="pre">1</span></code> pixels; an empty
<em>background</em> makes the <code class="docutils literal notranslate"><span class="pre">0</span></code> pixels transparent.
Both have <em>active…</em> and <em>disabled…</em> variants, and <em>bitmap</em> has
<em>activebitmap</em> and <em>disabledbitmap</em> variants.</p>
</dd>
</dl>
<p>For <code class="docutils literal notranslate"><span class="pre">image</span></code> items:</p>
<dl class="simple">
<dt><em>image</em></dt><dd><p>The Tk image to display, previously created with the image
protocols.</p>
</dd>
<dt><em>anchor</em></dt><dd><p>How the image is positioned relative to its point.</p>
</dd>
</dl>
<p>Both options have <em>active…</em> and <em>disabled…</em> variants
(<em>activeimage</em>, <em>disabledimage</em>) used in the active and disabled
states.</p>
<p>For <code class="docutils literal notranslate"><span class="pre">window</span></code> items:</p>
<dl class="simple">
<dt><em>window</em></dt><dd><p>The widget to embed; it must be a child of the canvas or of one of
its ancestors, and may not be a top-level window.</p>
</dd>
<dt><em>anchor</em></dt><dd><p>How the window is positioned relative to its point.</p>
</dd>
<dt><em>width</em>, <em>height</em></dt><dd><p>The size to assign to the window; if zero (the default), the window
is given its requested size.</p>
</dd>
</dl>
<p><code class="docutils literal notranslate"><span class="pre">oval</span></code> and <code class="docutils literal notranslate"><span class="pre">rectangle</span></code> items have no type-specific options; they
use only the standard item options.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Tk 8.6 added the <em>angle</em> option and Tk 9.0 added the <em>underline</em>
option for <code class="docutils literal notranslate"><span class="pre">text</span></code> items.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.coords">
<span class="sig-name descname"><span class="pre">coords</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.coords" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">coords</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">coordList</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span></dt>
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">coords</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">coordList</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Query or modify the coordinates of an item.
With only <em>tagOrId</em>, return a list of the floating-point coordinates of
the item given by <em>tagOrId</em> (the first matching item if it matches
several).
Given new coordinates, replace the coordinates of that item with them;
like the <code class="docutils literal notranslate"><span class="pre">create_*</span></code> methods, the coordinates may be given as separate
numbers, as a single sequence, or as coordinate pairs.
The returned coordinates are always in pixels, regardless of the units
used to specify them; for rectangles, ovals and arcs they are ordered
left, top, right, bottom.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.12: </span>The arguments are now flattened: the coordinates may be given as
separate arguments, as a single sequence, or grouped in pairs, like
the <code class="docutils literal notranslate"><span class="pre">create_*</span></code> methods.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.move">
<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">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xAmount</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">yAmount</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.move" title="Link to this definition">¶</a></dt>
<dd><p>Move each of the items given by <em>tagOrId</em> in the canvas coordinate space
by adding <em>xAmount</em> to every x-coordinate and <em>yAmount</em> to every
y-coordinate of the item.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.moveto">
<span class="sig-name descname"><span class="pre">moveto</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.moveto" title="Link to this definition">¶</a></dt>
<dd><p>Move the items given by <em>tagOrId</em> so that the first coordinate pair (the
upper-left corner of the bounding box) of the lowest matching item is at
position (<em>x</em>, <em>y</em>).
<em>x</em> or <em>y</em> may be an empty string, in which case the corresponding
coordinate is unchanged.
All matching items keep their positions relative to each other.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.8.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.scale">
<span class="sig-name descname"><span class="pre">scale</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xOrigin</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">yOrigin</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xScale</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">yScale</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.scale" title="Link to this definition">¶</a></dt>
<dd><p>Rescale the coordinates of all items given by <em>tagOrId</em> in canvas
coordinate space.
Each x-coordinate is adjusted so that its distance from <em>xOrigin</em> changes
by a factor of <em>xScale</em>, and each y-coordinate so that its distance from
<em>yOrigin</em> changes by a factor of <em>yScale</em> (a factor of <code class="docutils literal notranslate"><span class="pre">1.0</span></code> leaves the
coordinate unchanged).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.delete">
<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">tagOrIds</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.delete" title="Link to this definition">¶</a></dt>
<dd><p>Delete each of the items given by the <em>tagOrIds</em> arguments.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.dchars">
<span class="sig-name descname"><span class="pre">dchars</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">first</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.dchars" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">dchars</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">first</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">last</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span></dt>
<dd><p>Delete from each of the items given by <em>tagOrId</em> the characters (for text
items) or coordinates (for line and polygon items) in the range from
<em>first</em> to <em>last</em> inclusive; <em>last</em> defaults to <em>first</em>.
Items that do not support indexing ignore this operation.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.insert">
<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">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">beforeThis</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">string</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.insert" title="Link to this definition">¶</a></dt>
<dd><p>Insert <em>string</em> into each of the items given by <em>tagOrId</em> just before the
character or coordinate whose index is <em>beforeThis</em>.
For line and polygon items <em>string</em> must be a valid sequence of
coordinates.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.itemcget">
<span class="sig-name descname"><span class="pre">itemcget</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">option</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.itemcget" title="Link to this definition">¶</a></dt>
<dd><p>Return the current value of the configuration option <em>option</em> for the
item given by <em>tagOrId</em> (the lowest matching item if it matches several).
This is like <a class="reference internal" href="#tkinter.Misc.cget" title="tkinter.Misc.cget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">cget()</span></code></a> but applies to an individual item.</p>
</dd></dl>
<dl class="py method" id="tkinter.Canvas.itemconfig">
<dt class="sig sig-object py" id="tkinter.Canvas.itemconfigure">
<span class="sig-name descname"><span class="pre">itemconfigure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</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.Canvas.itemconfigure" title="Link to this definition">¶</a></dt>
<dd><p>Query or modify the configuration options of the items given by
<em>tagOrId</em>.
This mirrors <a class="reference internal" href="#tkinter.Misc.configure" title="tkinter.Misc.configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code></a>, except that it applies to
individual items rather than to the canvas as a whole.
With no options, it returns a dictionary describing the current options
of the first matching item; otherwise it sets the given options on every
matching item.
The legal options are those accepted by the corresponding <code class="docutils literal notranslate"><span class="pre">create_*</span></code>
method.
<a class="reference internal" href="#tkinter.Canvas.itemconfig" title="tkinter.Canvas.itemconfig"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itemconfig()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">itemconfigure()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.type">
<span class="sig-name descname"><span class="pre">type</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.type" title="Link to this definition">¶</a></dt>
<dd><p>Return the type of the item given by <em>tagOrId</em> (the first matching item
if it matches several), such as <code class="docutils literal notranslate"><span class="pre">'rectangle'</span></code> or <code class="docutils literal notranslate"><span class="pre">'text'</span></code>, or
<code class="docutils literal notranslate"><span class="pre">None</span></code> if <em>tagOrId</em> does not match any item.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.gettags">
<span class="sig-name descname"><span class="pre">gettags</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.gettags" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of the tags associated with the item given by <em>tagOrId</em>
(the first matching item in display-list order if it matches several).
Return an empty tuple if no item matches or the item has no tags.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.dtag">
<span class="sig-name descname"><span class="pre">dtag</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.dtag" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">dtag</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tagToDelete</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span></dt>
<dd><p>Remove the tag <em>tagToDelete</em> (which defaults to <em>tagOrId</em>) from each of
the items given by <em>tagOrId</em>.
Items that do not have that tag are unaffected.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.addtag">
<span class="sig-name descname"><span class="pre">addtag</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newtag</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">searchSpec</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em>, <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.Canvas.addtag" title="Link to this definition">¶</a></dt>
<dd><p>Add the tag <em>newtag</em> to each item selected by the search specification
<em>searchSpec</em> (and any further <em>args</em>).
<em>searchSpec</em> is one of <code class="docutils literal notranslate"><span class="pre">'above'</span></code>, <code class="docutils literal notranslate"><span class="pre">'all'</span></code>, <code class="docutils literal notranslate"><span class="pre">'below'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'closest'</span></code>, <code class="docutils literal notranslate"><span class="pre">'enclosed'</span></code>, <code class="docutils literal notranslate"><span class="pre">'overlapping'</span></code> or <code class="docutils literal notranslate"><span class="pre">'withtag'</span></code>; the
<code class="docutils literal notranslate"><span class="pre">addtag_*</span></code> methods below are convenient wrappers that supply each of
these forms.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.addtag_above">
<span class="sig-name descname"><span class="pre">addtag_above</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newtag</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.addtag_above" title="Link to this definition">¶</a></dt>
<dd><p>Add the tag <em>newtag</em> to the item just above (after) <em>tagOrId</em> in the
display list.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.addtag_all">
<span class="sig-name descname"><span class="pre">addtag_all</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newtag</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.addtag_all" title="Link to this definition">¶</a></dt>
<dd><p>Add the tag <em>newtag</em> to all items in the canvas.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.addtag_below">
<span class="sig-name descname"><span class="pre">addtag_below</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newtag</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.addtag_below" title="Link to this definition">¶</a></dt>
<dd><p>Add the tag <em>newtag</em> to the item just below (before) <em>tagOrId</em> in the
display list.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.addtag_closest">
<span class="sig-name descname"><span class="pre">addtag_closest</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newtag</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>, <em class="sig-param"><span class="n"><span class="pre">halo</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">start</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.Canvas.addtag_closest" title="Link to this definition">¶</a></dt>
<dd><p>Add the tag <em>newtag</em> to the item closest to the point (<em>x</em>, <em>y</em>).
If <em>halo</em> is given, any item within that distance of the point is treated
as overlapping it.
If <em>start</em> is given (a tag or id), select the topmost closest item that
lies below <em>start</em> in the display list, which can be used to step through
all the closest items.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.addtag_enclosed">
<span class="sig-name descname"><span class="pre">addtag_enclosed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newtag</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.addtag_enclosed" title="Link to this definition">¶</a></dt>
<dd><p>Add the tag <em>newtag</em> to every item completely enclosed within the
rectangle (<em>x1</em>, <em>y1</em>, <em>x2</em>, <em>y2</em>), where <em>x1</em> <= <em>x2</em> and <em>y1</em> <= <em>y2</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.addtag_overlapping">
<span class="sig-name descname"><span class="pre">addtag_overlapping</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newtag</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.addtag_overlapping" title="Link to this definition">¶</a></dt>
<dd><p>Add the tag <em>newtag</em> to every item that overlaps or is enclosed within
the rectangle (<em>x1</em>, <em>y1</em>, <em>x2</em>, <em>y2</em>), where <em>x1</em> <= <em>x2</em> and <em>y1</em> <=
<em>y2</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.addtag_withtag">
<span class="sig-name descname"><span class="pre">addtag_withtag</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newtag</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.addtag_withtag" title="Link to this definition">¶</a></dt>
<dd><p>Add the tag <em>newtag</em> to every item given by <em>tagOrId</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.find">
<span class="sig-name descname"><span class="pre">find</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">searchSpec</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em>, <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.Canvas.find" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of the ids of all items selected by the search
specification <em>searchSpec</em> (and any further <em>args</em>), in stacking order
with the lowest item first.
The search specification has any of the forms accepted by <a class="reference internal" href="#tkinter.Canvas.addtag" title="tkinter.Canvas.addtag"><code class="xref py py-meth docutils literal notranslate"><span class="pre">addtag()</span></code></a>.
The <code class="docutils literal notranslate"><span class="pre">find_*</span></code> methods below are more convenient wrappers around it.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.find_above">
<span class="sig-name descname"><span class="pre">find_above</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.find_above" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple containing the id of the item just above <em>tagOrId</em> in the
display list.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.find_all">
<span class="sig-name descname"><span class="pre">find_all</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.find_all" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of the ids of all items in the canvas, in stacking order.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.find_below">
<span class="sig-name descname"><span class="pre">find_below</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.find_below" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple containing the id of the item just below <em>tagOrId</em> in the
display list.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.find_closest">
<span class="sig-name descname"><span class="pre">find_closest</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>, <em class="sig-param"><span class="n"><span class="pre">halo</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">start</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.Canvas.find_closest" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple containing the id of the item closest to the point (<em>x</em>,
<em>y</em>).
<em>halo</em> and <em>start</em> are interpreted as for <a class="reference internal" href="#tkinter.Canvas.addtag_closest" title="tkinter.Canvas.addtag_closest"><code class="xref py py-meth docutils literal notranslate"><span class="pre">addtag_closest()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.find_enclosed">
<span class="sig-name descname"><span class="pre">find_enclosed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.find_enclosed" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of the ids of all items completely enclosed within the
rectangle (<em>x1</em>, <em>y1</em>, <em>x2</em>, <em>y2</em>).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.find_overlapping">
<span class="sig-name descname"><span class="pre">find_overlapping</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.find_overlapping" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of the ids of all items that overlap or are enclosed
within the rectangle (<em>x1</em>, <em>y1</em>, <em>x2</em>, <em>y2</em>).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.find_withtag">
<span class="sig-name descname"><span class="pre">find_withtag</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.find_withtag" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of the ids of all items given by <em>tagOrId</em>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Canvas.tkraise">
<span id="tkinter.Canvas.lift"></span><dt class="sig sig-object py" id="tkinter.Canvas.tag_raise">
<span class="sig-name descname"><span class="pre">tag_raise</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">aboveThis</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="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.tag_raise" title="Link to this definition">¶</a></dt>
<dd><p>Move all items given by <em>tagOrId</em> to a new position in the display list
just above the item given by <em>aboveThis</em>, or to the top of the display
list if <em>aboveThis</em> is omitted.
When several items are moved their relative order is preserved.
This has no effect on embedded window items, whose stacking order is
controlled by <a class="reference internal" href="#tkinter.Misc.tkraise" title="tkinter.Misc.tkraise"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.tkraise()</span></code></a> and <a class="reference internal" href="#tkinter.Misc.lower" title="tkinter.Misc.lower"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.lower()</span></code></a> instead.
<a class="reference internal" href="#tkinter.Canvas.lift" title="tkinter.Canvas.lift"><code class="xref py py-meth docutils literal notranslate"><span class="pre">lift()</span></code></a> and <a class="reference internal" href="#tkinter.Canvas.tkraise" title="tkinter.Canvas.tkraise"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tkraise()</span></code></a> are aliases of <code class="xref py py-meth docutils literal notranslate"><span class="pre">tag_raise()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Canvas.lower">
<dt class="sig sig-object py" id="tkinter.Canvas.tag_lower">
<span class="sig-name descname"><span class="pre">tag_lower</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">belowThis</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="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.tag_lower" title="Link to this definition">¶</a></dt>
<dd><p>Move all items given by <em>tagOrId</em> to a new position in the display list
just below the item given by <em>belowThis</em>, or to the bottom of the display
list if <em>belowThis</em> is omitted.
When several items are moved their relative order is preserved.
This has no effect on embedded window items.
<a class="reference internal" href="#tkinter.Canvas.lower" title="tkinter.Canvas.lower"><code class="xref py py-meth docutils literal notranslate"><span class="pre">lower()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">tag_lower()</span></code>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>On a <code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code>, <a class="reference internal" href="#tkinter.Canvas.tkraise" title="tkinter.Canvas.tkraise"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tkraise()</span></code></a>/<a class="reference internal" href="#tkinter.Canvas.lift" title="tkinter.Canvas.lift"><code class="xref py py-meth docutils literal notranslate"><span class="pre">lift()</span></code></a> and <a class="reference internal" href="#tkinter.Canvas.lower" title="tkinter.Canvas.lower"><code class="xref py py-meth docutils literal notranslate"><span class="pre">lower()</span></code></a>
restack canvas items,
shadowing the inherited <a class="reference internal" href="#tkinter.Misc.tkraise" title="tkinter.Misc.tkraise"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.tkraise()</span></code></a>/<a class="reference internal" href="#tkinter.Misc.lift" title="tkinter.Misc.lift"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.lift()</span></code></a> and
<a class="reference internal" href="#tkinter.Misc.lower" title="tkinter.Misc.lower"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.lower()</span></code></a> methods that restack the widget itself,
which are therefore not available.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.tag_bind">
<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">tagOrId</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">func</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">add</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.Canvas.tag_bind" title="Link to this definition">¶</a></dt>
<dd><p>Bind the callback <em>func</em> to the event <em>sequence</em> for all items given by
<em>tagOrId</em>, so that <em>func</em> is invoked whenever that event occurs for one
of the items.
This is like <a class="reference internal" href="#tkinter.Misc.bind" title="tkinter.Misc.bind"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Widget.bind</span></code></a> but operates on canvas items
rather than on whole widgets; only mouse, keyboard and virtual events may
be bound.
Mouse events are directed to the current item and keyboard events to the
focus item (see <a class="reference internal" href="#tkinter.Canvas.focus" title="tkinter.Canvas.focus"><code class="xref py py-meth docutils literal notranslate"><span class="pre">focus()</span></code></a>).
If <em>add</em> is true the new binding is added to any existing bindings for
the same sequence, rather than replacing them.
Return the identifier of the bound function, which can be passed to
<a class="reference internal" href="#tkinter.Canvas.tag_unbind" title="tkinter.Canvas.tag_unbind"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tag_unbind()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.tag_unbind">
<span class="sig-name descname"><span class="pre">tag_unbind</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sequence</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">funcid</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.Canvas.tag_unbind" title="Link to this definition">¶</a></dt>
<dd><p>Remove for all items given by <em>tagOrId</em> the binding for the event
<em>sequence</em>.
If <em>funcid</em> is given, only that callback (as returned by
<a class="reference internal" href="#tkinter.Canvas.tag_bind" title="tkinter.Canvas.tag_bind"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tag_bind()</span></code></a>) is unbound and deregistered.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.13: </span>If <em>funcid</em> is given, only that callback is unbound.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.bbox">
<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">tagOrId</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">tagOrIds</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.bbox" title="Link to this definition">¶</a></dt>
<dd><p>Return a 4-tuple <code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1,</span> <span class="pre">x2,</span> <span class="pre">y2)</span></code> giving an approximate bounding box,
in pixels, that encloses all the items given by <em>tagOrId</em> and any further
<em>tagOrIds</em>.
The result may overestimate the true bounding box by a few pixels.
Return <code class="docutils literal notranslate"><span class="pre">None</span></code> if no item matches or the matching items have nothing to
display.</p>
<p>This shadows the inherited <code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.bbox()</span></code>;
use <a class="reference internal" href="#tkinter.Misc.grid_bbox" title="tkinter.Misc.grid_bbox"><code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_bbox()</span></code></a> for the grid bounding box.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.canvasx">
<span class="sig-name descname"><span class="pre">canvasx</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">screenx</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gridspacing</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.Canvas.canvasx" title="Link to this definition">¶</a></dt>
<dd><p>Given a window x-coordinate <em>screenx</em>, return the canvas x-coordinate
displayed at that location.
If <em>gridspacing</em> is given, the result is rounded to the nearest multiple
of <em>gridspacing</em> units.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.canvasy">
<span class="sig-name descname"><span class="pre">canvasy</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">screeny</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gridspacing</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.Canvas.canvasy" title="Link to this definition">¶</a></dt>
<dd><p>Given a window y-coordinate <em>screeny</em>, return the canvas y-coordinate
displayed at that location.
If <em>gridspacing</em> is given, the result is rounded to the nearest multiple
of <em>gridspacing</em> units.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.focus">
<span class="sig-name descname"><span class="pre">focus</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.focus" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py">
<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">tagOrId</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span></dt>
<dd><p>With <em>tagOrId</em>, set the keyboard focus for the canvas to the first item
given by <em>tagOrId</em> that supports the insertion cursor; the focus is left
unchanged if no such item exists.
If <em>tagOrId</em> is an empty string, reset the focus so that no item has it.
With no argument, return the id of the item that currently has the focus,
or an empty string if none does.
An item only displays the insertion cursor when both it is the focus item
and its canvas has the input focus.</p>
<p>This shadows the inherited <code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.focus()</span></code>;
use <a class="reference internal" href="#tkinter.Misc.focus_set" title="tkinter.Misc.focus_set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">focus_set()</span></code></a> to focus the widget itself.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.icursor">
<span class="sig-name descname"><span class="pre">icursor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.icursor" title="Link to this definition">¶</a></dt>
<dd><p>Set the insertion cursor of the items given by <em>tagOrId</em> to just before
the character given by <em>index</em>.
Items that do not support an insertion cursor are unaffected.
The cursor is only displayed when the item has the focus, but its
position may be set at any time.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.index">
<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">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.index" title="Link to this definition">¶</a></dt>
<dd><p>Return as an integer the numerical index within <em>tagOrId</em> corresponding
to <em>index</em>, which is a textual description of a position (for text items
an index into the characters, for line and polygon items an index into
the coordinates).
If <em>tagOrId</em> matches several items, the first one that supports indexing
is used.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.select_adjust">
<span class="sig-name descname"><span class="pre">select_adjust</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</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.Canvas.select_adjust" title="Link to this definition">¶</a></dt>
<dd><p>Adjust the end of the selection in <em>tagOrId</em> nearest to <em>index</em> so that
it is at <em>index</em>, and make the other end the anchor point for future
<a class="reference internal" href="#tkinter.Canvas.select_to" title="tkinter.Canvas.select_to"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_to()</span></code></a> calls.
If the selection is not currently in <em>tagOrId</em>, this behaves like
<code class="xref py py-meth docutils literal notranslate"><span class="pre">select_to()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.select_clear">
<span class="sig-name descname"><span class="pre">select_clear</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.select_clear" title="Link to this definition">¶</a></dt>
<dd><p>Clear the selection if it is in this canvas; otherwise do nothing.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.select_from">
<span class="sig-name descname"><span class="pre">select_from</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</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.Canvas.select_from" title="Link to this definition">¶</a></dt>
<dd><p>Set the selection anchor point to just before the character given by
<em>index</em> in the item given by <em>tagOrId</em>.
This does not change the selection itself; it sets the fixed end for
future <a class="reference internal" href="#tkinter.Canvas.select_to" title="tkinter.Canvas.select_to"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_to()</span></code></a> calls.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.select_item">
<span class="sig-name descname"><span class="pre">select_item</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.select_item" title="Link to this definition">¶</a></dt>
<dd><p>Return the id of the item that holds the selection, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if the
selection is not in this canvas.
Unlike <a class="reference internal" href="#tkinter.Canvas.find" title="tkinter.Canvas.find"><code class="xref py py-meth docutils literal notranslate"><span class="pre">find()</span></code></a> and the <code class="docutils literal notranslate"><span class="pre">find_*</span></code> methods, this returns the id as a
string rather than an integer.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.select_to">
<span class="sig-name descname"><span class="pre">select_to</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</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.Canvas.select_to" title="Link to this definition">¶</a></dt>
<dd><p>Set the selection to the characters of <em>tagOrId</em> between the selection
anchor point and <em>index</em>, inclusive of <em>index</em>.
The anchor point is the one set by the most recent <a class="reference internal" href="#tkinter.Canvas.select_adjust" title="tkinter.Canvas.select_adjust"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_adjust()</span></code></a>
or <a class="reference internal" href="#tkinter.Canvas.select_from" title="tkinter.Canvas.select_from"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_from()</span></code></a> call.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.scan_mark">
<span class="sig-name descname"><span class="pre">scan_mark</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.Canvas.scan_mark" title="Link to this definition">¶</a></dt>
<dd><p>Record <em>x</em>, <em>y</em> and the current view, for use with later
<a class="reference internal" href="#tkinter.Canvas.scan_dragto" title="tkinter.Canvas.scan_dragto"><code class="xref py py-meth docutils literal notranslate"><span class="pre">scan_dragto()</span></code></a> calls.
This is typically bound to a mouse button press in the widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.scan_dragto">
<span class="sig-name descname"><span class="pre">scan_dragto</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>, <em class="sig-param"><span class="n"><span class="pre">gain</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Canvas.scan_dragto" title="Link to this definition">¶</a></dt>
<dd><p>Scroll the canvas by <em>gain</em> times the difference between <em>x</em>, <em>y</em> and the
coordinates passed to the last <a class="reference internal" href="#tkinter.Canvas.scan_mark" title="tkinter.Canvas.scan_mark"><code class="xref py py-meth docutils literal notranslate"><span class="pre">scan_mark()</span></code></a> call.
This is typically bound to mouse motion events in the widget, producing
the effect of dragging the canvas at high speed through its window.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Canvas.postscript">
<span class="sig-name descname"><span class="pre">postscript</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Canvas.postscript" title="Link to this definition">¶</a></dt>
<dd><p>Generate a PostScript (Encapsulated PostScript, version 3.0)
representation of part or all of the canvas.
If the <em>file</em> or <em>channel</em> option is given, the PostScript is written
there and an empty string is returned; otherwise it is returned as a
string.
By default only the area currently visible in the window is generated, so
it is usually necessary either to call <a class="reference internal" href="#tkinter.Misc.update" title="tkinter.Misc.update"><code class="xref py py-meth docutils literal notranslate"><span class="pre">update()</span></code></a> first or to
use the <em>width</em> and <em>height</em> options.
Supported options include <em>colormap</em>, <em>colormode</em>, <em>file</em>, <em>fontmap</em>,
<em>height</em>, <em>pageanchor</em>, <em>pageheight</em>, <em>pagewidth</em>, <em>pagex</em>, <em>pagey</em>,
<em>rotate</em>, <em>width</em>, <em>x</em> and <em>y</em>.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Checkbutton">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Checkbutton</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Checkbutton" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Checkbutton</span></code> widget displays a textual string, bitmap or image
together with a square indicator, and toggles a boolean selection when
pressed.
It has all the behavior of a simple button and, in addition, can be
selected: when selected the indicator is drawn with a check mark and the
associated variable is set to the <code class="docutils literal notranslate"><span class="pre">onvalue</span></code>, and when deselected the
indicator is drawn empty and the variable is set to the <code class="docutils literal notranslate"><span class="pre">offvalue</span></code>.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.
In addition to the standard widget options, a checkbutton accepts the
options documented in the Tk <code class="docutils literal notranslate"><span class="pre">checkbutton</span></code> manual page, such as
<em>variable</em>, <em>onvalue</em>, <em>offvalue</em> and <em>command</em>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Checkbutton.invoke">
<span class="sig-name descname"><span class="pre">invoke</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Checkbutton.invoke" title="Link to this definition">¶</a></dt>
<dd><p>Do just what would happen if the user pressed the checkbutton with the
mouse: toggle the selection state of the button and invoke the associated
command, if there is one.
Return the result of the command, or an empty string if no command is
associated with the checkbutton.
This is ignored if the checkbutton’s state is <code class="docutils literal notranslate"><span class="pre">disabled</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Checkbutton.select">
<span class="sig-name descname"><span class="pre">select</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Checkbutton.select" title="Link to this definition">¶</a></dt>
<dd><p>Select the checkbutton and set the associated variable to its
<code class="docutils literal notranslate"><span class="pre">onvalue</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Checkbutton.deselect">
<span class="sig-name descname"><span class="pre">deselect</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Checkbutton.deselect" title="Link to this definition">¶</a></dt>
<dd><p>Deselect the checkbutton and set the associated variable to its
<code class="docutils literal notranslate"><span class="pre">offvalue</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Checkbutton.toggle">
<span class="sig-name descname"><span class="pre">toggle</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Checkbutton.toggle" title="Link to this definition">¶</a></dt>
<dd><p>Toggle the selection state of the button, redisplaying it and modifying
its associated variable to reflect the new state.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Checkbutton.flash">
<span class="sig-name descname"><span class="pre">flash</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Checkbutton.flash" title="Link to this definition">¶</a></dt>
<dd><p>Flash the checkbutton by redisplaying it several times, alternating
between the active and normal colors.
At the end of the flash the checkbutton is left in the same normal or
active state as when the method was called.
This is ignored if the checkbutton’s state is <code class="docutils literal notranslate"><span class="pre">disabled</span></code>.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Entry">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Entry</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Entry" title="Link to this definition">¶</a></dt>
<dd><p>An <code class="xref py py-class docutils literal notranslate"><span class="pre">Entry</span></code> widget displays a single line of text and lets the user
edit it.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a> and <a class="reference internal" href="#tkinter.XView" title="tkinter.XView"><code class="xref py py-class docutils literal notranslate"><span class="pre">XView</span></code></a>; since entries can hold
strings too long to fit in the window, they support horizontal scrolling
through <a class="reference internal" href="#tkinter.XView.xview" title="tkinter.XView.xview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">xview()</span></code></a>.</p>
<p>In addition to the standard widget options, an entry accepts the options
documented in the Tk <code class="docutils literal notranslate"><span class="pre">entry</span></code> manual page.
Notable ones are <em>textvariable</em> (the name of a variable kept in sync with
the entry’s contents), <em>show</em> (if set, each character is displayed as the
given character rather than its true value, useful for password entry),
<em>validate</em> and <em>validatecommand</em> (which together let a callback accept or
reject edits), and <em>state</em> (one of <code class="docutils literal notranslate"><span class="pre">'normal'</span></code>, <code class="docutils literal notranslate"><span class="pre">'disabled'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'readonly'</span></code>).</p>
<p>Many of the methods below take an <em>index</em> argument that selects a character
in the entry’s string.
As described in the Tk <code class="docutils literal notranslate"><span class="pre">entry</span></code> manual page, <em>index</em> may be a number
(counting from 0), <code class="docutils literal notranslate"><span class="pre">'insert'</span></code> (the character just after the insertion
cursor), <code class="docutils literal notranslate"><span class="pre">'end'</span></code> (just after the last character), <code class="docutils literal notranslate"><span class="pre">'anchor'</span></code> (the
selection anchor point), <code class="docutils literal notranslate"><span class="pre">'sel.first'</span></code> and <code class="docutils literal notranslate"><span class="pre">'sel.last'</span></code> (the ends of the
selection), or <code class="docutils literal notranslate"><span class="pre">@x</span></code> (the character covering pixel x-coordinate <em>x</em> in the
window).
Out-of-range indices are rounded to the nearest legal value.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Entry.delete">
<span class="sig-name descname"><span class="pre">delete</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">first</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">last</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.Entry.delete" title="Link to this definition">¶</a></dt>
<dd><p>Delete the characters from index <em>first</em> up to but not including index
<em>last</em>.
If <em>last</em> is omitted, only the single character at <em>first</em> is deleted.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Entry.get">
<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.Entry.get" title="Link to this definition">¶</a></dt>
<dd><p>Return the entry’s current string.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Entry.insert">
<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">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">string</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Entry.insert" title="Link to this definition">¶</a></dt>
<dd><p>Insert <em>string</em> just before the character given by <em>index</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Entry.icursor">
<span class="sig-name descname"><span class="pre">icursor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Entry.icursor" title="Link to this definition">¶</a></dt>
<dd><p>Arrange for the insertion cursor to be displayed just before the
character given by <em>index</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Entry.index">
<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">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Entry.index" title="Link to this definition">¶</a></dt>
<dd><p>Return the numerical index corresponding to <em>index</em>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Entry.select_adjust">
<dt class="sig sig-object py" id="tkinter.Entry.selection_adjust">
<span class="sig-name descname"><span class="pre">selection_adjust</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Entry.selection_adjust" title="Link to this definition">¶</a></dt>
<dd><p>Locate the end of the selection nearest to the character given by
<em>index</em>, and adjust that end to be at <em>index</em> (including but not going
beyond it); the other end becomes the anchor point for future
<a class="reference internal" href="#tkinter.Entry.selection_to" title="tkinter.Entry.selection_to"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_to()</span></code></a> calls.
If there is no selection in the entry, a new one is created between
<em>index</em> and the most recent anchor point, inclusive.
<a class="reference internal" href="#tkinter.Entry.select_adjust" title="tkinter.Entry.select_adjust"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_adjust()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_adjust()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Entry.select_clear">
<dt class="sig sig-object py" id="tkinter.Entry.selection_clear">
<span class="sig-name descname"><span class="pre">selection_clear</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Entry.selection_clear" title="Link to this definition">¶</a></dt>
<dd><p>Clear the selection if it is currently in this widget.
If the selection is not in this widget the method has no effect.
<a class="reference internal" href="#tkinter.Entry.select_clear" title="tkinter.Entry.select_clear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_clear()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_clear()</span></code>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This shadows the inherited <a class="reference internal" href="#tkinter.Misc.selection_clear" title="tkinter.Misc.selection_clear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.selection_clear()</span></code></a>,
which clears the X selection;
that method is not available on an <code class="xref py py-class docutils literal notranslate"><span class="pre">Entry</span></code>.</p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Entry.select_from">
<dt class="sig sig-object py" id="tkinter.Entry.selection_from">
<span class="sig-name descname"><span class="pre">selection_from</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Entry.selection_from" title="Link to this definition">¶</a></dt>
<dd><p>Set the selection anchor point to just before the character given by
<em>index</em>, without changing the selection.
<a class="reference internal" href="#tkinter.Entry.select_from" title="tkinter.Entry.select_from"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_from()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_from()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Entry.select_present">
<dt class="sig sig-object py" id="tkinter.Entry.selection_present">
<span class="sig-name descname"><span class="pre">selection_present</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Entry.selection_present" title="Link to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if there are characters selected in the entry, <code class="docutils literal notranslate"><span class="pre">False</span></code>
otherwise.
<a class="reference internal" href="#tkinter.Entry.select_present" title="tkinter.Entry.select_present"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_present()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_present()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Entry.select_range">
<dt class="sig sig-object py" id="tkinter.Entry.selection_range">
<span class="sig-name descname"><span class="pre">selection_range</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">start</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Entry.selection_range" title="Link to this definition">¶</a></dt>
<dd><p>Set the selection to include the characters starting with the one indexed
by <em>start</em> and ending with the one just before <em>end</em>.
If <em>end</em> refers to the same character as <em>start</em> or an earlier one, the
selection is cleared.
<a class="reference internal" href="#tkinter.Entry.select_range" title="tkinter.Entry.select_range"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_range()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_range()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Entry.select_to">
<dt class="sig sig-object py" id="tkinter.Entry.selection_to">
<span class="sig-name descname"><span class="pre">selection_to</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Entry.selection_to" title="Link to this definition">¶</a></dt>
<dd><p>Set the selection between the anchor point and <em>index</em>: if <em>index</em> is
before the anchor point, the selection runs from <em>index</em> up to but not
including the anchor; if <em>index</em> is after it, from the anchor up to but
not including <em>index</em>; if they coincide, nothing happens.
The anchor point is the one set by the most recent <a class="reference internal" href="#tkinter.Entry.selection_from" title="tkinter.Entry.selection_from"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_from()</span></code></a>
or <a class="reference internal" href="#tkinter.Entry.selection_adjust" title="tkinter.Entry.selection_adjust"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_adjust()</span></code></a> call.
If there is no selection in the entry, a new one is created using the
most recent anchor point.
<a class="reference internal" href="#tkinter.Entry.select_to" title="tkinter.Entry.select_to"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_to()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_to()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Entry.scan_mark">
<span class="sig-name descname"><span class="pre">scan_mark</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.Entry.scan_mark" title="Link to this definition">¶</a></dt>
<dd><p>Record <em>x</em> and the current view in the entry window, for use with later
<a class="reference internal" href="#tkinter.Entry.scan_dragto" title="tkinter.Entry.scan_dragto"><code class="xref py py-meth docutils literal notranslate"><span class="pre">scan_dragto()</span></code></a> calls.
Typically associated with a mouse button press in the widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Entry.scan_dragto">
<span class="sig-name descname"><span class="pre">scan_dragto</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.Entry.scan_dragto" title="Link to this definition">¶</a></dt>
<dd><p>Compute the difference between <em>x</em> and the <em>x</em> given to the last
<a class="reference internal" href="#tkinter.Entry.scan_mark" title="tkinter.Entry.scan_mark"><code class="xref py py-meth docutils literal notranslate"><span class="pre">scan_mark()</span></code></a> call, and adjust the view left or right by 10 times
that difference.
Typically associated with mouse motion events, to produce the effect of
dragging the entry at high speed through the window.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Frame">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Frame</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Frame" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Frame</span></code> widget is a simple container.
Its primary purpose is to act as a spacer or container for complex window
layouts; its only features are its background and an optional 3-D border to
make the frame appear raised or sunken.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.
Refer to the Tk <code class="docutils literal notranslate"><span class="pre">frame</span></code> manual page for the full list of options.</p>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Label">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Label</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Label" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Label</span></code> widget displays a non-interactive textual string, bitmap
or image.
The displayed text is set with the <em>text</em> option or linked to a variable
through <em>textvariable</em>, and an image can be shown using the <em>image</em> option.
Text must all be in a single font but may occupy multiple lines, and one
character may be underlined with the <em>underline</em> option.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.
Refer to the Tk <code class="docutils literal notranslate"><span class="pre">label</span></code> manual page for the full list of options.</p>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.LabelFrame">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">LabelFrame</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.LabelFrame" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">LabelFrame</span></code> widget is a container that has the features of a
<a class="reference internal" href="#tkinter.Frame" title="tkinter.Frame"><code class="xref py py-class docutils literal notranslate"><span class="pre">Frame</span></code></a> plus the ability to display a label.
The label text is set with the <em>text</em> option and positioned with
<em>labelanchor</em>, or an arbitrary widget may be used as the label by giving it
as the <em>labelwidget</em> option.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.
Refer to the Tk <code class="docutils literal notranslate"><span class="pre">labelframe</span></code> manual page for the full list of options.</p>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Listbox">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Listbox</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Listbox" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Listbox</span></code> widget displays a list of single-line text items, one
per line, of which the user can select one or more.
The way the selection behaves is governed by the <em>selectmode</em> option, which
is one of <code class="docutils literal notranslate"><span class="pre">browse</span></code> (the default; at most one item, which may be dragged
with the mouse), <code class="docutils literal notranslate"><span class="pre">single</span></code> (at most one item), <code class="docutils literal notranslate"><span class="pre">multiple</span></code> (any number of
items, toggled individually), or <code class="docutils literal notranslate"><span class="pre">extended</span></code> (any number of items,
including discontiguous ranges, selected by clicking and dragging).
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>, <a class="reference internal" href="#tkinter.XView" title="tkinter.XView"><code class="xref py py-class docutils literal notranslate"><span class="pre">XView</span></code></a> and <a class="reference internal" href="#tkinter.YView" title="tkinter.YView"><code class="xref py py-class docutils literal notranslate"><span class="pre">YView</span></code></a>, so the
view can be scrolled horizontally and vertically with <a class="reference internal" href="#tkinter.XView.xview" title="tkinter.XView.xview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">xview()</span></code></a>
and <a class="reference internal" href="#tkinter.YView.yview" title="tkinter.YView.yview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">yview()</span></code></a>.
Refer to the Tk <code class="docutils literal notranslate"><span class="pre">listbox</span></code> manual page for the full list of options.</p>
<p>Many of the methods take an <em>index</em> argument identifying a particular item.
As described in the Tk <code class="docutils literal notranslate"><span class="pre">listbox</span></code> manual page, <em>index</em> may be a numeric
index (counting from 0 at the top), <code class="docutils literal notranslate"><span class="pre">'active'</span></code> (the item with the location
cursor, set with <a class="reference internal" href="#tkinter.Listbox.activate" title="tkinter.Listbox.activate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">activate()</span></code></a>), <code class="docutils literal notranslate"><span class="pre">'anchor'</span></code> (the selection anchor, set
with <a class="reference internal" href="#tkinter.Listbox.selection_anchor" title="tkinter.Listbox.selection_anchor"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_anchor()</span></code></a>), <code class="docutils literal notranslate"><span class="pre">'end'</span></code> (the last item, or for
<a class="reference internal" href="#tkinter.Listbox.index" title="tkinter.Listbox.index"><code class="xref py py-meth docutils literal notranslate"><span class="pre">index()</span></code></a> and <a class="reference internal" href="#tkinter.Listbox.insert" title="tkinter.Listbox.insert"><code class="xref py py-meth docutils literal notranslate"><span class="pre">insert()</span></code></a> the position just after it), or <code class="docutils literal notranslate"><span class="pre">@x,y</span></code>
(the item covering pixel coordinates <em>x</em>, <em>y</em> in the listbox window).
Arguments named <em>first</em> and <em>last</em> are indices of the same forms.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Listbox.insert">
<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">index</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">elements</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Listbox.insert" title="Link to this definition">¶</a></dt>
<dd><p>Insert the given <em>elements</em> as new items just before the item given by
<em>index</em>.
If <em>index</em> is <code class="docutils literal notranslate"><span class="pre">'end'</span></code>, the new items are appended to the end of the
list.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Listbox.delete">
<span class="sig-name descname"><span class="pre">delete</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">first</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">last</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.Listbox.delete" title="Link to this definition">¶</a></dt>
<dd><p>Delete the items in the range from <em>first</em> to <em>last</em> inclusive.
If <em>last</em> is omitted, it defaults to <em>first</em>, so that a single item is
deleted.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Listbox.get">
<span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">first</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">last</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.Listbox.get" title="Link to this definition">¶</a></dt>
<dd><p>If <em>last</em> is omitted, return the contents of the item given by <em>first</em>,
or an empty string if <em>first</em> refers to a non-existent item.
If <em>last</em> is given, return a tuple of all the items in the range from
<em>first</em> to <em>last</em> inclusive.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Listbox.size">
<span class="sig-name descname"><span class="pre">size</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Listbox.size" title="Link to this definition">¶</a></dt>
<dd><p>Return the total number of items in the listbox.</p>
<p>This shadows the inherited <code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.size()</span></code>;
use <a class="reference internal" href="#tkinter.Misc.grid_size" title="tkinter.Misc.grid_size"><code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_size()</span></code></a> for the grid size.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Listbox.index">
<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">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Listbox.index" title="Link to this definition">¶</a></dt>
<dd><p>Return the integer index value corresponding to <em>index</em>, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if
<em>index</em> is out of range.
If <em>index</em> is <code class="docutils literal notranslate"><span class="pre">'end'</span></code>, the result is a count of the number of items in
the listbox (not the index of the last item).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Listbox.bbox">
<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">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Listbox.bbox" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple <code class="docutils literal notranslate"><span class="pre">(x,</span> <span class="pre">y,</span> <span class="pre">width,</span> <span class="pre">height)</span></code> describing the bounding box, in
pixels relative to the widget, of the text of the item given by <em>index</em>.
Return <code class="docutils literal notranslate"><span class="pre">None</span></code> if no part of that item is visible on the screen, or if
<em>index</em> refers to a non-existent item; if the item is only partly
visible, the result still gives the full area of the item, including the
parts that are not visible.</p>
<p>This shadows the inherited <code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.bbox()</span></code>;
use <a class="reference internal" href="#tkinter.Misc.grid_bbox" title="tkinter.Misc.grid_bbox"><code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_bbox()</span></code></a> for the grid bounding box.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Listbox.nearest">
<span class="sig-name descname"><span class="pre">nearest</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.Listbox.nearest" title="Link to this definition">¶</a></dt>
<dd><p>Given a y-coordinate within the listbox window, return the index of the
visible item nearest to that y-coordinate.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Listbox.see">
<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">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Listbox.see" title="Link to this definition">¶</a></dt>
<dd><p>Adjust the view so that the item given by <em>index</em> is visible.
If the item is already visible the method has no effect; if it is near an
edge of the window the listbox scrolls just enough to bring it into view
at that edge, otherwise the listbox scrolls to center the item.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Listbox.activate">
<span class="sig-name descname"><span class="pre">activate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Listbox.activate" title="Link to this definition">¶</a></dt>
<dd><p>Set the active item to the one given by <em>index</em>.
If <em>index</em> is outside the range of items, the closest item is activated
instead.
The active item is drawn as specified by the <em>activestyle</em> option when
the widget has the input focus, and its index may be retrieved with the
<code class="docutils literal notranslate"><span class="pre">'active'</span></code> index.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Listbox.curselection">
<span class="sig-name descname"><span class="pre">curselection</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Listbox.curselection" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple containing the numerical indices of all of the items that
are currently selected, or an empty tuple if no items are selected.</p>
</dd></dl>
<dl class="py method" id="tkinter.Listbox.select_anchor">
<dt class="sig sig-object py" id="tkinter.Listbox.selection_anchor">
<span class="sig-name descname"><span class="pre">selection_anchor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Listbox.selection_anchor" title="Link to this definition">¶</a></dt>
<dd><p>Set the selection anchor to the item given by <em>index</em>.
If <em>index</em> refers to a non-existent item, the closest item is used.
The selection anchor is the end of the selection that is fixed while
dragging out a selection with the mouse, and may afterwards be referred
to with the <code class="docutils literal notranslate"><span class="pre">'anchor'</span></code> index.
<a class="reference internal" href="#tkinter.Listbox.select_anchor" title="tkinter.Listbox.select_anchor"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_anchor()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_anchor()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Listbox.select_clear">
<dt class="sig sig-object py" id="tkinter.Listbox.selection_clear">
<span class="sig-name descname"><span class="pre">selection_clear</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">first</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">last</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.Listbox.selection_clear" title="Link to this definition">¶</a></dt>
<dd><p>Deselect any of the items in the range from <em>first</em> to <em>last</em> inclusive
that are selected.
The selection state of items outside this range is not changed.
<a class="reference internal" href="#tkinter.Listbox.select_clear" title="tkinter.Listbox.select_clear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_clear()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_clear()</span></code>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This shadows the inherited <a class="reference internal" href="#tkinter.Misc.selection_clear" title="tkinter.Misc.selection_clear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.selection_clear()</span></code></a>,
which clears the X selection;
that method is not available on a <code class="xref py py-class docutils literal notranslate"><span class="pre">Listbox</span></code>.</p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Listbox.select_includes">
<dt class="sig sig-object py" id="tkinter.Listbox.selection_includes">
<span class="sig-name descname"><span class="pre">selection_includes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Listbox.selection_includes" title="Link to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the item given by <em>index</em> is currently selected,
<code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise.
<a class="reference internal" href="#tkinter.Listbox.select_includes" title="tkinter.Listbox.select_includes"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_includes()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_includes()</span></code>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Listbox.select_set">
<dt class="sig sig-object py" id="tkinter.Listbox.selection_set">
<span class="sig-name descname"><span class="pre">selection_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">first</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">last</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.Listbox.selection_set" title="Link to this definition">¶</a></dt>
<dd><p>Select all of the items in the range from <em>first</em> to <em>last</em> inclusive,
without affecting the selection state of items outside that range.
<a class="reference internal" href="#tkinter.Listbox.select_set" title="tkinter.Listbox.select_set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_set()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_set()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Listbox.itemcget">
<span class="sig-name descname"><span class="pre">itemcget</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">option</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Listbox.itemcget" title="Link to this definition">¶</a></dt>
<dd><p>Return the current value of the configuration option <em>option</em> for the
item given by <em>index</em>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Listbox.itemconfig">
<dt class="sig sig-object py" id="tkinter.Listbox.itemconfigure">
<span class="sig-name descname"><span class="pre">itemconfigure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</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.Listbox.itemconfigure" title="Link to this definition">¶</a></dt>
<dd><p>Query or modify the configuration options of the item given by <em>index</em>.
This mirrors <a class="reference internal" href="#tkinter.Misc.configure" title="tkinter.Misc.configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code></a>, except that it applies to an
individual item rather than to the listbox as a whole.
With no options, it returns a dictionary describing the current options
of the item; otherwise it sets the given options.
The supported item options are <em>background</em>, <em>foreground</em>,
<em>selectbackground</em> and <em>selectforeground</em>.
<a class="reference internal" href="#tkinter.Listbox.itemconfig" title="tkinter.Listbox.itemconfig"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itemconfig()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">itemconfigure()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Listbox.scan_mark">
<span class="sig-name descname"><span class="pre">scan_mark</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.Listbox.scan_mark" title="Link to this definition">¶</a></dt>
<dd><p>Record <em>x</em>, <em>y</em> and the current view, for use with later
<a class="reference internal" href="#tkinter.Listbox.scan_dragto" title="tkinter.Listbox.scan_dragto"><code class="xref py py-meth docutils literal notranslate"><span class="pre">scan_dragto()</span></code></a> calls.
This is typically bound to a mouse button press in the widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Listbox.scan_dragto">
<span class="sig-name descname"><span class="pre">scan_dragto</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.Listbox.scan_dragto" title="Link to this definition">¶</a></dt>
<dd><p>Scroll the listbox by 10 times the difference between <em>x</em>, <em>y</em> and the
coordinates passed to the last <a class="reference internal" href="#tkinter.Listbox.scan_mark" title="tkinter.Listbox.scan_mark"><code class="xref py py-meth docutils literal notranslate"><span class="pre">scan_mark()</span></code></a> call.
This is typically bound to mouse motion events in the widget, producing
the effect of dragging the list at high speed through the window.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Menu">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Menu</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menu" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Menu</span></code> widget displays a column of entries, each of which may be a
command, a checkbutton, a radiobutton, a cascade (which posts an associated
submenu) or a separator.
Menus are used as the menubar of a toplevel window, as pulldown menus posted
from a cascade entry or menubutton, and as popup menus.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.</p>
<p>Many of the entry methods take an <em>index</em> argument that selects which entry
to operate on.
As described in the Tk <code class="docutils literal notranslate"><span class="pre">menu</span></code> manual page, <em>index</em> may be a numeric index
(counting from 0 at the top), <code class="docutils literal notranslate"><span class="pre">'active'</span></code> (the currently active entry),
<code class="docutils literal notranslate"><span class="pre">'end'</span></code> or <code class="docutils literal notranslate"><span class="pre">'last'</span></code> (the bottommost entry), <code class="docutils literal notranslate"><span class="pre">'none'</span></code> (no entry at all,
written <code class="docutils literal notranslate"><span class="pre">{}</span></code> in Tcl), <code class="docutils literal notranslate"><span class="pre">@y</span></code> (the entry covering pixel y-coordinate <em>y</em> in
the menu window), or a pattern matched against the labels of the entries
from the top down.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.add">
<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">itemType</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menu.add" title="Link to this definition">¶</a></dt>
<dd><p>Add a new entry to the bottom of the menu.
<em>itemType</em> is one of <code class="docutils literal notranslate"><span class="pre">'command'</span></code>, <code class="docutils literal notranslate"><span class="pre">'cascade'</span></code>, <code class="docutils literal notranslate"><span class="pre">'checkbutton'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'radiobutton'</span></code> or <code class="docutils literal notranslate"><span class="pre">'separator'</span></code> and determines the type of the new
entry; the remaining options configure it.
The <code class="xref py py-meth docutils literal notranslate"><span class="pre">add_command()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">add_cascade()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">add_checkbutton()</span></code>,
<code class="xref py py-meth docutils literal notranslate"><span class="pre">add_radiobutton()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">add_separator()</span></code> convenience methods
call this method with the corresponding <em>itemType</em>.</p>
<p>The entry is configured by the following options, although not every
option applies to every entry type (a separator accepts none of them):</p>
<dl class="simple">
<dt><em>label</em></dt><dd><p>The text to display in the entry.</p>
</dd>
<dt><em>command</em></dt><dd><p>The function to call when the entry is invoked (command, checkbutton
and radiobutton entries).</p>
</dd>
<dt><em>accelerator</em></dt><dd><p>A string displayed at the right of the entry to advertise an
accelerator keystroke; it does not itself create the binding.</p>
</dd>
<dt><em>underline</em></dt><dd><p>The index of a character in the label to underline for keyboard
traversal.</p>
</dd>
<dt><em>state</em></dt><dd><p>One of <code class="docutils literal notranslate"><span class="pre">'normal'</span></code>, <code class="docutils literal notranslate"><span class="pre">'active'</span></code> or <code class="docutils literal notranslate"><span class="pre">'disabled'</span></code>.</p>
</dd>
<dt><em>image</em></dt><dd><p>An image to display instead of, or together with, the text label.</p>
</dd>
<dt><em>compound</em></dt><dd><p>Where to show the image relative to the text: <code class="docutils literal notranslate"><span class="pre">'none'</span></code> (the
default), <code class="docutils literal notranslate"><span class="pre">'text'</span></code>, <code class="docutils literal notranslate"><span class="pre">'image'</span></code>, <code class="docutils literal notranslate"><span class="pre">'top'</span></code>, <code class="docutils literal notranslate"><span class="pre">'bottom'</span></code>, <code class="docutils literal notranslate"><span class="pre">'left'</span></code>
or <code class="docutils literal notranslate"><span class="pre">'right'</span></code>.</p>
</dd>
<dt><em>bitmap</em></dt><dd><p>A bitmap to display instead of the text label.</p>
</dd>
<dt><em>font</em></dt><dd><p>The font to use for the text.</p>
</dd>
<dt><em>background</em>, <em>foreground</em></dt><dd><p>The entry’s background and foreground colors in its normal state
(ignored on macOS).</p>
</dd>
<dt><em>activebackground</em>, <em>activeforeground</em></dt><dd><p>The background and foreground colors used when the entry is active
(ignored on macOS).</p>
</dd>
<dt><em>columnbreak</em></dt><dd><p>If true, the entry starts a new column instead of being placed below
the previous entry.</p>
</dd>
<dt><em>hidemargin</em></dt><dd><p>If true, the standard margin around the entry is omitted, which is
useful when a menu is used as a palette.</p>
</dd>
<dt><em>menu</em></dt><dd><p>The submenu posted by a cascade entry; it must be a child of this
menu.</p>
</dd>
<dt><em>variable</em></dt><dd><p>The variable associated with a checkbutton or radiobutton entry.</p>
</dd>
<dt><em>onvalue</em>, <em>offvalue</em></dt><dd><p>The values stored in <em>variable</em> when a checkbutton entry is selected
or cleared.</p>
</dd>
<dt><em>value</em></dt><dd><p>The value stored in <em>variable</em> when a radiobutton entry is selected.</p>
</dd>
<dt><em>indicatoron</em></dt><dd><p>Whether to display the indicator of a checkbutton or radiobutton
entry.</p>
</dd>
<dt><em>selectcolor</em></dt><dd><p>The color of the indicator of a checkbutton or radiobutton entry when
it is selected.</p>
</dd>
<dt><em>selectimage</em></dt><dd><p>The image displayed when a checkbutton or radiobutton entry is
selected and <em>image</em> is also given.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.add_cascade">
<span class="sig-name descname"><span class="pre">add_cascade</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menu.add_cascade" title="Link to this definition">¶</a></dt>
<dd><p>Add a new cascade entry to the bottom of the menu.
A cascade entry has an associated submenu, given by its <em>menu</em> option,
which must be a child of this menu; posting the entry posts the submenu
next to it.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.add_checkbutton">
<span class="sig-name descname"><span class="pre">add_checkbutton</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menu.add_checkbutton" title="Link to this definition">¶</a></dt>
<dd><p>Add a new checkbutton entry to the bottom of the menu.
When invoked, a checkbutton entry toggles between its <em>onvalue</em> and
<em>offvalue</em>, storing the result in its associated <em>variable</em>, and displays
an indicator showing whether it is selected.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.add_command">
<span class="sig-name descname"><span class="pre">add_command</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menu.add_command" title="Link to this definition">¶</a></dt>
<dd><p>Add a new command entry to the bottom of the menu.
A command entry behaves much like a button: when it is invoked, the
callback given by its <em>command</em> option is called.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.add_radiobutton">
<span class="sig-name descname"><span class="pre">add_radiobutton</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menu.add_radiobutton" title="Link to this definition">¶</a></dt>
<dd><p>Add a new radiobutton entry to the bottom of the menu.
Radiobutton entries sharing the same <em>variable</em> form a group of which
only one may be selected at a time; selecting an entry stores its <em>value</em>
in the variable.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.add_separator">
<span class="sig-name descname"><span class="pre">add_separator</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menu.add_separator" title="Link to this definition">¶</a></dt>
<dd><p>Add a separator to the bottom of the menu.
A separator is displayed as a horizontal dividing line and cannot be
activated or invoked.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.insert">
<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">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">itemType</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menu.insert" title="Link to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#tkinter.Menu.add" title="tkinter.Menu.add"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add()</span></code></a>, except that the new entry is inserted just before
the entry given by <em>index</em> instead of being appended to the end of the
menu.
<em>itemType</em> is one of <code class="docutils literal notranslate"><span class="pre">'command'</span></code>, <code class="docutils literal notranslate"><span class="pre">'cascade'</span></code>, <code class="docutils literal notranslate"><span class="pre">'checkbutton'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'radiobutton'</span></code> or <code class="docutils literal notranslate"><span class="pre">'separator'</span></code>.
The <code class="xref py py-meth docutils literal notranslate"><span class="pre">insert_command()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">insert_cascade()</span></code>,
<code class="xref py py-meth docutils literal notranslate"><span class="pre">insert_checkbutton()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">insert_radiobutton()</span></code> and
<code class="xref py py-meth docutils literal notranslate"><span class="pre">insert_separator()</span></code> convenience methods call this method with the
corresponding <em>itemType</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.insert_cascade">
<span class="sig-name descname"><span class="pre">insert_cascade</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menu.insert_cascade" title="Link to this definition">¶</a></dt>
<dd><p>Insert a new cascade entry before the entry given by <em>index</em> (see
<a class="reference internal" href="#tkinter.Menu.add_cascade" title="tkinter.Menu.add_cascade"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_cascade()</span></code></a>).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.insert_checkbutton">
<span class="sig-name descname"><span class="pre">insert_checkbutton</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menu.insert_checkbutton" title="Link to this definition">¶</a></dt>
<dd><p>Insert a new checkbutton entry before the entry given by <em>index</em> (see
<a class="reference internal" href="#tkinter.Menu.add_checkbutton" title="tkinter.Menu.add_checkbutton"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_checkbutton()</span></code></a>).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.insert_command">
<span class="sig-name descname"><span class="pre">insert_command</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menu.insert_command" title="Link to this definition">¶</a></dt>
<dd><p>Insert a new command entry before the entry given by <em>index</em> (see
<a class="reference internal" href="#tkinter.Menu.add_command" title="tkinter.Menu.add_command"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_command()</span></code></a>).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.insert_radiobutton">
<span class="sig-name descname"><span class="pre">insert_radiobutton</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menu.insert_radiobutton" title="Link to this definition">¶</a></dt>
<dd><p>Insert a new radiobutton entry before the entry given by <em>index</em> (see
<a class="reference internal" href="#tkinter.Menu.add_radiobutton" title="tkinter.Menu.add_radiobutton"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_radiobutton()</span></code></a>).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.insert_separator">
<span class="sig-name descname"><span class="pre">insert_separator</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menu.insert_separator" title="Link to this definition">¶</a></dt>
<dd><p>Insert a separator before the entry given by <em>index</em> (see
<a class="reference internal" href="#tkinter.Menu.add_separator" title="tkinter.Menu.add_separator"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_separator()</span></code></a>).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.delete">
<span class="sig-name descname"><span class="pre">delete</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index2</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.Menu.delete" title="Link to this definition">¶</a></dt>
<dd><p>Delete all of the menu entries between <em>index1</em> and <em>index2</em> inclusive.
If <em>index2</em> is omitted, it defaults to <em>index1</em>, so that a single entry
is deleted.
Attempts to delete a tear-off entry are ignored; remove it by changing
the <em>tearoff</em> option instead.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.entrycget">
<span class="sig-name descname"><span class="pre">entrycget</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">option</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Menu.entrycget" title="Link to this definition">¶</a></dt>
<dd><p>Return the current value of the configuration option <em>option</em> for the
entry given by <em>index</em>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Menu.entryconfig">
<dt class="sig sig-object py" id="tkinter.Menu.entryconfigure">
<span class="sig-name descname"><span class="pre">entryconfigure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</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.Menu.entryconfigure" title="Link to this definition">¶</a></dt>
<dd><p>Query or modify the configuration options of the entry given by <em>index</em>.
This mirrors <a class="reference internal" href="#tkinter.Misc.configure" title="tkinter.Misc.configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code></a>, except that it applies to an
individual entry rather than to the menu as a whole.
With no options, it returns a dictionary describing the current options
of the entry; otherwise it sets the given options.
The supported options are those accepted by <a class="reference internal" href="#tkinter.Menu.add" title="tkinter.Menu.add"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add()</span></code></a> for the entry’s
type.
<a class="reference internal" href="#tkinter.Menu.entryconfig" title="tkinter.Menu.entryconfig"><code class="xref py py-meth docutils literal notranslate"><span class="pre">entryconfig()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">entryconfigure()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.index">
<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">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Menu.index" title="Link to this definition">¶</a></dt>
<dd><p>Return the numerical index corresponding to <em>index</em>, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if
<em>index</em> selects no entry.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.type">
<span class="sig-name descname"><span class="pre">type</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Menu.type" title="Link to this definition">¶</a></dt>
<dd><p>Return the type of the entry given by <em>index</em>: one of <code class="docutils literal notranslate"><span class="pre">'command'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'cascade'</span></code>, <code class="docutils literal notranslate"><span class="pre">'checkbutton'</span></code>, <code class="docutils literal notranslate"><span class="pre">'radiobutton'</span></code>, <code class="docutils literal notranslate"><span class="pre">'separator'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'tearoff'</span></code> (for the tear-off entry).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.activate">
<span class="sig-name descname"><span class="pre">activate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Menu.activate" title="Link to this definition">¶</a></dt>
<dd><p>Make the entry given by <em>index</em> the active entry, redisplaying it with
its active colors, and deactivate any previously active entry.
If <em>index</em> selects no entry, or the selected entry is disabled, the menu
ends up with no active entry.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.invoke">
<span class="sig-name descname"><span class="pre">invoke</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Menu.invoke" title="Link to this definition">¶</a></dt>
<dd><p>Invoke the action of the entry given by <em>index</em>, as if it had been
clicked.
Nothing happens if the entry is disabled.
If the entry has a <em>command</em> associated with it, the result of that
command is returned; otherwise the result is an empty string.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.post">
<span class="sig-name descname"><span class="pre">post</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.Menu.post" title="Link to this definition">¶</a></dt>
<dd><p>Display the menu on the screen at the root-window coordinates <em>x</em> and
<em>y</em>, adjusting them if necessary so that the whole menu is visible.
If the <em>postcommand</em> option has been specified, it is evaluated before
the menu is posted.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.tk_popup">
<span class="sig-name descname"><span class="pre">tk_popup</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>, <em class="sig-param"><span class="n"><span class="pre">entry</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Menu.tk_popup" title="Link to this definition">¶</a></dt>
<dd><p>Post the menu as a popup at the root-window coordinates <em>x</em> and <em>y</em>.
If <em>entry</em> is given, the menu is positioned so that this entry is
displayed under the pointer.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.unpost">
<span class="sig-name descname"><span class="pre">unpost</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Menu.unpost" title="Link to this definition">¶</a></dt>
<dd><p>Unmap the menu so that it is no longer displayed, also unposting any
posted lower-level cascaded submenu.
This has no effect on Windows and macOS, which manage the unposting of
menus themselves.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.xposition">
<span class="sig-name descname"><span class="pre">xposition</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Menu.xposition" title="Link to this definition">¶</a></dt>
<dd><p>Return the x-coordinate, within the menu window, of the leftmost pixel of
the entry given by <em>index</em>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.3.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Menu.yposition">
<span class="sig-name descname"><span class="pre">yposition</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Menu.yposition" title="Link to this definition">¶</a></dt>
<dd><p>Return the y-coordinate, within the menu window, of the topmost pixel of
the entry given by <em>index</em>.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Menubutton">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Menubutton</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Menubutton" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Menubutton</span></code> widget displays a textual string, bitmap or image and
posts an associated <a class="reference internal" href="#tkinter.Menu" title="tkinter.Menu"><code class="xref py py-class docutils literal notranslate"><span class="pre">Menu</span></code></a>, given by its <em>menu</em> option, when the user
presses it.
Like a <a class="reference internal" href="#tkinter.Label" title="tkinter.Label"><code class="xref py py-class docutils literal notranslate"><span class="pre">Label</span></code></a> it can show <em>text</em>, a <em>textvariable</em>, or an <em>image</em>,
and the <em>direction</em> option controls where the menu appears relative to the
button.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.
Refer to the Tk <code class="docutils literal notranslate"><span class="pre">menubutton</span></code> manual page for the full list of options.</p>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Message">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Message</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Message" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Message</span></code> widget displays a non-interactive textual string, given
by the <em>text</em> option or linked to a variable through <em>textvariable</em>.
Unlike a <a class="reference internal" href="#tkinter.Label" title="tkinter.Label"><code class="xref py py-class docutils literal notranslate"><span class="pre">Label</span></code></a>, it breaks the string into multiple lines in order
to produce a given aspect ratio, choosing line breaks at word boundaries,
and it can justify the text left, centered or right.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.
Refer to the Tk <code class="docutils literal notranslate"><span class="pre">message</span></code> manual page for the full list of options.</p>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.OptionMenu">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">OptionMenu</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">variable</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">values</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.OptionMenu" title="Link to this definition">¶</a></dt>
<dd><p>A helper subclass of <a class="reference internal" href="#tkinter.Menubutton" title="tkinter.Menubutton"><code class="xref py py-class docutils literal notranslate"><span class="pre">Menubutton</span></code></a> that displays a pop-up menu of
mutually exclusive choices.
<em>variable</em> is a <a class="reference internal" href="#tkinter.Variable" title="tkinter.Variable"><code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code></a> kept in sync with the selection, <em>value</em>
is the initial choice, and <em>values</em> are the remaining menu entries.
The keyword argument <em>command</em> may be given a callback that is invoked with
the selected value, and the keyword argument <em>name</em> sets the Tk widget name.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.OptionMenu.destroy">
<span class="sig-name descname"><span class="pre">destroy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.OptionMenu.destroy" title="Link to this definition">¶</a></dt>
<dd><p>Destroy the widget, also cleaning up the associated pop-up menu.</p>
</dd></dl>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.14: </span>Added support for the <em>name</em> keyword argument.</p>
</div>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.PanedWindow">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">PanedWindow</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.PanedWindow" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">PanedWindow</span></code> is a geometry-manager widget that arranges any
number of child <em>panes</em> in a row (when <em>orient</em> is <code class="docutils literal notranslate"><span class="pre">'horizontal'</span></code>) or a
column (when <em>orient</em> is <code class="docutils literal notranslate"><span class="pre">'vertical'</span></code>).
Each pane holds one widget, and each pair of adjacent panes is separated by
a movable <em>sash</em> that the user can drag with the mouse to resize the widgets
on either side of it.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.</p>
<p>The <em>orient</em> option selects the layout direction, <em>sashwidth</em> sets the width
of each sash and <em>sashrelief</em> its relief.
When <em>showhandle</em> is true a small handle is drawn on each sash that the user
can grab to drag it.
Refer to the Tk <code class="docutils literal notranslate"><span class="pre">panedwindow</span></code> manual page for the full list of options.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PanedWindow.add">
<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.PanedWindow.add" title="Link to this definition">¶</a></dt>
<dd><p>Add <em>child</em> to the panedwindow as a new pane, placed after any existing
panes.
The keyword arguments specify per-pane management options for <em>child</em>;
they may be any of the options accepted by <a class="reference internal" href="#tkinter.PanedWindow.paneconfigure" title="tkinter.PanedWindow.paneconfigure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">paneconfigure()</span></code></a>.</p>
</dd></dl>
<dl class="py method" id="tkinter.PanedWindow.forget">
<dt class="sig sig-object py" id="tkinter.PanedWindow.remove">
<span class="sig-name descname"><span class="pre">remove</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">child</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.PanedWindow.remove" title="Link to this definition">¶</a></dt>
<dd><p>Remove the pane containing <em>child</em> from the panedwindow.
All geometry management options for <em>child</em> are forgotten.
<a class="reference internal" href="#tkinter.PanedWindow.forget" title="tkinter.PanedWindow.forget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">forget()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">remove()</span></code>.
This shadows the inherited geometry-manager <code class="xref py py-meth docutils literal notranslate"><span class="pre">forget()</span></code>;
use <a class="reference internal" href="#tkinter.Pack.pack_forget" title="tkinter.Pack.pack_forget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pack_forget()</span></code></a>, <a class="reference internal" href="#tkinter.Grid.grid_forget" title="tkinter.Grid.grid_forget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_forget()</span></code></a> or
<a class="reference internal" href="#tkinter.Place.place_forget" title="tkinter.Place.place_forget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">place_forget()</span></code></a> to remove the widget itself from its manager.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PanedWindow.panes">
<span class="sig-name descname"><span class="pre">panes</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.PanedWindow.panes" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of the widgets managed by the panedwindow, one per pane,
in order.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PanedWindow.panecget">
<span class="sig-name descname"><span class="pre">panecget</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="n"><span class="pre">option</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.PanedWindow.panecget" title="Link to this definition">¶</a></dt>
<dd><p>Return the current value of the management option <em>option</em> for the pane
containing <em>child</em>.
<em>option</em> may be any value allowed by <a class="reference internal" href="#tkinter.PanedWindow.paneconfigure" title="tkinter.PanedWindow.paneconfigure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">paneconfigure()</span></code></a>.</p>
</dd></dl>
<dl class="py method" id="tkinter.PanedWindow.paneconfig">
<dt class="sig sig-object py" id="tkinter.PanedWindow.paneconfigure">
<span class="sig-name descname"><span class="pre">paneconfigure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagOrId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</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.PanedWindow.paneconfigure" title="Link to this definition">¶</a></dt>
<dd><p>Query or modify the management options of the pane containing the widget
<em>tagOrId</em>.
With no options, it returns a dictionary describing all of the available
options for the pane; given a single option name as a string, it returns
a description of that one option; otherwise it sets the given options.
The supported options include <em>after</em> and <em>before</em> (insert the pane after
or before another managed window), <em>height</em> and <em>width</em> (the outer
dimensions of the window, including any border), <em>minsize</em> (the minimum
size in the paned dimension), <em>padx</em> and <em>pady</em> (extra space to leave on
each side of the window), <em>sticky</em> (position or stretch the window within
an oversized pane, using a string of the characters <code class="docutils literal notranslate"><span class="pre">n</span></code>, <code class="docutils literal notranslate"><span class="pre">s</span></code>, <code class="docutils literal notranslate"><span class="pre">e</span></code>
and <code class="docutils literal notranslate"><span class="pre">w</span></code>), <em>hide</em> (hide the pane while keeping it in the list of panes)
and <em>stretch</em> (how extra space is allocated to the pane: one of
<code class="docutils literal notranslate"><span class="pre">'always'</span></code>, <code class="docutils literal notranslate"><span class="pre">'first'</span></code>, <code class="docutils literal notranslate"><span class="pre">'last'</span></code>, <code class="docutils literal notranslate"><span class="pre">'middle'</span></code> or <code class="docutils literal notranslate"><span class="pre">'never'</span></code>).
<a class="reference internal" href="#tkinter.PanedWindow.paneconfig" title="tkinter.PanedWindow.paneconfig"><code class="xref py py-meth docutils literal notranslate"><span class="pre">paneconfig()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">paneconfigure()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PanedWindow.identify">
<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.PanedWindow.identify" title="Link to this definition">¶</a></dt>
<dd><p>Identify the panedwindow component underneath the point given by <em>x</em> and
<em>y</em>, in window coordinates.
If the point is over a sash or a sash handle, the result is a two-element
tuple containing the index of the sash or handle and a word indicating
whether it is over a sash or a handle, such as <code class="docutils literal notranslate"><span class="pre">(0,</span> <span class="pre">'sash')</span></code> or
<code class="docutils literal notranslate"><span class="pre">(2,</span> <span class="pre">'handle')</span></code>.
If the point is over any other part of the panedwindow, the result is an
empty string.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PanedWindow.sash">
<span class="sig-name descname"><span class="pre">sash</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.PanedWindow.sash" title="Link to this definition">¶</a></dt>
<dd><p>Query or change the position of the sashes in the panedwindow.
This is a thin wrapper around the Tk <code class="docutils literal notranslate"><span class="pre">sash</span></code> subcommand; the convenience
methods <a class="reference internal" href="#tkinter.PanedWindow.sash_coord" title="tkinter.PanedWindow.sash_coord"><code class="xref py py-meth docutils literal notranslate"><span class="pre">sash_coord()</span></code></a>, <a class="reference internal" href="#tkinter.PanedWindow.sash_mark" title="tkinter.PanedWindow.sash_mark"><code class="xref py py-meth docutils literal notranslate"><span class="pre">sash_mark()</span></code></a> and <a class="reference internal" href="#tkinter.PanedWindow.sash_place" title="tkinter.PanedWindow.sash_place"><code class="xref py py-meth docutils literal notranslate"><span class="pre">sash_place()</span></code></a>
should normally be used instead.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PanedWindow.sash_coord">
<span class="sig-name descname"><span class="pre">sash_coord</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.PanedWindow.sash_coord" title="Link to this definition">¶</a></dt>
<dd><p>Return the current x and y coordinate pair for the sash given by <em>index</em>,
which must be an integer between 0 and one less than the number of panes
in the panedwindow.
The coordinates returned are those of the top left corner of the region
containing the sash.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PanedWindow.sash_mark">
<span class="sig-name descname"><span class="pre">sash_mark</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.PanedWindow.sash_mark" title="Link to this definition">¶</a></dt>
<dd><p>Record the current mouse position for the sash given by <em>index</em>, for use
together with later sash-drag operations to move the sash.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PanedWindow.sash_place">
<span class="sig-name descname"><span class="pre">sash_place</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</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.PanedWindow.sash_place" title="Link to this definition">¶</a></dt>
<dd><p>Place the sash given by <em>index</em> at the coordinates <em>x</em> and <em>y</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PanedWindow.proxy">
<span class="sig-name descname"><span class="pre">proxy</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.PanedWindow.proxy" title="Link to this definition">¶</a></dt>
<dd><p>Query or change the position of the sash proxy, the “ghost” sash shown
while a sash is being dragged with non-opaque resizing.
This is a thin wrapper around the Tk <code class="docutils literal notranslate"><span class="pre">proxy</span></code> subcommand; the
convenience methods <a class="reference internal" href="#tkinter.PanedWindow.proxy_coord" title="tkinter.PanedWindow.proxy_coord"><code class="xref py py-meth docutils literal notranslate"><span class="pre">proxy_coord()</span></code></a>, <a class="reference internal" href="#tkinter.PanedWindow.proxy_forget" title="tkinter.PanedWindow.proxy_forget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">proxy_forget()</span></code></a> and
<a class="reference internal" href="#tkinter.PanedWindow.proxy_place" title="tkinter.PanedWindow.proxy_place"><code class="xref py py-meth docutils literal notranslate"><span class="pre">proxy_place()</span></code></a> should normally be used instead.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PanedWindow.proxy_coord">
<span class="sig-name descname"><span class="pre">proxy_coord</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.PanedWindow.proxy_coord" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple containing the x and y coordinates of the most recent
proxy location.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PanedWindow.proxy_forget">
<span class="sig-name descname"><span class="pre">proxy_forget</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.PanedWindow.proxy_forget" title="Link to this definition">¶</a></dt>
<dd><p>Remove the proxy from the display.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PanedWindow.proxy_place">
<span class="sig-name descname"><span class="pre">proxy_place</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.PanedWindow.proxy_place" title="Link to this definition">¶</a></dt>
<dd><p>Place the proxy at the coordinates <em>x</em> and <em>y</em>.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Radiobutton">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Radiobutton</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Radiobutton" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Radiobutton</span></code> widget displays a textual string, bitmap or image
together with a diamond or circular indicator, and selects one choice out of
several.
It has all the behavior of a simple button and, in addition, can be
selected: typically several radiobuttons share a single <em>variable</em>, and
selecting one sets that variable to the radiobutton’s <em>value</em>; each
radiobutton also monitors the variable and automatically selects or
deselects itself when the variable changes.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.
In addition to the standard widget options, a radiobutton accepts the
options documented in the Tk <code class="docutils literal notranslate"><span class="pre">radiobutton</span></code> manual page, such as
<em>variable</em>, <em>value</em> and <em>command</em>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Radiobutton.invoke">
<span class="sig-name descname"><span class="pre">invoke</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Radiobutton.invoke" title="Link to this definition">¶</a></dt>
<dd><p>Do just what would happen if the user pressed the radiobutton with the
mouse: select the button and invoke the associated command, if there is
one.
Return the result of the command, or an empty string if no command is
associated with the radiobutton.
This is ignored if the radiobutton’s state is <code class="docutils literal notranslate"><span class="pre">disabled</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Radiobutton.select">
<span class="sig-name descname"><span class="pre">select</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Radiobutton.select" title="Link to this definition">¶</a></dt>
<dd><p>Select the radiobutton and set the associated variable to the value
corresponding to this widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Radiobutton.deselect">
<span class="sig-name descname"><span class="pre">deselect</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Radiobutton.deselect" title="Link to this definition">¶</a></dt>
<dd><p>Deselect the radiobutton and set the associated variable to an empty
string.
If this radiobutton was not currently selected, this has no effect.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Radiobutton.flash">
<span class="sig-name descname"><span class="pre">flash</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Radiobutton.flash" title="Link to this definition">¶</a></dt>
<dd><p>Flash the radiobutton by redisplaying it several times, alternating
between the active and normal colors.
At the end of the flash the radiobutton is left in the same normal or
active state as when the method was called.
This is ignored if the radiobutton’s state is <code class="docutils literal notranslate"><span class="pre">disabled</span></code>.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Scale">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Scale</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Scale" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Scale</span></code> widget lets the user select a numerical value by moving a
slider along a trough.
It can be oriented vertically or horizontally and can optionally display a
label and the current value.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.</p>
<p>In addition to the standard widget options, a scale accepts the options
documented in the Tk <code class="docutils literal notranslate"><span class="pre">scale</span></code> manual page, such as <em>from_</em>, <em>to</em>,
<em>resolution</em>, <em>orient</em>, <em>tickinterval</em>, <em>variable</em> and <em>command</em>.
As elsewhere in <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code>, the leading <code class="docutils literal notranslate"><span class="pre">-</span></code> of the Tk option name is
dropped; <em>from</em> is spelled <code class="docutils literal notranslate"><span class="pre">from_</span></code> because <a class="reference internal" href="../reference/simple_stmts.html#from"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">from</span></code></a> is a Python
keyword.</p>
<p>With a non-integer <em>resolution</em>, see <a class="reference internal" href="#tkinter-numeric-locale"><span class="std std-ref">numeric values and the locale</span></a>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Scale.get">
<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.Scale.get" title="Link to this definition">¶</a></dt>
<dd><p>Return the current value of the scale.
The result is an integer if the scale’s <em>resolution</em> yields whole
numbers, and a float otherwise.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Scale.set">
<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.Scale.set" title="Link to this definition">¶</a></dt>
<dd><p>Set the scale to <em>value</em>, moving the slider accordingly.
This has no effect if the scale is disabled.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Scale.coords">
<span class="sig-name descname"><span class="pre">coords</span></span><span class="sig-paren">(</span><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.Scale.coords" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple <code class="docutils literal notranslate"><span class="pre">(x,</span> <span class="pre">y)</span></code> giving the pixel coordinates, relative to the
widget, of the point on the centerline of the trough that corresponds to
<em>value</em>.
If <em>value</em> is omitted, the scale’s current value is used.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Scale.identify">
<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.Scale.identify" title="Link to this definition">¶</a></dt>
<dd><p>Return a string describing the part of the scale at the pixel coordinates
<em>x</em>, <em>y</em>: <code class="docutils literal notranslate"><span class="pre">'slider'</span></code>, <code class="docutils literal notranslate"><span class="pre">'trough1'</span></code> (the part of the trough above or to
the left of the slider), <code class="docutils literal notranslate"><span class="pre">'trough2'</span></code> (below or to the right of the
slider), or an empty string if the point is not over any of these
elements.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Scrollbar">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Scrollbar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Scrollbar" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Scrollbar</span></code> widget displays a slider and two arrows that let the
user scroll an associated widget, such as a <a class="reference internal" href="#tkinter.Listbox" title="tkinter.Listbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Listbox</span></code></a>, <a class="reference internal" href="#tkinter.Text" title="tkinter.Text"><code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code></a>,
<a class="reference internal" href="#tkinter.Canvas" title="tkinter.Canvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code></a> or <a class="reference internal" href="#tkinter.Entry" title="tkinter.Entry"><code class="xref py py-class docutils literal notranslate"><span class="pre">Entry</span></code></a>.
It is connected to the scrolled widget by setting that widget’s
<em>xscrollcommand</em> or <em>yscrollcommand</em> option to the scrollbar’s <a class="reference internal" href="stdtypes.html#set" title="set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code></a>
method, and the scrollbar’s <em>command</em> option to the scrolled widget’s
<a class="reference internal" href="#tkinter.XView.xview" title="tkinter.XView.xview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">xview()</span></code></a> or <a class="reference internal" href="#tkinter.YView.yview" title="tkinter.YView.yview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">yview()</span></code></a> method.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Scrollbar.get">
<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.Scrollbar.get" title="Link to this definition">¶</a></dt>
<dd><p>Return the current scrollbar settings as a tuple <code class="docutils literal notranslate"><span class="pre">(first,</span> <span class="pre">last)</span></code> of two
fractions between 0 and 1, describing the portion of the document that is
currently visible, as last passed to <a class="reference internal" href="stdtypes.html#set" title="set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Scrollbar.set">
<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">first</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">last</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Scrollbar.set" title="Link to this definition">¶</a></dt>
<dd><p>Set the scrollbar.
<em>first</em> and <em>last</em> are fractions between 0 and 1 giving the positions of
the start and end of the visible portion of the associated document.
This method is normally registered as the scrolled widget’s
<em>xscrollcommand</em> or <em>yscrollcommand</em> and called by that widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Scrollbar.activate">
<span class="sig-name descname"><span class="pre">activate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</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.Scrollbar.activate" title="Link to this definition">¶</a></dt>
<dd><p>Mark the element <em>index</em> (one of <code class="docutils literal notranslate"><span class="pre">'arrow1'</span></code>, <code class="docutils literal notranslate"><span class="pre">'slider'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'arrow2'</span></code>) as active, displaying it according to the
<em>activebackground</em> and <em>activerelief</em> options.
If <em>index</em> is omitted, return the name of the currently active element,
or <code class="docutils literal notranslate"><span class="pre">None</span></code> if no element is active.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.5: </span>The <em>index</em> argument is now optional.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Scrollbar.delta">
<span class="sig-name descname"><span class="pre">delta</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">deltax</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">deltay</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Scrollbar.delta" title="Link to this definition">¶</a></dt>
<dd><p>Return a float indicating the fractional change in the scrollbar setting
that corresponds to moving the slider by <em>deltax</em> pixels horizontally
(for horizontal scrollbars) or <em>deltay</em> pixels vertically (for vertical
scrollbars).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Scrollbar.fraction">
<span class="sig-name descname"><span class="pre">fraction</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.Scrollbar.fraction" title="Link to this definition">¶</a></dt>
<dd><p>Return a float between 0 and 1 indicating where the point at pixel
coordinates <em>x</em>, <em>y</em> lies in the trough: 0 corresponds to the top or left
of the trough and 1 to the bottom or right.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Scrollbar.identify">
<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.Scrollbar.identify" title="Link to this definition">¶</a></dt>
<dd><p>Return the name of the element under the pixel coordinates <em>x</em>, <em>y</em> (such
as <code class="docutils literal notranslate"><span class="pre">'arrow1'</span></code>), or an empty string if the point does not lie in any
element of the scrollbar.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Spinbox">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Spinbox</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Spinbox" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Spinbox</span></code> widget is an <a class="reference internal" href="#tkinter.Entry" title="tkinter.Entry"><code class="xref py py-class docutils literal notranslate"><span class="pre">Entry</span></code></a>-like widget with a pair of
up/down arrow buttons that let the user step through a range of values in
addition to editing the value directly.
The set of values may be a numeric range given by the <em>from_</em>, <em>to</em> and
<em>increment</em> options, or an explicit list of strings given by the <em>values</em>
option (which takes precedence over the range).
Each time an arrow is invoked the <em>command</em> callback, if any, is called; the
<em>wrap</em> option controls whether stepping past either end of the range wraps
around to the other end; the <em>format</em> option specifies how numeric values
are formatted; and the <em>validate</em> option enables validation of the entered
text.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a> and <a class="reference internal" href="#tkinter.XView" title="tkinter.XView"><code class="xref py py-class docutils literal notranslate"><span class="pre">XView</span></code></a>.</p>
<p>With a non-integer <em>increment</em>, see <a class="reference internal" href="#tkinter-numeric-locale"><span class="std std-ref">numeric values and the locale</span></a>.</p>
<p>Many of the methods take an <em>index</em> argument identifying a character in the
spinbox’s string.
As described in the Tk <code class="docutils literal notranslate"><span class="pre">spinbox</span></code> manual page, <em>index</em> may be a numeric
index (counting from 0), <code class="docutils literal notranslate"><span class="pre">'anchor'</span></code> (the selection anchor point),
<code class="docutils literal notranslate"><span class="pre">'end'</span></code> (just after the last character), <code class="docutils literal notranslate"><span class="pre">'insert'</span></code> (the character just
after the insertion cursor), <code class="docutils literal notranslate"><span class="pre">'sel.first'</span></code> or <code class="docutils literal notranslate"><span class="pre">'sel.last'</span></code> (the ends of
the selection), or <code class="docutils literal notranslate"><span class="pre">@x</span></code> (the character covering pixel x-coordinate <em>x</em> in
the window).</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.get">
<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.Spinbox.get" title="Link to this definition">¶</a></dt>
<dd><p>Return the spinbox’s string.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.insert">
<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">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Spinbox.insert" title="Link to this definition">¶</a></dt>
<dd><p>Insert the characters of the string <em>s</em> just before the character given
by <em>index</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.delete">
<span class="sig-name descname"><span class="pre">delete</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">first</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">last</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.Spinbox.delete" title="Link to this definition">¶</a></dt>
<dd><p>Delete one or more characters of the spinbox.
<em>first</em> is the index of the first character to delete, and <em>last</em> is the
index of the character just after the last one to delete.
If <em>last</em> is omitted, a single character at <em>first</em> is deleted.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.icursor">
<span class="sig-name descname"><span class="pre">icursor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Spinbox.icursor" title="Link to this definition">¶</a></dt>
<dd><p>Arrange for the insertion cursor to be displayed just before the
character given by <em>index</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.index">
<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">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Spinbox.index" title="Link to this definition">¶</a></dt>
<dd><p>Return the numerical index corresponding to <em>index</em>, as a string.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.bbox">
<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">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Spinbox.bbox" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of four integers <code class="docutils literal notranslate"><span class="pre">(x,</span> <span class="pre">y,</span> <span class="pre">width,</span> <span class="pre">height)</span></code> describing the
bounding box of the character given by <em>index</em>.
<em>x</em> and <em>y</em> are the pixel coordinates of the upper-left corner of the
character relative to the widget, and <em>width</em> and <em>height</em> are its size
in pixels.
The bounding box may refer to a region outside the visible area of the
window.</p>
<p>This shadows the inherited <code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.bbox()</span></code>;
use <a class="reference internal" href="#tkinter.Misc.grid_bbox" title="tkinter.Misc.grid_bbox"><code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_bbox()</span></code></a> for the grid bounding box.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.identify">
<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.Spinbox.identify" title="Link to this definition">¶</a></dt>
<dd><p>Return the name of the window element at the pixel coordinates <em>x</em>, <em>y</em>:
one of <code class="docutils literal notranslate"><span class="pre">'buttondown'</span></code>, <code class="docutils literal notranslate"><span class="pre">'buttonup'</span></code>, <code class="docutils literal notranslate"><span class="pre">'entry'</span></code> or <code class="docutils literal notranslate"><span class="pre">'none'</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.invoke">
<span class="sig-name descname"><span class="pre">invoke</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">element</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Spinbox.invoke" title="Link to this definition">¶</a></dt>
<dd><p>Invoke the spin button given by <em>element</em>, either <code class="docutils literal notranslate"><span class="pre">'buttonup'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'buttondown'</span></code>, triggering the action associated with it.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.scan">
<span class="sig-name descname"><span class="pre">scan</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.Spinbox.scan" title="Link to this definition">¶</a></dt>
<dd><p>A thin wrapper around the Tk <code class="docutils literal notranslate"><span class="pre">scan</span></code> widget subcommand, used to
implement fast dragging of the view: <code class="docutils literal notranslate"><span class="pre">scan('mark',</span> <span class="pre">x)</span></code> records <em>x</em> and
the current view, and <code class="docutils literal notranslate"><span class="pre">scan('dragto',</span> <span class="pre">x)</span></code> adjusts the view relative to
that mark.
The <a class="reference internal" href="#tkinter.Spinbox.scan_mark" title="tkinter.Spinbox.scan_mark"><code class="xref py py-meth docutils literal notranslate"><span class="pre">scan_mark()</span></code></a> and <a class="reference internal" href="#tkinter.Spinbox.scan_dragto" title="tkinter.Spinbox.scan_dragto"><code class="xref py py-meth docutils literal notranslate"><span class="pre">scan_dragto()</span></code></a> methods wrap the two forms.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.scan_mark">
<span class="sig-name descname"><span class="pre">scan_mark</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.Spinbox.scan_mark" title="Link to this definition">¶</a></dt>
<dd><p>Record <em>x</em> and the current view in the spinbox window, for use with a
later <a class="reference internal" href="#tkinter.Spinbox.scan_dragto" title="tkinter.Spinbox.scan_dragto"><code class="xref py py-meth docutils literal notranslate"><span class="pre">scan_dragto()</span></code></a> call.
This is typically associated with a mouse button press in the widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.scan_dragto">
<span class="sig-name descname"><span class="pre">scan_dragto</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.Spinbox.scan_dragto" title="Link to this definition">¶</a></dt>
<dd><p>Adjust the view by 10 times the difference between <em>x</em> and the <em>x</em> passed
to the last <a class="reference internal" href="#tkinter.Spinbox.scan_mark" title="tkinter.Spinbox.scan_mark"><code class="xref py py-meth docutils literal notranslate"><span class="pre">scan_mark()</span></code></a> call.
This is typically associated with mouse motion events, producing the
effect of dragging the spinbox at high speed through the window.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.selection">
<span class="sig-name descname"><span class="pre">selection</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.Spinbox.selection" title="Link to this definition">¶</a></dt>
<dd><p>A thin wrapper around the Tk <code class="docutils literal notranslate"><span class="pre">selection</span></code> widget subcommand, used to
adjust the selection within the spinbox.
It has several forms depending on the first argument, such as
<code class="docutils literal notranslate"><span class="pre">selection('adjust',</span> <span class="pre">index)</span></code>, <code class="docutils literal notranslate"><span class="pre">selection('clear')</span></code>,
<code class="docutils literal notranslate"><span class="pre">selection('element',</span> <span class="pre">?elem?)</span></code>, <code class="docutils literal notranslate"><span class="pre">selection('from',</span> <span class="pre">index)</span></code>,
<code class="docutils literal notranslate"><span class="pre">selection('present')</span></code>, <code class="docutils literal notranslate"><span class="pre">selection('range',</span> <span class="pre">start,</span> <span class="pre">end)</span></code> and
<code class="docutils literal notranslate"><span class="pre">selection('to',</span> <span class="pre">index)</span></code>.
The <a class="reference internal" href="#tkinter.Spinbox.selection_adjust" title="tkinter.Spinbox.selection_adjust"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_adjust()</span></code></a>, <a class="reference internal" href="#tkinter.Spinbox.selection_clear" title="tkinter.Spinbox.selection_clear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_clear()</span></code></a>,
<a class="reference internal" href="#tkinter.Spinbox.selection_element" title="tkinter.Spinbox.selection_element"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_element()</span></code></a>, <a class="reference internal" href="#tkinter.Spinbox.selection_from" title="tkinter.Spinbox.selection_from"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_from()</span></code></a>,
<a class="reference internal" href="#tkinter.Spinbox.selection_present" title="tkinter.Spinbox.selection_present"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_present()</span></code></a>, <a class="reference internal" href="#tkinter.Spinbox.selection_range" title="tkinter.Spinbox.selection_range"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_range()</span></code></a> and
<a class="reference internal" href="#tkinter.Spinbox.selection_to" title="tkinter.Spinbox.selection_to"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_to()</span></code></a> methods wrap these forms.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.selection_adjust">
<span class="sig-name descname"><span class="pre">selection_adjust</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Spinbox.selection_adjust" title="Link to this definition">¶</a></dt>
<dd><p>Locate the end of the selection nearest to the character given by <em>index</em>
and adjust that end of the selection to be at <em>index</em> (including but not
going beyond <em>index</em>).
The other end becomes the anchor point for future <a class="reference internal" href="#tkinter.Spinbox.selection_to" title="tkinter.Spinbox.selection_to"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_to()</span></code></a>
calls.
If the selection is not currently in the spinbox, a new selection is
created to include the characters between <em>index</em> and the most recent
anchor point, inclusive.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.selection_clear">
<span class="sig-name descname"><span class="pre">selection_clear</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Spinbox.selection_clear" title="Link to this definition">¶</a></dt>
<dd><p>Clear the selection if it is currently in this widget.
If the selection is not in this widget, the method has no effect.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This shadows the inherited <a class="reference internal" href="#tkinter.Misc.selection_clear" title="tkinter.Misc.selection_clear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.selection_clear()</span></code></a>,
which clears the X selection;
that method is not available on a <code class="xref py py-class docutils literal notranslate"><span class="pre">Spinbox</span></code>.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.selection_element">
<span class="sig-name descname"><span class="pre">selection_element</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">element</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.Spinbox.selection_element" title="Link to this definition">¶</a></dt>
<dd><p>Set or get the currently selected element.
If <em>element</em> (one of <code class="docutils literal notranslate"><span class="pre">'buttonup'</span></code>, <code class="docutils literal notranslate"><span class="pre">'buttondown'</span></code> or <code class="docutils literal notranslate"><span class="pre">'none'</span></code>) is
given, that spin button is selected and displayed depressed; otherwise
the name of the currently selected element is returned.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.selection_from">
<span class="sig-name descname"><span class="pre">selection_from</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Spinbox.selection_from" title="Link to this definition">¶</a></dt>
<dd><p>Set the selection anchor point to just before the character given by
<em>index</em>, without changing the selection itself.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.8.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.selection_present">
<span class="sig-name descname"><span class="pre">selection_present</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Spinbox.selection_present" title="Link to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if there are characters selected in the spinbox,
<code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.8.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.selection_range">
<span class="sig-name descname"><span class="pre">selection_range</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">start</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Spinbox.selection_range" title="Link to this definition">¶</a></dt>
<dd><p>Set the selection to include the characters starting with the one indexed
by <em>start</em> and ending with the one just before <em>end</em>.
If <em>end</em> refers to the same character as <em>start</em> or an earlier one, the
selection is cleared.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.8.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Spinbox.selection_to">
<span class="sig-name descname"><span class="pre">selection_to</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Spinbox.selection_to" title="Link to this definition">¶</a></dt>
<dd><p>Set the selection between <em>index</em> and the anchor point.
If <em>index</em> is before the anchor point, the selection runs from <em>index</em> up
to but not including the anchor point; if it is after, the selection runs
from the anchor point up to but not including <em>index</em>; if it is the same,
nothing happens.
The anchor point is the one set by the most recent <a class="reference internal" href="#tkinter.Spinbox.selection_from" title="tkinter.Spinbox.selection_from"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_from()</span></code></a>
or <a class="reference internal" href="#tkinter.Spinbox.selection_adjust" title="tkinter.Spinbox.selection_adjust"><code class="xref py py-meth docutils literal notranslate"><span class="pre">selection_adjust()</span></code></a> call.
If the selection is not in this widget, a new selection is created using
the most recent anchor point.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.8.</span></p>
</div>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Text">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Text</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Text" title="Link to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code> widget displays and edits multi-line text.
Portions of the text may be styled with <strong>tags</strong>, particular positions may
be annotated with floating <strong>marks</strong>, and arbitrary images and other widgets
may be embedded in the text.
The widget also provides an unlimited undo/redo mechanism and supports peer
widgets that share the same underlying data.
Inherits from <a class="reference internal" href="#tkinter.Widget" title="tkinter.Widget"><code class="xref py py-class docutils literal notranslate"><span class="pre">Widget</span></code></a>, <a class="reference internal" href="#tkinter.XView" title="tkinter.XView"><code class="xref py py-class docutils literal notranslate"><span class="pre">XView</span></code></a> and <a class="reference internal" href="#tkinter.YView" title="tkinter.YView"><code class="xref py py-class docutils literal notranslate"><span class="pre">YView</span></code></a>, so the
view can be scrolled horizontally and vertically with <a class="reference internal" href="#tkinter.XView.xview" title="tkinter.XView.xview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">xview()</span></code></a>
and <a class="reference internal" href="#tkinter.YView.yview" title="tkinter.YView.yview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">yview()</span></code></a>.
Refer to the Tk <code class="docutils literal notranslate"><span class="pre">text</span></code> manual page for the full list of options.</p>
<p>Most of the methods take one or more <em>index</em> arguments that identify a
position within the text.
As described in the Tk <code class="docutils literal notranslate"><span class="pre">text</span></code> manual page, an index is a string consisting
of a base, optionally followed by one or more modifiers.
The base may be <code class="docutils literal notranslate"><span class="pre">'line.char'</span></code> (line <em>line</em>, character <em>char</em>, where lines
are counted from 1 and characters within a line from 0; <code class="docutils literal notranslate"><span class="pre">'line.end'</span></code>
refers to the newline ending the line), <code class="docutils literal notranslate"><span class="pre">'end'</span></code> (the position just after
the last newline), the name of a mark, <code class="docutils literal notranslate"><span class="pre">'tag.first'</span></code> or <code class="docutils literal notranslate"><span class="pre">'tag.last'</span></code>
(the first character tagged with <em>tag</em>, or the position just after the last
such character), the name of an embedded image or window, or <code class="docutils literal notranslate"><span class="pre">@x,y</span></code> (the
character covering pixel coordinates <em>x</em>, <em>y</em> in the widget).
A modifier such as <code class="docutils literal notranslate"><span class="pre">'+5</span> <span class="pre">chars'</span></code>, <code class="docutils literal notranslate"><span class="pre">'-3</span> <span class="pre">lines'</span></code>, <code class="docutils literal notranslate"><span class="pre">'linestart'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'lineend'</span></code>, <code class="docutils literal notranslate"><span class="pre">'wordstart'</span></code> or <code class="docutils literal notranslate"><span class="pre">'wordend'</span></code> adjusts the index relative
to its base; several modifiers may be combined and are applied from left to
right, for example <code class="docutils literal notranslate"><span class="pre">'insert</span> <span class="pre">wordstart</span> <span class="pre">-</span> <span class="pre">1</span> <span class="pre">c'</span></code>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.insert">
<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">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">chars</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><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.insert" title="Link to this definition">¶</a></dt>
<dd><p>Insert the string <em>chars</em> just before the character at <em>index</em> (if
<em>index</em> is <code class="docutils literal notranslate"><span class="pre">'end'</span></code>, just before the final newline).
By default the new text inherits any tags present on both sides of the
insertion point.
If <em>args</em> is given, it consists of alternating <em>tagList</em>, <em>chars</em> values:
the preceding <em>chars</em> receives exactly the tags listed (a tag list may be
a single tag name or a sequence of names), overriding the surrounding
tags.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.delete">
<span class="sig-name descname"><span class="pre">delete</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index2</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.Text.delete" title="Link to this definition">¶</a></dt>
<dd><p>Delete the range of characters from <em>index1</em> up to but not including
<em>index2</em>.
If <em>index2</em> is omitted, the single character at <em>index1</em> is deleted.
The widget always keeps a newline as its last character, so a deletion
that would remove it is adjusted accordingly.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.replace">
<span class="sig-name descname"><span class="pre">replace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">chars</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><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.replace" title="Link to this definition">¶</a></dt>
<dd><p>Replace the range of characters from <em>index1</em> up to but not including
<em>index2</em> with <em>chars</em>.
This is equivalent to a <a class="reference internal" href="#tkinter.Text.delete" title="tkinter.Text.delete"><code class="xref py py-meth docutils literal notranslate"><span class="pre">delete()</span></code></a> followed by an <a class="reference internal" href="#tkinter.Text.insert" title="tkinter.Text.insert"><code class="xref py py-meth docutils literal notranslate"><span class="pre">insert()</span></code></a> at
<em>index1</em>; <em>args</em> is interpreted as for <code class="xref py py-meth docutils literal notranslate"><span class="pre">insert()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.3.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.get">
<span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index2</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.Text.get" title="Link to this definition">¶</a></dt>
<dd><p>Return the text from <em>index1</em> up to but not including <em>index2</em> as a
string.
If <em>index2</em> is omitted, return the single character at <em>index1</em>.
Embedded images and windows are omitted from the result.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.index">
<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">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.index" title="Link to this definition">¶</a></dt>
<dd><p>Return the position corresponding to <em>index</em> in the canonical
<code class="docutils literal notranslate"><span class="pre">'line.char'</span></code> form.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.compare">
<span class="sig-name descname"><span class="pre">compare</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">op</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.compare" title="Link to this definition">¶</a></dt>
<dd><p>Compare the positions of <em>index1</em> and <em>index2</em> using the relational
operator <em>op</em>, which must be one of <code class="docutils literal notranslate"><span class="pre">'<'</span></code>, <code class="docutils literal notranslate"><span class="pre">'<='</span></code>, <code class="docutils literal notranslate"><span class="pre">'=='</span></code>,
<code class="docutils literal notranslate"><span class="pre">'>='</span></code>, <code class="docutils literal notranslate"><span class="pre">'>'</span></code> or <code class="docutils literal notranslate"><span class="pre">'!='</span></code>, and return the boolean result.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.count">
<span class="sig-name descname"><span class="pre">count</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index2</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">options</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_ints</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.count" title="Link to this definition">¶</a></dt>
<dd><p>Count the number of items of the requested kinds between <em>index1</em> and
<em>index2</em>; the count is negative if <em>index1</em> is after <em>index2</em>.
Each of <em>options</em> names a kind of item to count: <code class="docutils literal notranslate"><span class="pre">'chars'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'displaychars'</span></code>, <code class="docutils literal notranslate"><span class="pre">'displayindices'</span></code>, <code class="docutils literal notranslate"><span class="pre">'displaylines'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'indices'</span></code>, <code class="docutils literal notranslate"><span class="pre">'lines'</span></code>, <code class="docutils literal notranslate"><span class="pre">'xpixels'</span></code> or <code class="docutils literal notranslate"><span class="pre">'ypixels'</span></code> (the default,
used when no option is given, is <code class="docutils literal notranslate"><span class="pre">'indices'</span></code>).
The pseudo-option <code class="docutils literal notranslate"><span class="pre">'update'</span></code> forces any out-of-date layout information
to be recalculated before the following options are evaluated.
When <em>return_ints</em> is true and a single counting option is given, return
a plain integer; otherwise return a tuple with one integer per counting
option (or <code class="docutils literal notranslate"><span class="pre">None</span></code> if the result is empty).</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.3.</span></p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.13: </span>Added the <em>return_ints</em> parameter.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.see">
<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">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.see" title="Link to this definition">¶</a></dt>
<dd><p>Adjust the view so that the character given by <em>index</em> is visible.
If it is already visible the method has no effect; if it is a short
distance out of view the widget scrolls just enough to bring it to the
nearest edge, otherwise it scrolls to center <em>index</em> in the window.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.bbox">
<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">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.bbox" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple <code class="docutils literal notranslate"><span class="pre">(x,</span> <span class="pre">y,</span> <span class="pre">width,</span> <span class="pre">height)</span></code> giving the bounding box, in
pixels, of the visible part of the character at <em>index</em>, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if
that character is not visible on the screen.</p>
<p>This shadows the inherited <code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.bbox()</span></code>;
use <a class="reference internal" href="#tkinter.Misc.grid_bbox" title="tkinter.Misc.grid_bbox"><code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_bbox()</span></code></a> for the grid bounding box.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.dlineinfo">
<span class="sig-name descname"><span class="pre">dlineinfo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.dlineinfo" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple <code class="docutils literal notranslate"><span class="pre">(x,</span> <span class="pre">y,</span> <span class="pre">width,</span> <span class="pre">height,</span> <span class="pre">baseline)</span></code> describing the display
line that contains <em>index</em>: the first four values give the bounding box
of the line in pixels and <em>baseline</em> gives the offset of the baseline
measured down from the top of the area.
Return <code class="docutils literal notranslate"><span class="pre">None</span></code> if that display line is not visible on the screen.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.mark_set">
<span class="sig-name descname"><span class="pre">mark_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">markName</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.Text.mark_set" title="Link to this definition">¶</a></dt>
<dd><p>Set the mark named <em>markName</em> to the position just before the character
at <em>index</em>, creating the mark if it does not already exist.
A mark created this way has right gravity by default.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.mark_unset">
<span class="sig-name descname"><span class="pre">mark_unset</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">markNames</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.mark_unset" title="Link to this definition">¶</a></dt>
<dd><p>Remove each of the marks named in <em>markNames</em>.
The special <code class="docutils literal notranslate"><span class="pre">insert</span></code> and <code class="docutils literal notranslate"><span class="pre">current</span></code> marks may not be removed.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.mark_names">
<span class="sig-name descname"><span class="pre">mark_names</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.mark_names" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of the names of all marks currently set in the widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.mark_gravity">
<span class="sig-name descname"><span class="pre">mark_gravity</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">markName</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">direction</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.Text.mark_gravity" title="Link to this definition">¶</a></dt>
<dd><p>If <em>direction</em> is omitted, return the gravity of mark <em>markName</em>, either
<code class="docutils literal notranslate"><span class="pre">'left'</span></code> or <code class="docutils literal notranslate"><span class="pre">'right'</span></code>.
Otherwise set its gravity to <em>direction</em>.
The gravity determines on which side of the mark text inserted at the
mark’s position appears: a mark with right gravity (the default) stays to
the right of such text.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.mark_next">
<span class="sig-name descname"><span class="pre">mark_next</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.mark_next" title="Link to this definition">¶</a></dt>
<dd><p>Return the name of the first mark at or after <em>index</em>, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if
there is none.
When <em>index</em> is the name of a mark, the search starts just after that
mark.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.mark_previous">
<span class="sig-name descname"><span class="pre">mark_previous</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.mark_previous" title="Link to this definition">¶</a></dt>
<dd><p>Return the name of the last mark at or before <em>index</em>, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if
there is none.
When <em>index</em> is the name of a mark, the search starts just before that
mark.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.tag_add">
<span class="sig-name descname"><span class="pre">tag_add</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">index1</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><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.tag_add" title="Link to this definition">¶</a></dt>
<dd><p>Add the tag <em>tagName</em> to the range of characters from <em>index1</em> up to but
not including the next index in <em>args</em>.
Further pairs of indices may follow in <em>args</em> to tag additional ranges; a
trailing single index tags just the character at that index.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.tag_remove">
<span class="sig-name descname"><span class="pre">tag_remove</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">index1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index2</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.Text.tag_remove" title="Link to this definition">¶</a></dt>
<dd><p>Remove the tag <em>tagName</em> from the characters from <em>index1</em> up to but not
including <em>index2</em> (or from the single character at <em>index1</em> if <em>index2</em>
is omitted).
The tag itself continues to exist even if no characters carry it.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.tag_delete">
<span class="sig-name descname"><span class="pre">tag_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">tagNames</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.tag_delete" title="Link to this definition">¶</a></dt>
<dd><p>Delete each of the tags named in <em>tagNames</em>, removing them from all
characters and discarding their options and bindings.</p>
</dd></dl>
<dl class="py method" id="tkinter.Text.tag_config">
<dt class="sig sig-object py" id="tkinter.Text.tag_configure">
<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">cnf</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.Text.tag_configure" title="Link to this definition">¶</a></dt>
<dd><p>Query or modify the configuration options of the tag <em>tagName</em>.
This mirrors <a class="reference internal" href="#tkinter.Misc.configure" title="tkinter.Misc.configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code></a>, except that it applies to a tag
rather than to the widget as a whole: with no options it returns a
dictionary describing the current options, otherwise it sets the given
options.
Defining a tag this way also gives it a priority higher than any existing
tag.</p>
<p>The supported tag options, all controlling the appearance of the tagged
text, are:</p>
<dl class="simple">
<dt><em>font</em></dt><dd><p>The font to use for the text.</p>
</dd>
<dt><em>foreground</em></dt><dd><p>The color to use for the text.</p>
</dd>
<dt><em>background</em></dt><dd><p>The color to use for the area behind the text.</p>
</dd>
<dt><em>fgstipple</em>, <em>bgstipple</em></dt><dd><p>Bitmaps used to stipple the foreground (text) and the background;
only well supported on X11.</p>
</dd>
<dt><em>borderwidth</em></dt><dd><p>The width of the border drawn around the text according to <em>relief</em>
(default <code class="docutils literal notranslate"><span class="pre">0</span></code>).</p>
</dd>
<dt><em>relief</em></dt><dd><p>The 3-D appearance of the text’s border: <code class="docutils literal notranslate"><span class="pre">'flat'</span></code> (the default),
<code class="docutils literal notranslate"><span class="pre">'raised'</span></code>, <code class="docutils literal notranslate"><span class="pre">'sunken'</span></code>, <code class="docutils literal notranslate"><span class="pre">'ridge'</span></code>, <code class="docutils literal notranslate"><span class="pre">'groove'</span></code> or <code class="docutils literal notranslate"><span class="pre">'solid'</span></code>.</p>
</dd>
<dt><em>offset</em></dt><dd><p>How far the text is raised above (or, if negative, lowered below) the
baseline, for superscripts and subscripts.</p>
</dd>
<dt><em>underline</em></dt><dd><p>Whether to underline the text.</p>
</dd>
<dt><em>underlinefg</em></dt><dd><p>The color of the underline; it defaults to the text color.</p>
</dd>
<dt><em>overstrike</em></dt><dd><p>Whether to draw a line through the middle of the text.</p>
</dd>
<dt><em>overstrikefg</em></dt><dd><p>The color of the overstrike line; it defaults to the text color.</p>
</dd>
<dt><em>elide</em></dt><dd><p>Whether the text is elided (hidden).</p>
</dd>
<dt><em>justify</em></dt><dd><p>How to justify the first character of a display line: <code class="docutils literal notranslate"><span class="pre">'left'</span></code> (the
default), <code class="docutils literal notranslate"><span class="pre">'right'</span></code> or <code class="docutils literal notranslate"><span class="pre">'center'</span></code>.</p>
</dd>
<dt><em>wrap</em></dt><dd><p>How to wrap lines that are too long: <code class="docutils literal notranslate"><span class="pre">'char'</span></code>, <code class="docutils literal notranslate"><span class="pre">'word'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'none'</span></code>.</p>
</dd>
<dt><em>lmargin1</em>, <em>lmargin2</em></dt><dd><p>The indentation, in pixels, of the first display line of a logical
line and of the remaining display lines.</p>
</dd>
<dt><em>lmargincolor</em></dt><dd><p>The color of the left margin area.</p>
</dd>
<dt><em>rmargin</em></dt><dd><p>The right-hand margin, in pixels.</p>
</dd>
<dt><em>rmargincolor</em></dt><dd><p>The color of the right margin area.</p>
</dd>
<dt><em>spacing1</em>, <em>spacing2</em>, <em>spacing3</em></dt><dd><p>Extra space, in pixels, above the first display line of a logical
line, between its display lines, and below its last display line.</p>
</dd>
<dt><em>tabs</em></dt><dd><p>The set of tab stops, in the same form as the widget’s <em>tabs</em> option.</p>
</dd>
<dt><em>tabstyle</em></dt><dd><p>How tab stops are interpreted: <code class="docutils literal notranslate"><span class="pre">'tabular'</span></code> or <code class="docutils literal notranslate"><span class="pre">'wordprocessor'</span></code>.</p>
</dd>
<dt><em>selectbackground</em>, <em>selectforeground</em></dt><dd><p>The background and foreground colors used for the text while it is
selected.</p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Tk 8.6 added the <em>lmargincolor</em>, <em>overstrikefg</em>, <em>rmargincolor</em>,
<em>selectbackground</em>, <em>selectforeground</em> and <em>underlinefg</em> options.</p>
</div>
<p><a class="reference internal" href="#tkinter.Text.tag_config" title="tkinter.Text.tag_config"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tag_config()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">tag_configure()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.tag_cget">
<span class="sig-name descname"><span class="pre">tag_cget</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></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.tag_cget" title="Link to this definition">¶</a></dt>
<dd><p>Return the current value of the configuration option <em>option</em> for the tag
<em>tagName</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.tag_names">
<span class="sig-name descname"><span class="pre">tag_names</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</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.Text.tag_names" title="Link to this definition">¶</a></dt>
<dd><p>If <em>index</em> is omitted, return a tuple of the names of all tags defined in
the widget; otherwise return only the names of the tags applied to the
character at <em>index</em>.
The names are ordered from lowest to highest priority.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.tag_ranges">
<span class="sig-name descname"><span class="pre">tag_ranges</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.tag_ranges" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of indices describing all ranges of text tagged with
<em>tagName</em>.
The result alternates start and end indices, so that elements <code class="docutils literal notranslate"><span class="pre">2*i</span></code> and
<code class="docutils literal notranslate"><span class="pre">2*i+1</span></code> bound the <em>i</em>-th range.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.tag_nextrange">
<span class="sig-name descname"><span class="pre">tag_nextrange</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">index1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index2</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.Text.tag_nextrange" title="Link to this definition">¶</a></dt>
<dd><p>Search forward from <em>index1</em> (up to <em>index2</em> if given) for the first
range of characters tagged with <em>tagName</em>, and return a two-element tuple
of its start and end indices, or an empty tuple if there is no such
range.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.tag_prevrange">
<span class="sig-name descname"><span class="pre">tag_prevrange</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">index1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index2</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.Text.tag_prevrange" title="Link to this definition">¶</a></dt>
<dd><p>Search backward from <em>index1</em> (down to <em>index2</em> if given) for the nearest
preceding range of characters tagged with <em>tagName</em>, and return a
two-element tuple of its start and end indices, or an empty tuple if
there is no such range.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.tag_raise">
<span class="sig-name descname"><span class="pre">tag_raise</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">aboveThis</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.Text.tag_raise" title="Link to this definition">¶</a></dt>
<dd><p>Raise the priority of tag <em>tagName</em> so that it is just above the priority
of <em>aboveThis</em>, or to the highest priority of all tags if <em>aboveThis</em> is
omitted.
When the display options of overlapping tags conflict, the
higher-priority tag wins.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.tag_lower">
<span class="sig-name descname"><span class="pre">tag_lower</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">belowThis</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.Text.tag_lower" title="Link to this definition">¶</a></dt>
<dd><p>Lower the priority of tag <em>tagName</em> so that it is just below the priority
of <em>belowThis</em>, or to the lowest priority of all tags if <em>belowThis</em> is
omitted.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.tag_bind">
<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></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">add</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.Text.tag_bind" title="Link to this definition">¶</a></dt>
<dd><p>Bind the event <em>sequence</em> on characters tagged with <em>tagName</em> to the
callback <em>func</em>, so that <em>func</em> is invoked when that event occurs over
such a character.
If <em>add</em> is true the binding is added alongside any existing bindings for
<em>sequence</em>, otherwise it replaces them.
Works like <a class="reference internal" href="#tkinter.Misc.bind" title="tkinter.Misc.bind"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bind()</span></code></a> and returns the identifier of the new
binding.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.tag_unbind">
<span class="sig-name descname"><span class="pre">tag_unbind</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></em>, <em class="sig-param"><span class="n"><span class="pre">funcid</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.Text.tag_unbind" title="Link to this definition">¶</a></dt>
<dd><p>Remove the bindings of the event <em>sequence</em> on characters tagged with
<em>tagName</em>.
If <em>funcid</em> is given, only that binding (as returned by <a class="reference internal" href="#tkinter.Text.tag_bind" title="tkinter.Text.tag_bind"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tag_bind()</span></code></a>)
is removed and its callback is unregistered.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.13: </span>If <em>funcid</em> is given, only that callback is unbound.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.image_create">
<span class="sig-name descname"><span class="pre">image_create</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Text.image_create" title="Link to this definition">¶</a></dt>
<dd><p>Embed an image at <em>index</em> and return the name assigned to this image
instance, which may then be used as an index or passed to the other
<code class="docutils literal notranslate"><span class="pre">image_*</span></code> methods.
The options, given in <em>cnf</em> and <em>kw</em>, include <em>image</em> (the Tk image to
display), <em>name</em> (a base name for the instance), <em>align</em>, <em>padx</em> and
<em>pady</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.image_cget">
<span class="sig-name descname"><span class="pre">image_cget</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">option</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.image_cget" title="Link to this definition">¶</a></dt>
<dd><p>Return the current value of the configuration option <em>option</em> for the
embedded image at <em>index</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.image_configure">
<span class="sig-name descname"><span class="pre">image_configure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</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.Text.image_configure" title="Link to this definition">¶</a></dt>
<dd><p>Query or modify the configuration options of the embedded image at
<em>index</em>, like <a class="reference internal" href="#tkinter.Misc.configure" title="tkinter.Misc.configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code></a> but applied to that image.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.image_names">
<span class="sig-name descname"><span class="pre">image_names</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.image_names" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of the names of all images embedded in the widget.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This shadows the inherited <a class="reference internal" href="#tkinter.Misc.image_names" title="tkinter.Misc.image_names"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.image_names()</span></code></a>,
which returns the names of all images in the Tcl interpreter;
that method is not available on a <code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code>.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.window_create">
<span class="sig-name descname"><span class="pre">window_create</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Text.window_create" title="Link to this definition">¶</a></dt>
<dd><p>Embed a window (any widget) at <em>index</em>.
The options, given in <em>cnf</em> and <em>kw</em>, include <em>window</em> (the widget to
embed), <em>create</em> (a callback that creates the widget on demand), <em>align</em>,
<em>stretch</em>, <em>padx</em> and <em>pady</em>.
The embedded widget must be a descendant of the text widget’s parent.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.window_cget">
<span class="sig-name descname"><span class="pre">window_cget</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">option</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.window_cget" title="Link to this definition">¶</a></dt>
<dd><p>Return the current value of the configuration option <em>option</em> for the
embedded window at <em>index</em>.</p>
</dd></dl>
<dl class="py method" id="tkinter.Text.window_config">
<dt class="sig sig-object py" id="tkinter.Text.window_configure">
<span class="sig-name descname"><span class="pre">window_configure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</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.Text.window_configure" title="Link to this definition">¶</a></dt>
<dd><p>Query or modify the configuration options of the embedded window at
<em>index</em>, like <a class="reference internal" href="#tkinter.Misc.configure" title="tkinter.Misc.configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code></a> but applied to that window.</p>
<p><a class="reference internal" href="#tkinter.Text.window_config" title="tkinter.Text.window_config"><code class="xref py py-meth docutils literal notranslate"><span class="pre">window_config()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">window_configure()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.window_names">
<span class="sig-name descname"><span class="pre">window_names</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.window_names" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of the names of all windows embedded in the widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.edit">
<span class="sig-name descname"><span class="pre">edit</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.Text.edit" title="Link to this definition">¶</a></dt>
<dd><p>Low-level wrapper around the Tk <code class="docutils literal notranslate"><span class="pre">edit</span></code> widget command that controls the
undo/redo mechanism and the modified flag; <em>args</em> is the <code class="docutils literal notranslate"><span class="pre">edit</span></code>
subcommand and its arguments.
The <code class="xref py py-meth docutils literal notranslate"><span class="pre">edit_*()</span></code> methods below are thin wrappers around it and are
usually more convenient.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.edit_modified">
<span class="sig-name descname"><span class="pre">edit_modified</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">arg</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.Text.edit_modified" title="Link to this definition">¶</a></dt>
<dd><p>If <em>arg</em> is omitted, return the current state of the modified flag as
true or false; the flag is set automatically whenever the text is
inserted or deleted.
Otherwise set the flag to the boolean <em>arg</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.edit_undo">
<span class="sig-name descname"><span class="pre">edit_undo</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.edit_undo" title="Link to this definition">¶</a></dt>
<dd><p>Undo the most recent edit action, that is, all the inserts and deletes
recorded on the undo stack since the previous separator, and move it to
the redo stack.
Raises <a class="reference internal" href="#tkinter.TclError" title="tkinter.TclError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TclError</span></code></a> if the undo stack is empty.
Has no effect unless the <em>undo</em> option is true.
Since Tk 9.0, returns a tuple of indices delimiting the ranges of text
that were changed.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.edit_redo">
<span class="sig-name descname"><span class="pre">edit_redo</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.edit_redo" title="Link to this definition">¶</a></dt>
<dd><p>Reapply the most recently undone edit action, provided no further edits
have been made since, and move it back to the undo stack.
Raises <a class="reference internal" href="#tkinter.TclError" title="tkinter.TclError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TclError</span></code></a> if the redo stack is empty.
Has no effect unless the <em>undo</em> option is true.
Since Tk 9.0, returns a tuple of indices delimiting the ranges of text
that were changed.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.edit_reset">
<span class="sig-name descname"><span class="pre">edit_reset</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.edit_reset" title="Link to this definition">¶</a></dt>
<dd><p>Clear the undo and redo stacks.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.edit_separator">
<span class="sig-name descname"><span class="pre">edit_separator</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.edit_separator" title="Link to this definition">¶</a></dt>
<dd><p>Push a separator onto the undo stack, marking a boundary between edit
actions for undo and redo.
Has no effect unless the <em>undo</em> option is true.
Separators are inserted automatically when the <em>autoseparators</em> option is
true.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.search">
<span class="sig-name descname"><span class="pre">search</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pattern</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">stopindex</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">forwards</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">backwards</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">exact</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">regexp</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">nocase</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">count</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">elide</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="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">nolinestop</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">strictlimits</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.Text.search" title="Link to this definition">¶</a></dt>
<dd><p>Search for <em>pattern</em> starting at <em>index</em> and return the index of the
first character of the first match, or an empty string if there is no
match.
Searching stops at <em>stopindex</em> if given; otherwise it wraps around the
ends of the text until the starting position is reached again.
The following boolean keyword flags control the search: <em>forwards</em> or
<em>backwards</em> select the direction (forward is the default); <em>exact</em> (the
default) or <em>regexp</em> select literal or regular-expression matching;
<em>nocase</em> makes the match case-insensitive; <em>elide</em> causes hidden text to
be searched as well; <em>nolinestop</em> (regexp only) lets <code class="docutils literal notranslate"><span class="pre">.</span></code> and <code class="docutils literal notranslate"><span class="pre">[^</span></code>
match newlines; and <em>strictlimits</em> requires the whole match to lie within
<em>index</em> and <em>stopindex</em>.
If <em>count</em> is a <a class="reference internal" href="#tkinter.Variable" title="tkinter.Variable"><code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code></a>, the number of index positions in the
match is stored in it.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.15: </span>Added the <em>nolinestop</em> and <em>strictlimits</em> parameters.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.search_all">
<span class="sig-name descname"><span class="pre">search_all</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pattern</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">stopindex</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="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">forwards</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">backwards</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">exact</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">regexp</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">nocase</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">count</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">elide</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">nolinestop</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">overlap</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">strictlimits</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.Text.search_all" title="Link to this definition">¶</a></dt>
<dd><p>Like <a class="reference internal" href="#tkinter.Text.search" title="tkinter.Text.search"><code class="xref py py-meth docutils literal notranslate"><span class="pre">search()</span></code></a>, but find every match in the searched range and
return a tuple of the starting indices of all matches (empty if there are
none).
By default overlapping matches are not reported; passing a true <em>overlap</em>
returns every match that is not wholly contained in another.
If <em>count</em> is a <a class="reference internal" href="#tkinter.Variable" title="tkinter.Variable"><code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code></a>, it receives a list with one element
per match.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.scan_mark">
<span class="sig-name descname"><span class="pre">scan_mark</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.Text.scan_mark" title="Link to this definition">¶</a></dt>
<dd><p>Record <em>x</em>, <em>y</em> and the current view, for use with later
<a class="reference internal" href="#tkinter.Text.scan_dragto" title="tkinter.Text.scan_dragto"><code class="xref py py-meth docutils literal notranslate"><span class="pre">scan_dragto()</span></code></a> calls.
This is typically bound to a mouse button press in the widget.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.scan_dragto">
<span class="sig-name descname"><span class="pre">scan_dragto</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.Text.scan_dragto" title="Link to this definition">¶</a></dt>
<dd><p>Scroll the widget by 10 times the difference between <em>x</em>, <em>y</em> and the
coordinates passed to the last <a class="reference internal" href="#tkinter.Text.scan_mark" title="tkinter.Text.scan_mark"><code class="xref py py-meth docutils literal notranslate"><span class="pre">scan_mark()</span></code></a> call.
This is typically bound to mouse motion events, producing the effect of
dragging the text at high speed through the window.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.debug">
<span class="sig-name descname"><span class="pre">debug</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">boolean</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.Text.debug" title="Link to this definition">¶</a></dt>
<dd><p>If <em>boolean</em> is omitted, return whether internal consistency checks of
the B-tree data structure are enabled.
Otherwise enable or disable them.
The setting is shared by all text widgets and may noticeably slow down
widgets holding large amounts of text.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.dump">
<span class="sig-name descname"><span class="pre">dump</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index2</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">command</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.Text.dump" title="Link to this definition">¶</a></dt>
<dd><p>Return the contents of the widget from <em>index1</em> up to but not including
<em>index2</em> (or just the segment at <em>index1</em> if <em>index2</em> is omitted),
including text and information about marks, tags, images and windows.
The result is a list of <code class="docutils literal notranslate"><span class="pre">(key,</span> <span class="pre">value,</span> <span class="pre">index)</span></code> triples, where <em>key</em> is
one of <code class="docutils literal notranslate"><span class="pre">'text'</span></code>, <code class="docutils literal notranslate"><span class="pre">'mark'</span></code>, <code class="docutils literal notranslate"><span class="pre">'tagon'</span></code>, <code class="docutils literal notranslate"><span class="pre">'tagoff'</span></code>, <code class="docutils literal notranslate"><span class="pre">'image'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'window'</span></code>.
By default all kinds are reported; passing any of the keyword arguments
<em>all</em>, <em>text</em>, <em>mark</em>, <em>tag</em>, <em>image</em> or <em>window</em> as true restricts the
dump to the selected kinds.
If <em>command</em> is given, it is called once per triple with the three values
as arguments and nothing is returned.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.peer_create">
<span class="sig-name descname"><span class="pre">peer_create</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newPathName</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</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.Text.peer_create" title="Link to this definition">¶</a></dt>
<dd><p>Create a peer text widget with the path name <em>newPathName</em> that shares
this widget’s underlying data (text, marks, tags, images and the undo
stack).
Changes made through any peer are reflected in all of them.
By default the peer covers the same lines as this widget; standard text
options, including <em>startline</em> and <em>endline</em>, may be given to override
this.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.3.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.peer_names">
<span class="sig-name descname"><span class="pre">peer_names</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.peer_names" title="Link to this definition">¶</a></dt>
<dd><p>Return a tuple of the path names of this widget’s peers, not including
the widget itself.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.3.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Text.yview_pickplace">
<span class="sig-name descname"><span class="pre">yview_pickplace</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">what</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Text.yview_pickplace" title="Link to this definition">¶</a></dt>
<dd><p>Adjust the view so that the location given by <em>what</em> is visible.
This is an obsolete equivalent of <a class="reference internal" href="#tkinter.Text.see" title="tkinter.Text.see"><code class="xref py py-meth docutils literal notranslate"><span class="pre">see()</span></code></a>, which should be used
instead.</p>
</dd></dl>
</dd></dl>
</section>
<section id="variable-classes">
<h3>Variable classes<a class="headerlink" href="#variable-classes" title="Link to this heading">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Variable">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Variable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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>, <em class="sig-param"><span class="n"><span class="pre">name</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.Variable" title="Link to this definition">¶</a></dt>
<dd><p>The base class for the Tk variable wrappers.
A Tk variable is a value stored in the Tcl interpreter that can be linked to
widgets through their <em>variable</em> or <em>textvariable</em> options (see
<a class="reference internal" href="#coupling-widget-variables"><span class="std std-ref">Coupling widget variables</span></a>), so that changes propagate both ways:
updating the variable updates every widget bound to it, and a user editing
such a widget updates the variable.</p>
<p><em>master</em> is the widget whose Tcl interpreter owns the variable; if omitted,
the default root window is used.
<em>value</em> is the initial value; if omitted, a type-specific default is used.
<em>name</em> is the name of the variable in the Tcl interpreter; if omitted, a
unique name of the form <code class="docutils literal notranslate"><span class="pre">'PY_VARnum'</span></code> is generated.
If <em>name</em> matches an existing variable and <em>value</em> is omitted, the existing
value is retained.</p>
<p>In most cases you should use one of the typed subclasses below –
<a class="reference internal" href="#tkinter.StringVar" title="tkinter.StringVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">StringVar</span></code></a>, <a class="reference internal" href="#tkinter.IntVar" title="tkinter.IntVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">IntVar</span></code></a>, <a class="reference internal" href="#tkinter.DoubleVar" title="tkinter.DoubleVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">DoubleVar</span></code></a> or
<a class="reference internal" href="#tkinter.BooleanVar" title="tkinter.BooleanVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">BooleanVar</span></code></a> – rather than <code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code> directly.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>When a <code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code> is garbage collected, its Tcl variable is unset.
Keep a reference to it for as long as a widget is linked to it, for example
by storing it as an attribute rather than in a local variable.
Otherwise Tk recreates the Tcl variable to keep the widget working, but it
is never unset again, leaking one Tcl variable per dropped wrapper.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.10: </span>Two variables now compare equal (<code class="docutils literal notranslate"><span class="pre">==</span></code>) only when they have the same
name, are of the same class, and belong to the same Tcl interpreter.</p>
</div>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Variable.get">
<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.Variable.get" title="Link to this definition">¶</a></dt>
<dd><p>Return the current value of the variable.
For the base class the value is returned as a string; the typed
subclasses convert it to the appropriate Python type.</p>
</dd></dl>
<dl class="py method" id="tkinter.Variable.initialize">
<dt class="sig sig-object py" id="tkinter.Variable.set">
<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.Variable.set" title="Link to this definition">¶</a></dt>
<dd><p>Set the variable to <em>value</em>.
<a class="reference internal" href="#tkinter.Variable.initialize" title="tkinter.Variable.initialize"><code class="xref py py-meth docutils literal notranslate"><span class="pre">initialize()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.3: </span>The <em>initialize</em> spelling.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Variable.trace_add">
<span class="sig-name descname"><span class="pre">trace_add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mode</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">callback</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Variable.trace_add" title="Link to this definition">¶</a></dt>
<dd><p>Register <em>callback</em> to be called when the variable is accessed according
to <em>mode</em>.
<em>mode</em> is one of the strings <code class="docutils literal notranslate"><span class="pre">'array'</span></code>, <code class="docutils literal notranslate"><span class="pre">'read'</span></code>, <code class="docutils literal notranslate"><span class="pre">'write'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'unset'</span></code>, or a list or tuple of such strings.</p>
<p>When triggered, <em>callback</em> is called with three arguments: the name of
the Tcl variable, an index (or an empty string if the variable is not an
element of an array), and the <em>mode</em> that triggered the call.</p>
<p>Return the internal name of the registered callback, which can be passed
to <a class="reference internal" href="#tkinter.Variable.trace_remove" title="tkinter.Variable.trace_remove"><code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_remove()</span></code></a>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.6.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Variable.trace_remove">
<span class="sig-name descname"><span class="pre">trace_remove</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mode</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cbname</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Variable.trace_remove" title="Link to this definition">¶</a></dt>
<dd><p>Remove a trace callback from the variable.
<em>mode</em> must match the <em>mode</em> that was passed to <a class="reference internal" href="#tkinter.Variable.trace_add" title="tkinter.Variable.trace_add"><code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_add()</span></code></a>, and
<em>cbname</em> is the callback name returned by <code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_add()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.6.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Variable.trace_info">
<span class="sig-name descname"><span class="pre">trace_info</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Variable.trace_info" title="Link to this definition">¶</a></dt>
<dd><p>Return a list of <code class="docutils literal notranslate"><span class="pre">(modes,</span> <span class="pre">cbname)</span></code> pairs describing all traces
currently set on the variable, where <em>modes</em> is a tuple of mode strings
and <em>cbname</em> is the internal callback name.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.6.</span></p>
</div>
</dd></dl>
<dl class="py method" id="tkinter.Variable.trace">
<dt class="sig sig-object py" id="tkinter.Variable.trace_variable">
<span class="sig-name descname"><span class="pre">trace_variable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mode</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">callback</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Variable.trace_variable" title="Link to this definition">¶</a></dt>
<dd><p>Register <em>callback</em> to be called when the variable is accessed according
to <em>mode</em>.
<em>mode</em> is one of the strings <code class="docutils literal notranslate"><span class="pre">'r'</span></code>, <code class="docutils literal notranslate"><span class="pre">'w'</span></code> or <code class="docutils literal notranslate"><span class="pre">'u'</span></code>, for read, write
or unset.
Return the internal name of the registered callback.
<a class="reference internal" href="trace.html#module-trace" title="trace: Trace or track Python statement execution."><code class="xref py py-meth docutils literal notranslate"><span class="pre">trace()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_variable()</span></code>.</p>
<div class="deprecated">
<p><span class="versionmodified deprecated">Deprecated since version 3.6: </span>Use <a class="reference internal" href="#tkinter.Variable.trace_add" title="tkinter.Variable.trace_add"><code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_add()</span></code></a> instead. This method wraps a Tcl feature that
was removed in Tcl 9.0.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Variable.trace_vdelete">
<span class="sig-name descname"><span class="pre">trace_vdelete</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mode</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cbname</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Variable.trace_vdelete" title="Link to this definition">¶</a></dt>
<dd><p>Remove the trace callback named <em>cbname</em> registered for <em>mode</em> with
<a class="reference internal" href="#tkinter.Variable.trace_variable" title="tkinter.Variable.trace_variable"><code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_variable()</span></code></a>.</p>
<div class="deprecated">
<p><span class="versionmodified deprecated">Deprecated since version 3.6: </span>Use <a class="reference internal" href="#tkinter.Variable.trace_remove" title="tkinter.Variable.trace_remove"><code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_remove()</span></code></a> instead. This method wraps a Tcl feature
that was removed in Tcl 9.0.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Variable.trace_vinfo">
<span class="sig-name descname"><span class="pre">trace_vinfo</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Variable.trace_vinfo" title="Link to this definition">¶</a></dt>
<dd><p>Return a list of <code class="docutils literal notranslate"><span class="pre">(mode,</span> <span class="pre">cbname)</span></code> pairs for all traces set on the
variable with <a class="reference internal" href="#tkinter.Variable.trace_variable" title="tkinter.Variable.trace_variable"><code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_variable()</span></code></a>.</p>
<div class="deprecated">
<p><span class="versionmodified deprecated">Deprecated since version 3.6: </span>Use <a class="reference internal" href="#tkinter.Variable.trace_info" title="tkinter.Variable.trace_info"><code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_info()</span></code></a> instead. This method wraps a Tcl feature that
was removed in Tcl 9.0.</p>
</div>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.StringVar">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">StringVar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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>, <em class="sig-param"><span class="n"><span class="pre">name</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.StringVar" title="Link to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="#tkinter.Variable" title="tkinter.Variable"><code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code></a> subclass that holds a string.
The default value is <code class="docutils literal notranslate"><span class="pre">''</span></code>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.StringVar.get">
<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.StringVar.get" title="Link to this definition">¶</a></dt>
<dd><p>Return the value of the variable as a <a class="reference internal" href="stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.IntVar">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">IntVar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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>, <em class="sig-param"><span class="n"><span class="pre">name</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.IntVar" title="Link to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="#tkinter.Variable" title="tkinter.Variable"><code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code></a> subclass that holds an integer.
The default value is <code class="docutils literal notranslate"><span class="pre">0</span></code>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.IntVar.get">
<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.IntVar.get" title="Link to this definition">¶</a></dt>
<dd><p>Return the value of the variable as an <a class="reference internal" href="functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.DoubleVar">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">DoubleVar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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>, <em class="sig-param"><span class="n"><span class="pre">name</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.DoubleVar" title="Link to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="#tkinter.Variable" title="tkinter.Variable"><code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code></a> subclass that holds a float.
The default value is <code class="docutils literal notranslate"><span class="pre">0.0</span></code>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.DoubleVar.get">
<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.DoubleVar.get" title="Link to this definition">¶</a></dt>
<dd><p>Return the value of the variable as a <a class="reference internal" href="functions.html#float" title="float"><code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code></a>.</p>
</dd></dl>
<div class="admonition note" id="tkinter-numeric-locale">
<p class="admonition-title">Note</p>
<p>A floating-point value is always parsed with a period (<code class="docutils literal notranslate"><span class="pre">.</span></code>) as the
decimal separator, but <a class="reference internal" href="#tkinter.Spinbox" title="tkinter.Spinbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Spinbox</span></code></a>, <a class="reference internal" href="#tkinter.Scale" title="tkinter.Scale"><code class="xref py py-class docutils literal notranslate"><span class="pre">Scale</span></code></a> and
<a class="reference internal" href="tkinter.ttk.html#tkinter.ttk.Spinbox" title="tkinter.ttk.Spinbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">ttk.Spinbox</span></code></a> format it according to the
<code class="docutils literal notranslate"><span class="pre">LC_NUMERIC</span></code> locale. Under a locale that uses a comma they produce a
value that <a class="reference internal" href="#tkinter.DoubleVar.get" title="tkinter.DoubleVar.get"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get()</span></code></a> cannot read, raising <a class="reference internal" href="#tkinter.TclError" title="tkinter.TclError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TclError</span></code></a>. Set
<code class="docutils literal notranslate"><span class="pre">LC_NUMERIC</span></code> to a locale that uses a period (such as <code class="docutils literal notranslate"><span class="pre">'C'</span></code>) to avoid
this.</p>
</div>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.BooleanVar">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">BooleanVar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">master</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>, <em class="sig-param"><span class="n"><span class="pre">name</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.BooleanVar" title="Link to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="#tkinter.Variable" title="tkinter.Variable"><code class="xref py py-class docutils literal notranslate"><span class="pre">Variable</span></code></a> subclass that holds a boolean.
The default value is <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.BooleanVar.get">
<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.BooleanVar.get" title="Link to this definition">¶</a></dt>
<dd><p>Return the value of the variable as a <a class="reference internal" href="functions.html#bool" title="bool"><code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code></a>.
Raise a <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> if the value cannot be interpreted as a
boolean.</p>
</dd></dl>
<dl class="py method" id="tkinter.BooleanVar.initialize">
<dt class="sig sig-object py" id="tkinter.BooleanVar.set">
<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.BooleanVar.set" title="Link to this definition">¶</a></dt>
<dd><p>Set the variable to <em>value</em>, converting it to a boolean.
<a class="reference internal" href="#tkinter.BooleanVar.initialize" title="tkinter.BooleanVar.initialize"><code class="xref py py-meth docutils literal notranslate"><span class="pre">initialize()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.3: </span>The <em>initialize</em> spelling.</p>
</div>
</dd></dl>
</dd></dl>
</section>
<section id="image-classes">
<h3>Image classes<a class="headerlink" href="#image-classes" title="Link to this heading">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Image">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Image</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">imgtype</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">master</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.Image" title="Link to this definition">¶</a></dt>
<dd><p>Base class for Tk images.
<em>imgtype</em> is the Tk image type, one of <code class="docutils literal notranslate"><span class="pre">'photo'</span></code> or <code class="docutils literal notranslate"><span class="pre">'bitmap'</span></code>.
An image is a named object that can be displayed by widgets through their
<em>image</em> option; deleting all references to the <code class="xref py py-class docutils literal notranslate"><span class="pre">Image</span></code> object
deletes the underlying Tk image.
Usually you create a <a class="reference internal" href="#tkinter.PhotoImage" title="tkinter.PhotoImage"><code class="xref py py-class docutils literal notranslate"><span class="pre">PhotoImage</span></code></a> or <a class="reference internal" href="#tkinter.BitmapImage" title="tkinter.BitmapImage"><code class="xref py py-class docutils literal notranslate"><span class="pre">BitmapImage</span></code></a> rather than
an <code class="xref py py-class docutils literal notranslate"><span class="pre">Image</span></code> directly.</p>
<p>The image’s configuration options are given by <em>cnf</em> and <em>kw</em> and may be
queried and changed later with the mapping protocol (using <code class="docutils literal notranslate"><span class="pre">image[key]</span></code>)
or with the <a class="reference internal" href="#tkinter.Image.configure" title="tkinter.Image.configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code></a> method.</p>
<dl class="py method" id="tkinter.Image.config">
<dt class="sig sig-object py" id="tkinter.Image.configure">
<span class="sig-name descname"><span class="pre">configure</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">kw</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Image.configure" title="Link to this definition">¶</a></dt>
<dd><p>Modify one or more configuration options of the image.
The valid options depend on the image type; see <a class="reference internal" href="#tkinter.PhotoImage" title="tkinter.PhotoImage"><code class="xref py py-class docutils literal notranslate"><span class="pre">PhotoImage</span></code></a> and
<a class="reference internal" href="#tkinter.BitmapImage" title="tkinter.BitmapImage"><code class="xref py py-class docutils literal notranslate"><span class="pre">BitmapImage</span></code></a>.
<a class="reference internal" href="#tkinter.Image.config" title="tkinter.Image.config"><code class="xref py py-meth docutils literal notranslate"><span class="pre">config()</span></code></a> is an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Image.height">
<span class="sig-name descname"><span class="pre">height</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Image.height" title="Link to this definition">¶</a></dt>
<dd><p>Return the height of the image, in pixels.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Image.width">
<span class="sig-name descname"><span class="pre">width</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Image.width" title="Link to this definition">¶</a></dt>
<dd><p>Return the width of the image, in pixels.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Image.type">
<span class="sig-name descname"><span class="pre">type</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Image.type" title="Link to this definition">¶</a></dt>
<dd><p>Return the type of the image, that is the value of <em>imgtype</em> with which
it was created (for example <code class="docutils literal notranslate"><span class="pre">'photo'</span></code> or <code class="docutils literal notranslate"><span class="pre">'bitmap'</span></code>).</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.PhotoImage">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">PhotoImage</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">master</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.PhotoImage" title="Link to this definition">¶</a></dt>
<dd><p>A full-color image (the Tk <code class="docutils literal notranslate"><span class="pre">photo</span></code> image type), stored internally with a
varying degree of transparency per pixel.
It can read and write GIF, PPM/PGM and (in Tk 8.6 and later) PNG files, read
SVG files (in Tk 9.0 and later), and be drawn in widgets.
Inherits from <a class="reference internal" href="#tkinter.Image" title="tkinter.Image"><code class="xref py py-class docutils literal notranslate"><span class="pre">Image</span></code></a>.</p>
<p>The configuration options include <em>data</em> (the image contents as a string),
<em>file</em> (the name of a file to read the contents from), <em>format</em> (the name of
the file format handler), <em>width</em> and <em>height</em> (the size of the image, used
when building it up piece by piece), <em>gamma</em> and <em>palette</em>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PhotoImage.blank">
<span class="sig-name descname"><span class="pre">blank</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.PhotoImage.blank" title="Link to this definition">¶</a></dt>
<dd><p>Blank the image; that is, set the entire image to have no data, so that
it is displayed as transparent and the background of whatever window it
is displayed in shows through.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PhotoImage.cget">
<span class="sig-name descname"><span class="pre">cget</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">option</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.PhotoImage.cget" title="Link to this definition">¶</a></dt>
<dd><p>Return the current value of the configuration option <em>option</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PhotoImage.copy">
<span class="sig-name descname"><span class="pre">copy</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">from_coords</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">zoom</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">subsample</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.PhotoImage.copy" title="Link to this definition">¶</a></dt>
<dd><p>Return a new <code class="xref py py-class docutils literal notranslate"><span class="pre">PhotoImage</span></code> with a copy of this image.</p>
<p><em>from_coords</em> specifies a rectangular sub-region of the source image to
be copied.
It must be a tuple or a list of 1 to 4 integers <code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1,</span> <span class="pre">x2,</span> <span class="pre">y2)</span></code>.
<code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1)</span></code> and <code class="docutils literal notranslate"><span class="pre">(x2,</span> <span class="pre">y2)</span></code> specify diagonally opposite corners of the
rectangle.
If <em>x2</em> and <em>y2</em> are not specified, they default to the bottom-right
corner of the source image.
The pixels copied include the left and top edges of the rectangle but not
the bottom or right edges.
If <em>from_coords</em> is not given, the whole source image is copied.</p>
<p>If <em>zoom</em> or <em>subsample</em> are specified, the image is transformed as in
the <a class="reference internal" href="#tkinter.PhotoImage.zoom" title="tkinter.PhotoImage.zoom"><code class="xref py py-meth docutils literal notranslate"><span class="pre">zoom()</span></code></a> or <a class="reference internal" href="#tkinter.PhotoImage.subsample" title="tkinter.PhotoImage.subsample"><code class="xref py py-meth docutils literal notranslate"><span class="pre">subsample()</span></code></a> methods.
The value must be a single integer or a pair of integers.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.13: </span>Added the <em>from_coords</em>, <em>zoom</em> and <em>subsample</em> parameters.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PhotoImage.copy_replace">
<span class="sig-name descname"><span class="pre">copy_replace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sourceImage</span></span></em>, <em class="sig-param"><span class="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">from_coords</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">to</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">shrink</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">zoom</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">subsample</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">compositingrule</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.PhotoImage.copy_replace" title="Link to this definition">¶</a></dt>
<dd><p>Copy a region from <em>sourceImage</em> (which must be a <code class="xref py py-class docutils literal notranslate"><span class="pre">PhotoImage</span></code>)
into this image, possibly with pixel zooming and/or subsampling.
If no options are specified, the whole of <em>sourceImage</em> is copied into
this image, starting at coordinates <code class="docutils literal notranslate"><span class="pre">(0,</span> <span class="pre">0)</span></code>.</p>
<p><em>from_coords</em> specifies a rectangular sub-region of the source image to
be copied, as in the <a class="reference internal" href="copy.html#module-copy" title="copy: Shallow and deep copy operations."><code class="xref py py-meth docutils literal notranslate"><span class="pre">copy()</span></code></a> method.</p>
<p><em>to</em> specifies a rectangular sub-region of the destination image to be
affected.
It must be a tuple or a list of 1 to 4 integers <code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1,</span> <span class="pre">x2,</span> <span class="pre">y2)</span></code>.
If <em>x2</em> and <em>y2</em> are not specified, they default to <code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1)</span></code> plus the
size of the source region (after subsampling and zooming, if specified).
If <em>x2</em> and <em>y2</em> are specified, the source region is replicated if
necessary to fill the destination region in a tiled fashion.</p>
<p>If <em>shrink</em> is true, the size of the destination image is reduced, if
necessary, so that the region being copied into is at the bottom-right
corner of the image.</p>
<p>If <em>zoom</em> or <em>subsample</em> are specified, the image is transformed as in
the <a class="reference internal" href="#tkinter.PhotoImage.zoom" title="tkinter.PhotoImage.zoom"><code class="xref py py-meth docutils literal notranslate"><span class="pre">zoom()</span></code></a> or <a class="reference internal" href="#tkinter.PhotoImage.subsample" title="tkinter.PhotoImage.subsample"><code class="xref py py-meth docutils literal notranslate"><span class="pre">subsample()</span></code></a> methods.
The value must be a single integer or a pair of integers.</p>
<p><em>compositingrule</em> specifies how transparent pixels in the source image
are combined with the destination image.
With <code class="docutils literal notranslate"><span class="pre">'overlay'</span></code> (the default), the old contents of the destination
image remain visible, as if the source image were printed on a piece of
transparent film and placed over the top of the destination.
With <code class="docutils literal notranslate"><span class="pre">'set'</span></code>, the old contents of the destination image are discarded
and the source image is used as-is.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PhotoImage.data">
<span class="sig-name descname"><span class="pre">data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">format</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="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">from_coords</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">background</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">grayscale</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.PhotoImage.data" title="Link to this definition">¶</a></dt>
<dd><p>Return the image data.</p>
<p><em>format</em> specifies the name of the image file format handler to use.
If it is not given, the data is returned as a tuple (one element per row)
of strings containing space-separated (one element per pixel/column)
colors in <code class="docutils literal notranslate"><span class="pre">#RRGGBB</span></code> format.</p>
<p><em>from_coords</em> specifies a rectangular region of the image to be returned.
It must be a tuple or a list of 1 to 4 integers <code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1,</span> <span class="pre">x2,</span> <span class="pre">y2)</span></code>.
If only <em>x1</em> and <em>y1</em> are specified, the region extends from <code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1)</span></code>
to the bottom-right corner of the image.
If all four coordinates are given, they specify diagonally opposite
corners of the region, including <code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1)</span></code> and excluding <code class="docutils literal notranslate"><span class="pre">(x2,</span> <span class="pre">y2)</span></code>.
If <em>from_coords</em> is not given, the whole image is returned.</p>
<p>If <em>background</em> is specified, the data does not contain any transparency
information; in all transparent pixels the color is replaced by the
specified color.</p>
<p>If <em>grayscale</em> is true, the data does not contain color information; all
pixel data is transformed into grayscale.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PhotoImage.get">
<span class="sig-name descname"><span class="pre">get</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.PhotoImage.get" title="Link to this definition">¶</a></dt>
<dd><p>Return the color of the pixel at coordinates (<em>x</em>, <em>y</em>) as an
<code class="docutils literal notranslate"><span class="pre">(r,</span> <span class="pre">g,</span> <span class="pre">b)</span></code> tuple of three integers between 0 and 255, representing the
red, green and blue components respectively.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PhotoImage.put">
<span class="sig-name descname"><span class="pre">put</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">to</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.PhotoImage.put" title="Link to this definition">¶</a></dt>
<dd><p>Set pixels of the image to the colors given in <em>data</em>, which must be a
string or a nested sequence of horizontal rows of pixel colors (for
example <code class="docutils literal notranslate"><span class="pre">"{red</span> <span class="pre">green}</span> <span class="pre">{blue</span> <span class="pre">yellow}"</span></code>).</p>
<p><em>to</em> specifies the coordinates of the region of the image into which the
data are copied.
It must be a tuple or a list of 2 or 4 integers <code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1)</span></code> or
<code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1,</span> <span class="pre">x2,</span> <span class="pre">y2)</span></code> giving the top-left corner, and optionally the
bottom-right corner, of the region.
The default position is <code class="docutils literal notranslate"><span class="pre">(0,</span> <span class="pre">0)</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PhotoImage.read">
<span class="sig-name descname"><span class="pre">read</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">format</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="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">from_coords</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">to</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">shrink</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.PhotoImage.read" title="Link to this definition">¶</a></dt>
<dd><p>Read image data from the file named <em>filename</em> into the image.</p>
<p><em>format</em> specifies the format of the image data in the file.</p>
<p><em>from_coords</em> specifies a rectangular sub-region of the image file data
to be copied to the destination image.
It must be a tuple or a list of 1 to 4 integers <code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1,</span> <span class="pre">x2,</span> <span class="pre">y2)</span></code>.
If only <em>x1</em> and <em>y1</em> are specified, the region extends from <code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1)</span></code>
to the bottom-right corner of the image in the file.
If all four coordinates are given, they specify diagonally opposite
corners of the region.
If <em>from_coords</em> is not given, the whole of the image in the file is
read.</p>
<p><em>to</em> specifies the coordinates of the top-left corner of the region of
the image into which the data are read.
The default is <code class="docutils literal notranslate"><span class="pre">(0,</span> <span class="pre">0)</span></code>.</p>
<p>If <em>shrink</em> is true, the size of the image is reduced, if necessary, so
that the region into which the file data are read is at the bottom-right
corner of the image.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PhotoImage.subsample">
<span class="sig-name descname"><span class="pre">subsample</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><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">from_coords</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.PhotoImage.subsample" title="Link to this definition">¶</a></dt>
<dd><p>Return a new <code class="xref py py-class docutils literal notranslate"><span class="pre">PhotoImage</span></code> based on this image but using only every
<em>x</em>-th pixel in the X direction and every <em>y</em>-th pixel in the Y
direction.
If <em>y</em> is not given, it defaults to the same value as <em>x</em>.</p>
<p><em>from_coords</em> specifies a rectangular sub-region of the source image to
be copied, as in the <a class="reference internal" href="copy.html#module-copy" title="copy: Shallow and deep copy operations."><code class="xref py py-meth docutils literal notranslate"><span class="pre">copy()</span></code></a> method.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.13: </span>Added the <em>from_coords</em> parameter.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PhotoImage.transparency_get">
<span class="sig-name descname"><span class="pre">transparency_get</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.PhotoImage.transparency_get" title="Link to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the pixel at coordinates (<em>x</em>, <em>y</em>) is fully
transparent, <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.8.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PhotoImage.transparency_set">
<span class="sig-name descname"><span class="pre">transparency_set</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>, <em class="sig-param"><span class="n"><span class="pre">boolean</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.PhotoImage.transparency_set" title="Link to this definition">¶</a></dt>
<dd><p>Make the pixel at coordinates (<em>x</em>, <em>y</em>) fully transparent if <em>boolean</em>
is true, fully opaque otherwise.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.8.</span></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PhotoImage.write">
<span class="sig-name descname"><span class="pre">write</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">format</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">from_coords</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="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">background</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">grayscale</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.PhotoImage.write" title="Link to this definition">¶</a></dt>
<dd><p>Write image data from the image to the file named <em>filename</em>.</p>
<p><em>format</em> specifies the name of the image file format handler to use.
If it is not given, the format is guessed from the file extension.</p>
<p><em>from_coords</em> specifies a rectangular region of the image to be written.
It must be a tuple or a list of 1 to 4 integers <code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1,</span> <span class="pre">x2,</span> <span class="pre">y2)</span></code>.
If only <em>x1</em> and <em>y1</em> are specified, the region extends from <code class="docutils literal notranslate"><span class="pre">(x1,</span> <span class="pre">y1)</span></code>
to the bottom-right corner of the image.
If all four coordinates are given, they specify diagonally opposite
corners of the region.
If <em>from_coords</em> is not given, the whole image is written.</p>
<p>If <em>background</em> is specified, the data does not contain any transparency
information; in all transparent pixels the color is replaced by the
specified color.</p>
<p>If <em>grayscale</em> is true, the data does not contain color information; all
pixel data is transformed into grayscale.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.13: </span>Added the <em>background</em> and <em>grayscale</em> parameters.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.PhotoImage.zoom">
<span class="sig-name descname"><span class="pre">zoom</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><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">from_coords</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.PhotoImage.zoom" title="Link to this definition">¶</a></dt>
<dd><p>Return a new <code class="xref py py-class docutils literal notranslate"><span class="pre">PhotoImage</span></code> with this image magnified by a factor of
<em>x</em> in the X direction and <em>y</em> in the Y direction.
If <em>y</em> is not given, it defaults to the same value as <em>x</em>.</p>
<p><em>from_coords</em> specifies a rectangular sub-region of the source image to
be copied, as in the <a class="reference internal" href="copy.html#module-copy" title="copy: Shallow and deep copy operations."><code class="xref py py-meth docutils literal notranslate"><span class="pre">copy()</span></code></a> method.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.13: </span>Added the <em>from_coords</em> parameter.</p>
</div>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.BitmapImage">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">BitmapImage</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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">cnf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">master</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.BitmapImage" title="Link to this definition">¶</a></dt>
<dd><p>A two-color image (the Tk <code class="docutils literal notranslate"><span class="pre">bitmap</span></code> image type) created from an X11 bitmap.
Each pixel displays a foreground color, a background color, or nothing
(producing a transparent effect).
Inherits from <a class="reference internal" href="#tkinter.Image" title="tkinter.Image"><code class="xref py py-class docutils literal notranslate"><span class="pre">Image</span></code></a>.</p>
<p>The configuration options are <em>data</em> or <em>file</em> (the source bitmap, given as
a string in X11 bitmap format or as the name of a file in that format),
<em>maskdata</em> or <em>maskfile</em> (the mask bitmap, in the same forms), and
<em>foreground</em> and <em>background</em> (the two colors).
For pixels where the mask is zero the image displays nothing; for other
pixels it displays the foreground color where the source is one and the
background color where the source is zero.
If <em>background</em> is set to an empty string, the background pixels are
transparent.</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">BitmapImage</span></code> has no methods of its own beyond those inherited from
<a class="reference internal" href="#tkinter.Image" title="tkinter.Image"><code class="xref py py-class docutils literal notranslate"><span class="pre">Image</span></code></a>.</p>
</dd></dl>
</section>
<section id="other-classes">
<h3>Other classes<a class="headerlink" href="#other-classes" title="Link to this heading">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.Event">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Event</span></span><a class="headerlink" href="#tkinter.Event" title="Link to this definition">¶</a></dt>
<dd><p>A container for the attributes of an event passed to a callback bound with
<a class="reference internal" href="#tkinter.Misc.bind" title="tkinter.Misc.bind"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.bind()</span></code></a>.
An <code class="xref py py-class docutils literal notranslate"><span class="pre">Event</span></code> instance has the following attributes, each corresponding
to a field of the underlying Tk event; depending on the event type, some
attributes may be set to the string <code class="docutils literal notranslate"><span class="pre">'??'</span></code> to indicate that they are not
meaningful.
See <a class="reference internal" href="#bindings-and-events"><span class="std std-ref">Bindings and events</span></a>.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.serial">
<span class="sig-name descname"><span class="pre">serial</span></span><a class="headerlink" href="#tkinter.Event.serial" title="Link to this definition">¶</a></dt>
<dd><p>The serial number of the event.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.num">
<span class="sig-name descname"><span class="pre">num</span></span><a class="headerlink" href="#tkinter.Event.num" title="Link to this definition">¶</a></dt>
<dd><p>The mouse button that was pressed or released (for button events).</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.focus">
<span class="sig-name descname"><span class="pre">focus</span></span><a class="headerlink" href="#tkinter.Event.focus" title="Link to this definition">¶</a></dt>
<dd><p>Whether the window has the focus (for <code class="docutils literal notranslate"><span class="pre">Enter</span></code> and <code class="docutils literal notranslate"><span class="pre">Leave</span></code> events).</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.height">
<span class="sig-name descname"><span class="pre">height</span></span><a class="headerlink" href="#tkinter.Event.height" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Event.width">
<span class="sig-name descname"><span class="pre">width</span></span><a class="headerlink" href="#tkinter.Event.width" title="Link to this definition">¶</a></dt>
<dd><p>The new height and width of the window (for <code class="docutils literal notranslate"><span class="pre">Configure</span></code> and <code class="docutils literal notranslate"><span class="pre">Expose</span></code>
events).</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.keycode">
<span class="sig-name descname"><span class="pre">keycode</span></span><a class="headerlink" href="#tkinter.Event.keycode" title="Link to this definition">¶</a></dt>
<dd><p>The keycode of the key that was pressed or released.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.state">
<span class="sig-name descname"><span class="pre">state</span></span><a class="headerlink" href="#tkinter.Event.state" title="Link to this definition">¶</a></dt>
<dd><p>The state of the event, as a number (for most events) or a string (for
<code class="docutils literal notranslate"><span class="pre">Visibility</span></code> events).</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.time">
<span class="sig-name descname"><span class="pre">time</span></span><a class="headerlink" href="#tkinter.Event.time" title="Link to this definition">¶</a></dt>
<dd><p>The timestamp of the event, in milliseconds.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.x">
<span class="sig-name descname"><span class="pre">x</span></span><a class="headerlink" href="#tkinter.Event.x" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Event.y">
<span class="sig-name descname"><span class="pre">y</span></span><a class="headerlink" href="#tkinter.Event.y" title="Link to this definition">¶</a></dt>
<dd><p>The pointer position relative to the widget, in pixels.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.x_root">
<span class="sig-name descname"><span class="pre">x_root</span></span><a class="headerlink" href="#tkinter.Event.x_root" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Event.y_root">
<span class="sig-name descname"><span class="pre">y_root</span></span><a class="headerlink" href="#tkinter.Event.y_root" title="Link to this definition">¶</a></dt>
<dd><p>The pointer position relative to the top-left corner of the screen, in
pixels.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.char">
<span class="sig-name descname"><span class="pre">char</span></span><a class="headerlink" href="#tkinter.Event.char" title="Link to this definition">¶</a></dt>
<dd><p>The character typed, as a string (for key events).</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.send_event">
<span class="sig-name descname"><span class="pre">send_event</span></span><a class="headerlink" href="#tkinter.Event.send_event" title="Link to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">True</span></code> if the event was sent by another application.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.keysym">
<span class="sig-name descname"><span class="pre">keysym</span></span><a class="headerlink" href="#tkinter.Event.keysym" title="Link to this definition">¶</a></dt>
<dd><p>The symbolic name of the key that was pressed or released.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.keysym_num">
<span class="sig-name descname"><span class="pre">keysym_num</span></span><a class="headerlink" href="#tkinter.Event.keysym_num" title="Link to this definition">¶</a></dt>
<dd><p>The numeric value of <a class="reference internal" href="#tkinter.Event.keysym" title="tkinter.Event.keysym"><code class="xref py py-attr docutils literal notranslate"><span class="pre">keysym</span></code></a>.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.type">
<span class="sig-name descname"><span class="pre">type</span></span><a class="headerlink" href="#tkinter.Event.type" title="Link to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#tkinter.EventType" title="tkinter.EventType"><code class="xref py py-class docutils literal notranslate"><span class="pre">EventType</span></code></a> of the event.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.widget">
<span class="sig-name descname"><span class="pre">widget</span></span><a class="headerlink" href="#tkinter.Event.widget" title="Link to this definition">¶</a></dt>
<dd><p>The widget on which the event occurred.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.delta">
<span class="sig-name descname"><span class="pre">delta</span></span><a class="headerlink" href="#tkinter.Event.delta" title="Link to this definition">¶</a></dt>
<dd><p>The amount the mouse wheel was rotated (for <code class="docutils literal notranslate"><span class="pre">MouseWheel</span></code> events).</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.user_data">
<span class="sig-name descname"><span class="pre">user_data</span></span><a class="headerlink" href="#tkinter.Event.user_data" title="Link to this definition">¶</a></dt>
<dd><p>The data string of a virtual event, as passed to the <em>data</em> option of
<a class="reference internal" href="#tkinter.Misc.event_generate" title="tkinter.Misc.event_generate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.event_generate()</span></code></a>.
It is <code class="docutils literal notranslate"><span class="pre">'??'</span></code> for non-virtual events.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15.</span></p>
</div>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tkinter.Event.detail">
<span class="sig-name descname"><span class="pre">detail</span></span><a class="headerlink" href="#tkinter.Event.detail" title="Link to this definition">¶</a></dt>
<dd><p>A fixed detail string for <code class="docutils literal notranslate"><span class="pre">Enter</span></code>, <code class="docutils literal notranslate"><span class="pre">Leave</span></code>, <code class="docutils literal notranslate"><span class="pre">FocusIn</span></code>, <code class="docutils literal notranslate"><span class="pre">FocusOut</span></code>
and <code class="docutils literal notranslate"><span class="pre">ConfigureRequest</span></code> events (see the Tcl/Tk documentation).
It is <code class="docutils literal notranslate"><span class="pre">'??'</span></code> for other events.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15.</span></p>
</div>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.EventType">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">EventType</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">values</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.EventType" title="Link to this definition">¶</a></dt>
<dd><p>An <a class="reference internal" href="enum.html#enum.StrEnum" title="enum.StrEnum"><code class="xref py py-class docutils literal notranslate"><span class="pre">enum.StrEnum</span></code></a> enumerating the Tk event types, used as the value
of <a class="reference internal" href="#tkinter.Event.type" title="tkinter.Event.type"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Event.type</span></code></a>.
Its members include, among others, <code class="docutils literal notranslate"><span class="pre">KeyPress</span></code>, <code class="docutils literal notranslate"><span class="pre">KeyRelease</span></code>,
<code class="docutils literal notranslate"><span class="pre">ButtonPress</span></code>, <code class="docutils literal notranslate"><span class="pre">ButtonRelease</span></code>, <code class="docutils literal notranslate"><span class="pre">Motion</span></code>, <code class="docutils literal notranslate"><span class="pre">Enter</span></code>, <code class="docutils literal notranslate"><span class="pre">Leave</span></code>,
<code class="docutils literal notranslate"><span class="pre">FocusIn</span></code>, <code class="docutils literal notranslate"><span class="pre">FocusOut</span></code>, <code class="docutils literal notranslate"><span class="pre">Configure</span></code>, <code class="docutils literal notranslate"><span class="pre">Map</span></code>, <code class="docutils literal notranslate"><span class="pre">Unmap</span></code>, <code class="docutils literal notranslate"><span class="pre">Expose</span></code>,
<code class="docutils literal notranslate"><span class="pre">Destroy</span></code> and <code class="docutils literal notranslate"><span class="pre">MouseWheel</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.6.</span></p>
</div>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="tkinter.CallWrapper">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">CallWrapper</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">subst</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">widget</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.CallWrapper" title="Link to this definition">¶</a></dt>
<dd><p>Internal helper that wraps a Python callback so that it can be invoked from
Tcl.
<em>func</em> is the Python function, <em>subst</em> is an optional function that
pre-processes the Tcl arguments, and <em>widget</em> is the widget used for error
reporting.
Instances are created automatically by <a class="reference internal" href="#tkinter.Misc.register" title="tkinter.Misc.register"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.register()</span></code></a>; this class is
not normally used directly.</p>
</dd></dl>
</section>
<section id="module-level-functions">
<h3>Module-level functions<a class="headerlink" href="#module-level-functions" title="Link to this heading">¶</a></h3>
<dl class="py function">
<dt class="sig sig-object py" id="tkinter.Tcl">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Tcl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">screenName</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">baseName</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">className</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'Tk'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">useTk</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Tcl" title="Link to this definition">¶</a></dt>
<dd><p>The <code class="xref py py-func docutils literal notranslate"><span class="pre">Tcl()</span></code> function is a factory function which creates an object much
like that created by the <a class="reference internal" href="#tkinter.Tk" title="tkinter.Tk"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tk</span></code></a> class, except that it does not
initialize the Tk subsystem.
This is most often useful when driving the Tcl interpreter in an environment
where one doesn’t want to create extraneous toplevel windows, or where one
cannot (such as Unix/Linux systems without an X server).
An object created by the <code class="xref py py-func docutils literal notranslate"><span class="pre">Tcl()</span></code> object can have a Toplevel window
created (and the Tk subsystem initialized) by calling its <a class="reference internal" href="#tkinter.Tk.loadtk" title="tkinter.Tk.loadtk"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loadtk()</span></code></a>
method.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="tkinter.NoDefaultRoot">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">NoDefaultRoot</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.NoDefaultRoot" title="Link to this definition">¶</a></dt>
<dd><p>Inhibit the creation of an implicit default root window.
Afterwards <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> no longer creates a shared default root
automatically, and operations that rely on one — such as constructing a
widget without an explicit <em>master</em> — raise a <a class="reference internal" href="exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a>.
Call this early in larger applications to make the root window explicit.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="tkinter.mainloop">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">mainloop</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.mainloop" title="Link to this definition">¶</a></dt>
<dd><p>Run the Tk main event loop on the default root window until all windows are
destroyed.
Equivalent to calling <a class="reference internal" href="#tkinter.Misc.mainloop" title="tkinter.Misc.mainloop"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.mainloop()</span></code></a> on the default root.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="tkinter.getboolean">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">getboolean</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.getboolean" title="Link to this definition">¶</a></dt>
<dd><p>Convert the Tcl boolean string <em>s</em> (one of <code class="docutils literal notranslate"><span class="pre">'1'</span></code>, <code class="docutils literal notranslate"><span class="pre">'true'</span></code>, <code class="docutils literal notranslate"><span class="pre">'yes'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'on'</span></code> and similar, or their false counterparts) to a Python
<a class="reference internal" href="functions.html#bool" title="bool"><code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code></a>.
Raise <a class="reference internal" href="#tkinter.TclError" title="tkinter.TclError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TclError</span></code></a> for an invalid value.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="tkinter.getdouble">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">getdouble</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.getdouble" title="Link to this definition">¶</a></dt>
<dd><p>Convert <em>s</em> to a floating-point number.
This is the built-in <a class="reference internal" href="functions.html#float" title="float"><code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code></a>.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="tkinter.getint">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">getint</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.getint" title="Link to this definition">¶</a></dt>
<dd><p>Convert <em>s</em> to an integer.
This is the built-in <a class="reference internal" href="functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="tkinter.image_names">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">image_names</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.image_names" title="Link to this definition">¶</a></dt>
<dd><p>Return the names of all existing images in the default root’s interpreter.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="tkinter.image_types">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">image_types</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.image_types" title="Link to this definition">¶</a></dt>
<dd><p>Return the available image types (such as <code class="docutils literal notranslate"><span class="pre">'photo'</span></code> and <code class="docutils literal notranslate"><span class="pre">'bitmap'</span></code>) in
the default root’s interpreter.</p>
</dd></dl>
</section>
<section id="file-handlers">
<span id="tkinter-file-handlers"></span><h3>File handlers<a class="headerlink" href="#file-handlers" title="Link to this heading">¶</a></h3>
<p>Tk allows you to register and unregister a callback function which will be
called from the Tk mainloop when I/O is possible on a file descriptor.
Only one handler may be registered per file descriptor. Example code:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">tkinter</span>
<span class="n">widget</span> <span class="o">=</span> <span class="n">tkinter</span><span class="o">.</span><span class="n">Tk</span><span class="p">()</span>
<span class="n">mask</span> <span class="o">=</span> <span class="n">tkinter</span><span class="o">.</span><span class="n">READABLE</span> <span class="o">|</span> <span class="n">tkinter</span><span class="o">.</span><span class="n">WRITABLE</span>
<span class="n">widget</span><span class="o">.</span><span class="n">tk</span><span class="o">.</span><span class="n">createfilehandler</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="n">mask</span><span class="p">,</span> <span class="n">callback</span><span class="p">)</span>
<span class="o">...</span>
<span class="n">widget</span><span class="o">.</span><span class="n">tk</span><span class="o">.</span><span class="n">deletefilehandler</span><span class="p">(</span><span class="n">file</span><span class="p">)</span>
</pre></div>
</div>
<p>This feature is not available on Windows.</p>
<p>Since you don’t know how many bytes are available for reading, you may not
want to use the <a class="reference internal" href="io.html#io.BufferedIOBase" title="io.BufferedIOBase"><code class="xref py py-class docutils literal notranslate"><span class="pre">BufferedIOBase</span></code></a> or <a class="reference internal" href="io.html#io.TextIOBase" title="io.TextIOBase"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextIOBase</span></code></a>
<a class="reference internal" href="io.html#io.BufferedIOBase.read" title="io.BufferedIOBase.read"><code class="xref py py-meth docutils literal notranslate"><span class="pre">read()</span></code></a> or <a class="reference internal" href="io.html#io.IOBase.readline" title="io.IOBase.readline"><code class="xref py py-meth docutils literal notranslate"><span class="pre">readline()</span></code></a> methods,
since these will insist on reading a predefined number of bytes.
For sockets, the <a class="reference internal" href="socket.html#socket.socket.recv" title="socket.socket.recv"><code class="xref py py-meth docutils literal notranslate"><span class="pre">recv()</span></code></a> or
<a class="reference internal" href="socket.html#socket.socket.recvfrom" title="socket.socket.recvfrom"><code class="xref py py-meth docutils literal notranslate"><span class="pre">recvfrom()</span></code></a> methods will work fine; for other files,
use raw reads or <code class="docutils literal notranslate"><span class="pre">os.read(file.fileno(),</span> <span class="pre">maxbytecount)</span></code>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Widget.tk.createfilehandler">
<span class="sig-prename descclassname"><span class="pre">Widget.tk.</span></span><span class="sig-name descname"><span class="pre">createfilehandler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mask</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Widget.tk.createfilehandler" title="Link to this definition">¶</a></dt>
<dd><p>Registers the file handler callback function <em>func</em>. The <em>file</em> argument
may either be an object with a <a class="reference internal" href="io.html#io.IOBase.fileno" title="io.IOBase.fileno"><code class="xref py py-meth docutils literal notranslate"><span class="pre">fileno()</span></code></a> method (such as
a file or socket object), or an integer file descriptor. The <em>mask</em>
argument is an ORed combination of any of the three constants below.
The callback is called as follows:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">callback</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="n">mask</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="tkinter.Widget.tk.deletefilehandler">
<span class="sig-prename descclassname"><span class="pre">Widget.tk.</span></span><span class="sig-name descname"><span class="pre">deletefilehandler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.Widget.tk.deletefilehandler" title="Link to this definition">¶</a></dt>
<dd><p>Unregisters a file handler.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.READABLE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">READABLE</span></span><a class="headerlink" href="#tkinter.READABLE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.WRITABLE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">WRITABLE</span></span><a class="headerlink" href="#tkinter.WRITABLE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.EXCEPTION">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">EXCEPTION</span></span><a class="headerlink" href="#tkinter.EXCEPTION" title="Link to this definition">¶</a></dt>
<dd><p>Constants used in the <em>mask</em> arguments.</p>
</dd></dl>
</section>
<section id="constants">
<h3>Constants<a class="headerlink" href="#constants" title="Link to this heading">¶</a></h3>
<p>The following symbolic constants are available in both the <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code>
and <code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.constants</span></code> namespaces.</p>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.TRUE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">TRUE</span></span><a class="headerlink" href="#tkinter.TRUE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.YES">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">YES</span></span><a class="headerlink" href="#tkinter.YES" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.ON">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">ON</span></span><a class="headerlink" href="#tkinter.ON" title="Link to this definition">¶</a></dt>
<dd><p>Truthy values, all equal to the integer <code class="docutils literal notranslate"><span class="pre">1</span></code>.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.FALSE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">FALSE</span></span><a class="headerlink" href="#tkinter.FALSE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.NO">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">NO</span></span><a class="headerlink" href="#tkinter.NO" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.OFF">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">OFF</span></span><a class="headerlink" href="#tkinter.OFF" title="Link to this definition">¶</a></dt>
<dd><p>Falsy values, all equal to the integer <code class="docutils literal notranslate"><span class="pre">0</span></code>.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.N">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">N</span></span><a class="headerlink" href="#tkinter.N" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.S">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">S</span></span><a class="headerlink" href="#tkinter.S" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.E">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">E</span></span><a class="headerlink" href="#tkinter.E" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.W">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">W</span></span><a class="headerlink" href="#tkinter.W" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.NE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">NE</span></span><a class="headerlink" href="#tkinter.NE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.NW">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">NW</span></span><a class="headerlink" href="#tkinter.NW" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.SE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">SE</span></span><a class="headerlink" href="#tkinter.SE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.SW">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">SW</span></span><a class="headerlink" href="#tkinter.SW" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.NS">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">NS</span></span><a class="headerlink" href="#tkinter.NS" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.EW">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">EW</span></span><a class="headerlink" href="#tkinter.EW" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.NSEW">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">NSEW</span></span><a class="headerlink" href="#tkinter.NSEW" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.CENTER">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">CENTER</span></span><a class="headerlink" href="#tkinter.CENTER" title="Link to this definition">¶</a></dt>
<dd><p>Compass directions (<code class="docutils literal notranslate"><span class="pre">'n'</span></code>, <code class="docutils literal notranslate"><span class="pre">'s'</span></code>, <code class="docutils literal notranslate"><span class="pre">'e'</span></code>, <code class="docutils literal notranslate"><span class="pre">'w'</span></code> and the diagonals and
edges) plus <code class="docutils literal notranslate"><span class="pre">CENTER</span></code> (<code class="docutils literal notranslate"><span class="pre">'center'</span></code>), used as values for the <em>anchor</em> and
<em>sticky</em> options and by methods such as <a class="reference internal" href="#tkinter.Misc.grid_anchor" title="tkinter.Misc.grid_anchor"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Misc.grid_anchor()</span></code></a>.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.LEFT">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">LEFT</span></span><a class="headerlink" href="#tkinter.LEFT" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.RIGHT">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">RIGHT</span></span><a class="headerlink" href="#tkinter.RIGHT" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.TOP">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">TOP</span></span><a class="headerlink" href="#tkinter.TOP" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.BOTTOM">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">BOTTOM</span></span><a class="headerlink" href="#tkinter.BOTTOM" title="Link to this definition">¶</a></dt>
<dd><p>Sides for the <em>side</em> option of the packer (see <a class="reference internal" href="#tkinter.Pack.pack_configure" title="tkinter.Pack.pack_configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Pack.pack_configure()</span></code></a>).</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.X">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">X</span></span><a class="headerlink" href="#tkinter.X" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.Y">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">Y</span></span><a class="headerlink" href="#tkinter.Y" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.BOTH">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">BOTH</span></span><a class="headerlink" href="#tkinter.BOTH" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.NONE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">NONE</span></span><a class="headerlink" href="#tkinter.NONE" title="Link to this definition">¶</a></dt>
<dd><p>Values for the <em>fill</em> option of the packer: <code class="docutils literal notranslate"><span class="pre">'x'</span></code>, <code class="docutils literal notranslate"><span class="pre">'y'</span></code>, <code class="docutils literal notranslate"><span class="pre">'both'</span></code> or
<code class="docutils literal notranslate"><span class="pre">'none'</span></code>.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.RAISED">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">RAISED</span></span><a class="headerlink" href="#tkinter.RAISED" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.SUNKEN">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">SUNKEN</span></span><a class="headerlink" href="#tkinter.SUNKEN" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.FLAT">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">FLAT</span></span><a class="headerlink" href="#tkinter.FLAT" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.RIDGE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">RIDGE</span></span><a class="headerlink" href="#tkinter.RIDGE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.GROOVE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">GROOVE</span></span><a class="headerlink" href="#tkinter.GROOVE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.SOLID">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">SOLID</span></span><a class="headerlink" href="#tkinter.SOLID" title="Link to this definition">¶</a></dt>
<dd><p>Values for the <em>relief</em> option, which controls a widget’s 3-D border.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.HORIZONTAL">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">HORIZONTAL</span></span><a class="headerlink" href="#tkinter.HORIZONTAL" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.VERTICAL">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">VERTICAL</span></span><a class="headerlink" href="#tkinter.VERTICAL" title="Link to this definition">¶</a></dt>
<dd><p>Values for the <em>orient</em> option of widgets such as <a class="reference internal" href="#tkinter.Scale" title="tkinter.Scale"><code class="xref py py-class docutils literal notranslate"><span class="pre">Scale</span></code></a>,
<a class="reference internal" href="#tkinter.Scrollbar" title="tkinter.Scrollbar"><code class="xref py py-class docutils literal notranslate"><span class="pre">Scrollbar</span></code></a> and <a class="reference internal" href="#tkinter.PanedWindow" title="tkinter.PanedWindow"><code class="xref py py-class docutils literal notranslate"><span class="pre">PanedWindow</span></code></a>.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.CHAR">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">CHAR</span></span><a class="headerlink" href="#tkinter.CHAR" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.WORD">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">WORD</span></span><a class="headerlink" href="#tkinter.WORD" title="Link to this definition">¶</a></dt>
<dd><p>Values for the <em>wrap</em> option of the <a class="reference internal" href="#tkinter.Text" title="tkinter.Text"><code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code></a> widget, selecting line
wrapping on character or word boundaries.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.BASELINE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">BASELINE</span></span><a class="headerlink" href="#tkinter.BASELINE" title="Link to this definition">¶</a></dt>
<dd><p>The text-alignment value <code class="docutils literal notranslate"><span class="pre">'baseline'</span></code>.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.INSIDE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">INSIDE</span></span><a class="headerlink" href="#tkinter.INSIDE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.OUTSIDE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">OUTSIDE</span></span><a class="headerlink" href="#tkinter.OUTSIDE" title="Link to this definition">¶</a></dt>
<dd><p>Values for the <em>bordermode</em> option of the placer (see
<a class="reference internal" href="#tkinter.Place.place_configure" title="tkinter.Place.place_configure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Place.place_configure()</span></code></a>).</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.INSERT">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">INSERT</span></span><a class="headerlink" href="#tkinter.INSERT" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.CURRENT">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">CURRENT</span></span><a class="headerlink" href="#tkinter.CURRENT" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.END">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">END</span></span><a class="headerlink" href="#tkinter.END" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.ANCHOR">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">ANCHOR</span></span><a class="headerlink" href="#tkinter.ANCHOR" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.SEL">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">SEL</span></span><a class="headerlink" href="#tkinter.SEL" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.SEL_FIRST">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">SEL_FIRST</span></span><a class="headerlink" href="#tkinter.SEL_FIRST" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.SEL_LAST">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">SEL_LAST</span></span><a class="headerlink" href="#tkinter.SEL_LAST" title="Link to this definition">¶</a></dt>
<dd><p>Symbolic indices used by the <a class="reference internal" href="#tkinter.Text" title="tkinter.Text"><code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code></a>, <a class="reference internal" href="#tkinter.Entry" title="tkinter.Entry"><code class="xref py py-class docutils literal notranslate"><span class="pre">Entry</span></code></a>, <a class="reference internal" href="#tkinter.Listbox" title="tkinter.Listbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Listbox</span></code></a>
and <a class="reference internal" href="#tkinter.Canvas" title="tkinter.Canvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code></a> widgets, such as <code class="docutils literal notranslate"><span class="pre">'insert'</span></code> (the insertion cursor),
<code class="docutils literal notranslate"><span class="pre">'current'</span></code>, <code class="docutils literal notranslate"><span class="pre">'end'</span></code>, <code class="docutils literal notranslate"><span class="pre">'anchor'</span></code> and the bounds of the selection
(<code class="docutils literal notranslate"><span class="pre">'sel.first'</span></code> and <code class="docutils literal notranslate"><span class="pre">'sel.last'</span></code>).</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.ALL">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">ALL</span></span><a class="headerlink" href="#tkinter.ALL" title="Link to this definition">¶</a></dt>
<dd><p>The special tag <code class="docutils literal notranslate"><span class="pre">'all'</span></code>, which matches every item of a <a class="reference internal" href="#tkinter.Canvas" title="tkinter.Canvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code></a> or
every character of a <a class="reference internal" href="#tkinter.Text" title="tkinter.Text"><code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code></a> (for example <code class="docutils literal notranslate"><span class="pre">canvas.delete(ALL)</span></code>).</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.NORMAL">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">NORMAL</span></span><a class="headerlink" href="#tkinter.NORMAL" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.DISABLED">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">DISABLED</span></span><a class="headerlink" href="#tkinter.DISABLED" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.ACTIVE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">ACTIVE</span></span><a class="headerlink" href="#tkinter.ACTIVE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.HIDDEN">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">HIDDEN</span></span><a class="headerlink" href="#tkinter.HIDDEN" title="Link to this definition">¶</a></dt>
<dd><p>Values for the <em>state</em> option of various widgets and items.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.CASCADE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">CASCADE</span></span><a class="headerlink" href="#tkinter.CASCADE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.CHECKBUTTON">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">CHECKBUTTON</span></span><a class="headerlink" href="#tkinter.CHECKBUTTON" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.COMMAND">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">COMMAND</span></span><a class="headerlink" href="#tkinter.COMMAND" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.RADIOBUTTON">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">RADIOBUTTON</span></span><a class="headerlink" href="#tkinter.RADIOBUTTON" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.SEPARATOR">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">SEPARATOR</span></span><a class="headerlink" href="#tkinter.SEPARATOR" title="Link to this definition">¶</a></dt>
<dd><p>Menu entry types, used as the <em>itemType</em> argument of <a class="reference internal" href="#tkinter.Menu.add" title="tkinter.Menu.add"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Menu.add()</span></code></a> and
<a class="reference internal" href="#tkinter.Menu.insert" title="tkinter.Menu.insert"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Menu.insert()</span></code></a>.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.SINGLE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">SINGLE</span></span><a class="headerlink" href="#tkinter.SINGLE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.BROWSE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">BROWSE</span></span><a class="headerlink" href="#tkinter.BROWSE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.MULTIPLE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">MULTIPLE</span></span><a class="headerlink" href="#tkinter.MULTIPLE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.EXTENDED">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">EXTENDED</span></span><a class="headerlink" href="#tkinter.EXTENDED" title="Link to this definition">¶</a></dt>
<dd><p>Values for the <em>selectmode</em> option of the <a class="reference internal" href="#tkinter.Listbox" title="tkinter.Listbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">Listbox</span></code></a> widget.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.PIESLICE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">PIESLICE</span></span><a class="headerlink" href="#tkinter.PIESLICE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.CHORD">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">CHORD</span></span><a class="headerlink" href="#tkinter.CHORD" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.ARC">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">ARC</span></span><a class="headerlink" href="#tkinter.ARC" title="Link to this definition">¶</a></dt>
<dd><p>Values for the <em>style</em> option of <a class="reference internal" href="#tkinter.Canvas" title="tkinter.Canvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code></a> arc items.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.BUTT">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">BUTT</span></span><a class="headerlink" href="#tkinter.BUTT" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.PROJECTING">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">PROJECTING</span></span><a class="headerlink" href="#tkinter.PROJECTING" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.ROUND">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">ROUND</span></span><a class="headerlink" href="#tkinter.ROUND" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.BEVEL">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">BEVEL</span></span><a class="headerlink" href="#tkinter.BEVEL" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.MITER">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">MITER</span></span><a class="headerlink" href="#tkinter.MITER" title="Link to this definition">¶</a></dt>
<dd><p>Values for the <em>capstyle</em> (<code class="docutils literal notranslate"><span class="pre">'butt'</span></code>, <code class="docutils literal notranslate"><span class="pre">'projecting'</span></code>, <code class="docutils literal notranslate"><span class="pre">'round'</span></code>) and
<em>joinstyle</em> (<code class="docutils literal notranslate"><span class="pre">'round'</span></code>, <code class="docutils literal notranslate"><span class="pre">'bevel'</span></code>, <code class="docutils literal notranslate"><span class="pre">'miter'</span></code>) options of
<a class="reference internal" href="#tkinter.Canvas" title="tkinter.Canvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code></a> line items.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.FIRST">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">FIRST</span></span><a class="headerlink" href="#tkinter.FIRST" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.LAST">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">LAST</span></span><a class="headerlink" href="#tkinter.LAST" title="Link to this definition">¶</a></dt>
<dd><p>Values for the <em>arrow</em> option of <a class="reference internal" href="#tkinter.Canvas" title="tkinter.Canvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">Canvas</span></code></a> line items, indicating
which ends have arrowheads.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.MOVETO">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">MOVETO</span></span><a class="headerlink" href="#tkinter.MOVETO" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.SCROLL">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">SCROLL</span></span><a class="headerlink" href="#tkinter.SCROLL" title="Link to this definition">¶</a></dt>
<dd><p>The first argument passed by a <a class="reference internal" href="#tkinter.Scrollbar" title="tkinter.Scrollbar"><code class="xref py py-class docutils literal notranslate"><span class="pre">Scrollbar</span></code></a> to the <a class="reference internal" href="#tkinter.XView.xview" title="tkinter.XView.xview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">XView.xview()</span></code></a>
or <a class="reference internal" href="#tkinter.YView.yview" title="tkinter.YView.yview"><code class="xref py py-meth docutils literal notranslate"><span class="pre">YView.yview()</span></code></a> method of the scrolled widget.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.UNITS">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">UNITS</span></span><a class="headerlink" href="#tkinter.UNITS" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.PAGES">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">PAGES</span></span><a class="headerlink" href="#tkinter.PAGES" title="Link to this definition">¶</a></dt>
<dd><p>Values for the <em>what</em> argument of <a class="reference internal" href="#tkinter.XView.xview_scroll" title="tkinter.XView.xview_scroll"><code class="xref py py-meth docutils literal notranslate"><span class="pre">XView.xview_scroll()</span></code></a> and
<a class="reference internal" href="#tkinter.YView.yview_scroll" title="tkinter.YView.yview_scroll"><code class="xref py py-meth docutils literal notranslate"><span class="pre">YView.yview_scroll()</span></code></a>.</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="tkinter.UNDERLINE">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">UNDERLINE</span></span><a class="headerlink" href="#tkinter.UNDERLINE" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.NUMERIC">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">NUMERIC</span></span><a class="headerlink" href="#tkinter.NUMERIC" title="Link to this definition">¶</a></dt>
<dt class="sig sig-object py" id="tkinter.DOTBOX">
<span class="sig-prename descclassname"><span class="pre">tkinter.</span></span><span class="sig-name descname"><span class="pre">DOTBOX</span></span><a class="headerlink" href="#tkinter.DOTBOX" title="Link to this definition">¶</a></dt>
<dd><p>Other option values: <code class="docutils literal notranslate"><span class="pre">'underline'</span></code>, <code class="docutils literal notranslate"><span class="pre">'numeric'</span></code> and <code class="docutils literal notranslate"><span class="pre">'dotbox'</span></code>.</p>
</dd></dl>
</section>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<div>
<h3><a href="../contents.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> — Python interface to Tcl/Tk</a><ul>
<li><a class="reference internal" href="#architecture">Architecture</a></li>
<li><a class="reference internal" href="#tkinter-modules">Tkinter modules</a></li>
<li><a class="reference internal" href="#tkinter-life-preserver">Tkinter life preserver</a><ul>
<li><a class="reference internal" href="#a-hello-world-program">A Hello World program</a></li>
<li><a class="reference internal" href="#important-tk-concepts">Important Tk concepts</a></li>
<li><a class="reference internal" href="#understanding-how-tkinter-wraps-tcl-tk">Understanding how Tkinter wraps Tcl/Tk</a></li>
<li><a class="reference internal" href="#how-do-i-what-option-does">How do I…? What option does…?</a></li>
<li><a class="reference internal" href="#navigating-the-tcl-tk-reference-manual">Navigating the Tcl/Tk reference manual</a></li>
</ul>
</li>
<li><a class="reference internal" href="#threading-model">Threading model</a></li>
<li><a class="reference internal" href="#handy-reference">Handy reference</a><ul>
<li><a class="reference internal" href="#setting-options">Setting options</a></li>
<li><a class="reference internal" href="#geometry-management">Geometry management</a></li>
<li><a class="reference internal" href="#coupling-widget-variables">Coupling widget variables</a></li>
<li><a class="reference internal" href="#the-window-manager">The window manager</a></li>
<li><a class="reference internal" href="#tk-option-data-types">Tk option data types</a></li>
<li><a class="reference internal" href="#bindings-and-events">Bindings and events</a></li>
<li><a class="reference internal" href="#the-index-parameter">The index parameter</a></li>
<li><a class="reference internal" href="#images">Images</a></li>
</ul>
</li>
<li><a class="reference internal" href="#reference">Reference</a><ul>
<li><a class="reference internal" href="#base-and-mixin-classes">Base and mixin classes</a></li>
<li><a class="reference internal" href="#toplevel-widgets">Toplevel widgets</a></li>
<li><a class="reference internal" href="#widget-classes">Widget classes</a></li>
<li><a class="reference internal" href="#variable-classes">Variable classes</a></li>
<li><a class="reference internal" href="#image-classes">Image classes</a></li>
<li><a class="reference internal" href="#other-classes">Other classes</a></li>
<li><a class="reference internal" href="#module-level-functions">Module-level functions</a></li>
<li><a class="reference internal" href="#file-handlers">File handlers</a></li>
<li><a class="reference internal" href="#constants">Constants</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="tk.html"
title="previous chapter">Graphical user interfaces with Tk</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="tkinter.colorchooser.html"
title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.colorchooser</span></code> — Color choosing dialog</a></p>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const title = document.querySelector('meta[property="og:title"]').content;
const elements = document.querySelectorAll('.improvepage');
const pageurl = window.location.href.split('?')[0];
elements.forEach(element => {
const url = new URL(element.href.split('?')[0].replace("-nojs", ""));
url.searchParams.set('pagetitle', title);
url.searchParams.set('pageurl', pageurl);
url.searchParams.set('pagesource', "library/tkinter.rst");
element.href = url.toString();
});
});
</script>
<div role="note" aria-label="source link">
<h3>This page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a bug</a></li>
<li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>
<li>
<a href="https://github.com/python/cpython/blob/main/Doc/library/tkinter.rst?plain=1"
rel="nofollow">Show source
</a>
</li>
</ul>
</div>
</div>
<div id="sidebarbutton" title="Collapse sidebar">
<span>«</span>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="tkinter.colorchooser.html" title="tkinter.colorchooser — Color choosing dialog"
>next</a> |</li>
<li class="right" >
<a href="tk.html" title="Graphical user interfaces with Tk"
>previous</a> |</li>
<li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>
<li><a href="https://www.python.org/">Python</a> »</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.15.0rc1 Documentation</a> »
</li>
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>
<li class="nav-item nav-item-2"><a href="tk.html" >Graphical user interfaces with Tk</a> »</li>
<li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code> — Python interface to Tcl/Tk</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">
<input type="submit" value="Go">
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="footer">
© <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.
<br>
This page is licensed under the Python Software Foundation License Version 2.
<br>
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
<br>
See <a href="/license.html">History and License</a> for more information.<br>
<br>
The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br>
<br>
Last updated on Aug 04, 2026 (11:13 UTC).
<a href="/bugs.html">Found a bug</a>?
<br>
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
</div>
</body>
</html>