If *belowThis* is given, the widget is moved to be just below it in the
stacking order instead.
+ :meth:`tkraise`/:meth:`lift` and :meth:`lower` are overridden by the
+ :class:`Canvas` widget,
+ where they restack canvas items instead.
+
.. method:: image_names()
Return the names of all images that currently exist in the Tcl
interpreter.
+ This is overridden by the :class:`Text` widget,
+ where :meth:`!image_names` returns the names of its embedded images
+ instead.
+
.. method:: image_types()
Return the available image types, such as ``'photo'`` and ``'bitmap'``.
column 0 to that cell; if *col2* and *row2* are also given, it spans from
the cell (*column*, *row*) to the cell (*col2*, *row2*).
- :meth:`bbox` is an alias of :meth:`!grid_bbox`.
+ :meth:`bbox` is an alias of :meth:`!grid_bbox`,
+ except on :class:`Canvas`, :class:`Listbox`, :class:`Spinbox`,
+ :class:`Text`, :class:`ttk.Entry <tkinter.ttk.Entry>` and
+ :class:`ttk.Treeview <tkinter.ttk.Treeview>`,
+ which provide their own :meth:`!bbox` method.
.. method:: columnconfigure(index, cnf={}, **kw)
:no-typesetting:
Return the size of the grid managed by this container as a
``(columns, rows)`` tuple.
- :meth:`size` is an alias of :meth:`!grid_size`.
+ :meth:`size` is an alias of :meth:`!grid_size`,
+ except on the :class:`Listbox` widget,
+ which provides its own :meth:`!size` method.
.. method:: grid_slaves(row=None, column=None)
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.
- :meth:`focus` is an alias of :meth:`!focus_set`.
+ :meth:`focus` is an alias of :meth:`!focus_set`,
+ except on the :class:`Canvas` and
+ :class:`ttk.Treeview <tkinter.ttk.Treeview>` widgets,
+ which provide their own :meth:`!focus` method.
.. method:: focus_force()
The *displayof* keyword argument names a widget that determines the
display on which to operate, and defaults to this widget.
+ This is overridden by the :class:`Entry`, :class:`Listbox` and
+ :class:`Spinbox` widgets,
+ where :meth:`!selection_clear` clears the widget's own selection instead.
+
.. method:: selection_get(**kw)
Return the contents of the current X selection.
first and ``STRING`` is used as a fallback.
The *displayof* keyword argument names a widget that determines the
display, and defaults to the root window of the application.
- This is equivalent to ``selection_get(selection= 'CLIPBOARD')``.
+ This is equivalent to ``selection_get(selection='CLIPBOARD')``.
.. method:: option_add(pattern, value, priority=None)
widget is managed again.
:meth:`wm_forget` is an alias of :meth:`!forget`.
+ Not to be confused with :meth:`Pack.forget`.
+
.. versionadded:: 3.3
.. method:: wm_frame()
string if the window is not gridded.
:meth:`wm_grid` is an alias of :meth:`!grid`.
+ Not to be confused with the grid geometry manager :meth:`Grid.grid`.
+
.. method:: wm_group(pathName=None)
:no-typesetting:
:meth:`iconwindow`); the ``'icon'`` state cannot be set.
:meth:`wm_state` is an alias of :meth:`!state`.
+ Not to be confused with :meth:`ttk.Widget.state
+ <tkinter.ttk.Widget.state>`.
+
.. method:: wm_title(string=None)
:no-typesetting:
*pack* geometry manager.
See also :ref:`pack-the-packer`.
+ .. note::
+
+ :class:`Pack`, :class:`Place` and :class:`Grid` all define the short
+ method names :meth:`!forget`, :meth:`!info`, :meth:`!slaves`,
+ :meth:`!content` and :meth:`!propagate`.
+ On a widget the bare names resolve to the *pack* manager's versions,
+ since :class:`Pack` and :class:`Misc` precede :class:`Place` and
+ :class:`Grid` in the method resolution order,
+ whatever manager actually manages the widget;
+ and :meth:`!configure`/:meth:`!config` configure the widget's options,
+ not its geometry.
+ Use the explicit ``pack_*``, ``grid_*`` and ``place_*`` methods
+ (and ``pack``, ``grid``, ``place`` for geometry configuration)
+ to act on a specific geometry manager.
+
.. method:: configure(cnf={}, **kw)
:no-typesetting:
Unmap the widget and remove it from the packing order, forgetting its
packing options.
It can be packed again later with :meth:`pack_configure`.
- :meth:`forget` is an alias of :meth:`!pack_forget`.
+ :meth:`forget` is an alias of :meth:`!pack_forget`,
+ except on :class:`PanedWindow`,
+ :class:`ttk.Notebook <tkinter.ttk.Notebook>` and
+ :class:`ttk.PanedWindow <tkinter.ttk.PanedWindow>`,
+ which provide their own :meth:`!forget` method.
+
+ Not to be confused with :meth:`Wm.forget`.
.. method:: info()
:no-typesetting:
Unmap the widget and remove it from the placement, forgetting its place
options.
- :meth:`forget` is an alias of :meth:`!place_forget`.
.. method:: info()
:no-typesetting:
.. method:: place_info()
Return a dictionary of the widget's current place options.
- :meth:`info` is an alias of :meth:`!place_info`.
.. method:: slaves()
:no-typesetting:
Same as :meth:`Misc.place_slaves`: return the list of widgets placed in
this widget.
- :meth:`slaves` is an alias of :meth:`!place_slaves`.
.. class:: Grid()
grid(cnf={}, **kw)
Position the widget in a cell of its container's grid.
+
+ Not to be confused with :meth:`Wm.grid`.
+
The supported options are:
*row*, *column*
Unmap the widget and remove it from the grid, forgetting its grid
options.
- :meth:`forget` is an alias of :meth:`!grid_forget`.
.. method:: grid_remove()
.. method:: grid_info()
Return a dictionary of the widget's current grid options.
- :meth:`info` is an alias of :meth:`!grid_info`.
.. method:: bbox(column=None, row=None, col2=None, row2=None)
:no-typesetting:
.. method:: grid_bbox(column=None, row=None, col2=None, row2=None)
Same as :meth:`Misc.grid_bbox`.
- :meth:`bbox` is an alias of :meth:`!grid_bbox`.
+ :meth:`bbox` is an alias of :meth:`!grid_bbox`,
+ except on :class:`Canvas`, :class:`Listbox`, :class:`Spinbox`,
+ :class:`Text`, :class:`ttk.Entry <tkinter.ttk.Entry>` and
+ :class:`ttk.Treeview <tkinter.ttk.Treeview>`,
+ which provide their own :meth:`!bbox` method.
.. method:: columnconfigure(index, cnf={}, **kw)
:no-typesetting:
Same as :meth:`Misc.grid_size`: return a ``(columns, rows)`` tuple giving
the size of the grid.
- :meth:`size` is an alias of :meth:`!grid_size`.
+ :meth:`size` is an alias of :meth:`!grid_size`,
+ except on the :class:`Listbox` widget,
+ which provides its own :meth:`!size` method.
.. method:: propagate()
propagate(flag)
grid_propagate(flag)
Same as :meth:`Misc.grid_propagate`.
- :meth:`propagate` is an alias of :meth:`!grid_propagate`.
.. method:: slaves(row=None, column=None)
:no-typesetting:
Same as :meth:`Misc.grid_slaves`: return the widgets managed in the grid,
optionally restricted to a *row* and/or *column*.
- :meth:`slaves` is an alias of :meth:`!grid_slaves`.
.. class:: XView()
This has no effect on embedded window items.
:meth:`lower` is an alias of :meth:`!tag_lower`.
+ .. note::
+
+ On a :class:`Canvas`, :meth:`tkraise`/:meth:`lift` and :meth:`lower`
+ restack canvas items,
+ shadowing the inherited :meth:`Misc.tkraise`/:meth:`Misc.lift` and
+ :meth:`Misc.lower` methods that restack the widget itself,
+ which are therefore not available.
+
.. method:: tag_bind(tagOrId, sequence=None, func=None, add=None)
Bind the callback *func* to the event *sequence* for all items given by
Return ``None`` if no item matches or the matching items have nothing to
display.
+ This shadows the inherited :meth:`!Misc.bbox`;
+ use :meth:`~Misc.grid_bbox` for the grid bounding box.
+
.. method:: canvasx(screenx, gridspacing=None)
Given a window x-coordinate *screenx*, return the canvas x-coordinate
An item only displays the insertion cursor when both it is the focus item
and its canvas has the input focus.
+ This shadows the inherited :meth:`!Misc.focus`;
+ use :meth:`~Misc.focus_set` to focus the widget itself.
+
.. method:: icursor(tagOrId, index, /)
Set the insertion cursor of the items given by *tagOrId* to just before
If the selection is not in this widget the method has no effect.
:meth:`select_clear` is an alias of :meth:`!selection_clear`.
+ .. note::
+
+ This shadows the inherited :meth:`Misc.selection_clear`,
+ which clears the X selection;
+ that method is not available on an :class:`Entry`.
+
.. method:: select_from(index)
:no-typesetting:
Return the total number of items in the listbox.
+ This shadows the inherited :meth:`!Misc.size`;
+ use :meth:`~Misc.grid_size` for the grid size.
+
.. method:: index(index)
Return the integer index value corresponding to *index*, or ``None`` if
visible, the result still gives the full area of the item, including the
parts that are not visible.
+ This shadows the inherited :meth:`!Misc.bbox`;
+ use :meth:`~Misc.grid_bbox` for the grid bounding box.
+
.. method:: nearest(y)
Given a y-coordinate within the listbox window, return the index of the
The selection state of items outside this range is not changed.
:meth:`select_clear` is an alias of :meth:`!selection_clear`.
+ .. note::
+
+ This shadows the inherited :meth:`Misc.selection_clear`,
+ which clears the X selection;
+ that method is not available on a :class:`Listbox`.
+
.. method:: select_includes(index)
:no-typesetting:
Remove the pane containing *child* from the panedwindow.
All geometry management options for *child* are forgotten.
:meth:`forget` is an alias of :meth:`!remove`.
+ This shadows the inherited geometry-manager :meth:`!forget`;
+ use :meth:`~Pack.pack_forget`, :meth:`~Grid.grid_forget` or
+ :meth:`~Place.place_forget` to remove the widget itself from its manager.
.. method:: panes()
The bounding box may refer to a region outside the visible area of the
window.
+ This shadows the inherited :meth:`!Misc.bbox`;
+ use :meth:`~Misc.grid_bbox` for the grid bounding box.
+
.. method:: identify(x, y)
Return the name of the window element at the pixel coordinates *x*, *y*:
Clear the selection if it is currently in this widget.
If the selection is not in this widget, the method has no effect.
+ .. note::
+
+ This shadows the inherited :meth:`Misc.selection_clear`,
+ which clears the X selection;
+ that method is not available on a :class:`Spinbox`.
+
.. method:: selection_element(element=None)
Set or get the currently selected element.
pixels, of the visible part of the character at *index*, or ``None`` if
that character is not visible on the screen.
+ This shadows the inherited :meth:`!Misc.bbox`;
+ use :meth:`~Misc.grid_bbox` for the grid bounding box.
+
.. method:: dlineinfo(index)
Return a tuple ``(x, y, width, height, baseline)`` describing the display
Return a tuple of the names of all images embedded in the widget.
+ .. note::
+
+ This shadows the inherited :meth:`Misc.image_names`,
+ which returns the names of all images in the Tcl interpreter;
+ that method is not available on a :class:`Text`.
+
.. method:: window_create(index, cnf={}, **kw)
Embed a window (any widget) at *index*.
.. method:: set(value)
Set the variable to *value*.
+ :meth:`initialize` is an alias of :meth:`!set`.
.. versionadded:: 3.3
The *initialize* spelling.
*mode* is one of the strings ``'r'``, ``'w'`` or ``'u'``, for read, write
or unset.
Return the internal name of the registered callback.
+ :meth:`trace` is an alias of :meth:`!trace_variable`.
.. deprecated:: 3.6
Use :meth:`trace_add` instead. This method wraps a Tcl feature that
.. method:: set(value)
Set the variable to *value*, converting it to a boolean.
+ :meth:`initialize` is an alias of :meth:`!set`.
.. versionadded:: 3.3
The *initialize* spelling.
"""Add tag NEWTAG to all items with TAGORID."""
self.addtag(newtag, 'withtag', tagOrId)
- def bbox(self, *args):
+ def bbox(self, *args): # overrides Misc.bbox
"""Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle
which encloses all items with tags specified as arguments."""
return self._getints(
"""Return all items with TAGORID."""
return self.find('withtag', tagOrId)
- def focus(self, *args):
+ def focus(self, *args): # overrides Misc.focus
"""Set focus to the first item specified in ARGS."""
return self.tk.call((self._w, 'focus') + args)
(optional below another item)."""
self.tk.call((self._w, 'lower') + args)
- lower = tag_lower
+ lower = tag_lower # overrides Misc.lower
def move(self, *args):
"""Move an item TAGORID given in ARGS."""
(optional above another item)."""
self.tk.call((self._w, 'raise') + args)
- lift = tkraise = tag_raise
+ lift = tkraise = tag_raise # overrides Misc.tkraise
def scale(self, *args):
"""Scale item TAGORID with XORIGIN, YORIGIN, XSCALE, YSCALE."""
select_adjust = selection_adjust
- def selection_clear(self):
+ def selection_clear(self): # overrides Misc.selection_clear
"""Clear the selection if it is in this widget."""
self.tk.call(self._w, 'selection', 'clear')
"""Activate item identified by INDEX."""
self.tk.call(self._w, 'activate', index)
- def bbox(self, index):
+ def bbox(self, index): # overrides Misc.bbox
"""Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle
which encloses the item identified by the given index."""
return self._getints(self.tk.call(self._w, 'bbox', index)) or None
select_anchor = selection_anchor
- def selection_clear(self, first, last=None):
+ def selection_clear(self, first, last=None): # overrides Misc.selection_clear
"""Clear the selection from FIRST to LAST (included)."""
self.tk.call(self._w,
'selection', 'clear', first, last)
select_set = selection_set
- def size(self):
+ def size(self): # overrides Misc.size
"""Return the number of elements in the listbox."""
return self.tk.getint(self.tk.call(self._w, 'size'))
"""
Widget.__init__(self, master, 'text', cnf, kw)
- def bbox(self, index):
+ def bbox(self, index): # overrides Misc.bbox
"""Return a tuple of (x,y,width,height) which gives the bounding
box of the visible part of the character at the given index."""
return self._getints(
self._w, "image", "create", index,
*self._options(cnf, kw))
- def image_names(self):
+ def image_names(self): # overrides Misc.image_names
"""Return all names of embedded images in this widget."""
return self.tk.call(self._w, "image", "names")
"""
Widget.__init__(self, master, 'spinbox', cnf, kw)
- def bbox(self, index):
+ def bbox(self, index): # overrides Misc.bbox
"""Return a tuple of X1,Y1,X2,Y2 coordinates for a
rectangle which encloses the character given by index.
"""
return self.selection("adjust", index)
- def selection_clear(self):
+ def selection_clear(self): # overrides Misc.selection_clear
"""Clear the selection
If the selection isn't in this widget then the
"""
self.tk.call(self._w, 'forget', child)
- forget = remove
+ forget = remove # overrides Pack.forget
def identify(self, x, y):
"""Identify the panedwindow component at point x, y