Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions Doc/library/tkinter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6772,6 +6772,17 @@ and :mod:`!tkinter.constants` namespaces.
edges) plus ``CENTER`` (``'center'``), used as values for the *anchor* and
*sticky* options and by methods such as :meth:`Misc.grid_anchor`.

.. data:: EN
ES
WN
WS

Additional values for the *labelanchor* option of :class:`LabelFrame`
and :class:`ttk.LabelFrame <tkinter.ttk.LabelFrame>`,
which also accept the compass directions above.

.. versionadded:: next

.. data:: LEFT
RIGHT
TOP
Expand Down Expand Up @@ -6808,6 +6819,13 @@ and :mod:`!tkinter.constants` namespaces.
Values for the *wrap* option of the :class:`Text` widget, selecting line
wrapping on character or word boundaries.

.. data:: TABULAR
WORDPROCESSOR

Values for the *tabstyle* option of the :class:`Text` widget.

.. versionadded:: next

.. data:: BASELINE

The text-alignment value ``'baseline'``.
Expand All @@ -6818,6 +6836,12 @@ and :mod:`!tkinter.constants` namespaces.
Values for the *bordermode* option of the placer (see
:meth:`Place.place_configure`).

.. data:: IGNORE

An additional value for the *bordermode* option of the placer.

.. versionadded:: next

.. data:: INSERT
CURRENT
END
Expand All @@ -6843,6 +6867,38 @@ and :mod:`!tkinter.constants` namespaces.

Values for the *state* option of various widgets and items.

.. data:: READONLY

An additional value for the *state* option of :class:`Entry`,
:class:`Spinbox` and the themed widgets.

.. versionadded:: next

.. data:: ALTERNATE
BACKGROUND
FOCUS
HOVER
INVALID
PRESSED
SELECTED

Names of the themed widget states
(see :meth:`ttk.Widget.state <tkinter.ttk.Widget.state>`),
in addition to ``ACTIVE``, ``DISABLED`` and ``READONLY``.

.. versionadded:: next

.. data:: LEAF
OPEN

Names of the themed widget states used by
:class:`ttk.Treeview <tkinter.ttk.Treeview>`,
as are ``FIRST`` and ``LAST`` for the tabs of
:class:`ttk.Notebook <tkinter.ttk.Notebook>`.
They require Tk 9.1 or newer.

.. versionadded:: next

.. data:: CASCADE
CHECKBUTTON
COMMAND
Expand All @@ -6852,13 +6908,38 @@ and :mod:`!tkinter.constants` namespaces.
Menu entry types, used as the *itemType* argument of :meth:`Menu.add` and
:meth:`Menu.insert`.

.. data:: MENUBAR
TEAROFF

Values for the *type* option of the :class:`Menu` widget,
in addition to ``NORMAL``.

.. versionadded:: next

.. data:: SINGLE
BROWSE
MULTIPLE
EXTENDED

Values for the *selectmode* option of the :class:`Listbox` widget.

.. data:: ITEM
CELL

Values for the *selecttype* option of
:class:`ttk.Treeview <tkinter.ttk.Treeview>`.
It requires Tk 9.0 or newer.

.. versionadded:: next

.. data:: TREE
HEADINGS

Values for the *show* option of
:class:`ttk.Treeview <tkinter.ttk.Treeview>`.

.. versionadded:: next

.. data:: PIESLICE
CHORD
ARC
Expand Down Expand Up @@ -6893,6 +6974,74 @@ and :mod:`!tkinter.constants` namespaces.
Values for the *what* argument of :meth:`XView.xview_scroll` and
:meth:`YView.yview_scroll`.

.. data:: PIXELS

An additional value for the *what* argument of
:meth:`YView.yview_scroll` of the :class:`Text` widget.

.. versionadded:: next

.. data:: TEXT
IMAGE

Values for the *compound* option of the themed widgets,
in addition to ``CENTER``, ``LEFT``, ``RIGHT``, ``TOP``, ``BOTTOM``
and ``NONE``.

.. versionadded:: next

.. data:: ABOVE
BELOW
FLUSH

Values for the *direction* option of :class:`Menubutton` and
:class:`ttk.Menubutton <tkinter.ttk.Menubutton>`,
in addition to ``LEFT`` and ``RIGHT``.

.. versionadded:: next

.. data:: ALWAYS
MIDDLE
NEVER

Values for the *stretch* option of :meth:`PanedWindow.paneconfigure`,
in addition to ``FIRST`` and ``LAST``.

.. versionadded:: next

.. data:: DETERMINATE
INDETERMINATE

Values for the *mode* option of
:class:`ttk.Progressbar <tkinter.ttk.Progressbar>`.

.. versionadded:: next

.. data:: HOLLOW

An additional value for the *insertunfocussed* option of the
:class:`Text` widget, which also accepts ``NONE`` and ``SOLID``.
The option requires Tk 8.6 or newer.

.. versionadded:: next

.. data:: KEY
FOCUSIN
FOCUSOUT

Values for the *validate* option of :class:`Entry`, :class:`Spinbox`
and :class:`ttk.Entry <tkinter.ttk.Entry>`,
in addition to ``ALL``, ``FOCUS`` and ``NONE``.

.. versionadded:: next

.. data:: FORCED

An additional validation reason reported by the ``%V`` substitution
of the *validatecommand* option.

.. versionadded:: next

.. data:: UNDERLINE
NUMERIC
DOTBOX
Expand Down
8 changes: 8 additions & 0 deletions Doc/whatsnew/3.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,14 @@ tkinter
with no unit suffix to :class:`int` or :class:`float`.
(Contributed by Serhiy Storchaka in :gh:`153513`.)

* Added symbolic constants for Tk option values which were missing in
:mod:`!tkinter.constants`: values for the *labelanchor*, *compound*,
*bordermode*, *direction*, *stretch*, *tabstyle*, *insertunfocussed*,
*mode*, *selecttype*, *show*, *state*, *validate* and *type* options,
the names of the themed widget states, and ``PIXELS`` for scrolling
the :class:`~tkinter.Text` widget.
(Contributed by Serhiy Storchaka in :gh:`159301`.)


turtle
------
Expand Down
68 changes: 68 additions & 0 deletions Lib/tkinter/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
NSEW='nsew'
CENTER='center'

# -labelanchor, in addition to the values above
EN='en'
ES='es'
WN='wn'
WS='ws'

# -compound
TEXT='text'
IMAGE='image'

# -fill
NONE='none'
X='x'
Expand Down Expand Up @@ -54,8 +64,38 @@

# -bordermode
INSIDE='inside'
IGNORE='ignore'
OUTSIDE='outside'

# -direction
ABOVE='above'
BELOW='below'
FLUSH='flush'

# -stretch
ALWAYS='always'
MIDDLE='middle'
NEVER='never'

# -tabstyle
TABULAR='tabular'
WORDPROCESSOR='wordprocessor'

# -insertunfocussed (Tk 8.6+)
HOLLOW='hollow'

# -mode
DETERMINATE='determinate'
INDETERMINATE='indeterminate'

# -selecttype (Tk 9.0+)
ITEM='item'
CELL='cell'

# -show
TREE='tree'
HEADINGS='headings'

# Special tags, marks and insert positions
SEL='sel'
SEL_FIRST='sel.first'
Expand All @@ -72,6 +112,29 @@
ACTIVE='active'
# Canvas state
HIDDEN='hidden'
# Entry and ttk widget states
READONLY='readonly'
# Other ttk widget states
ALTERNATE='alternate'
BACKGROUND='background'
FOCUS='focus'
HOVER='hover'
INVALID='invalid'
PRESSED='pressed'
SELECTED='selected'
# ttk widget states for Treeview items and Notebook tabs (Tk 9.1+)
# FIRST='first' and LAST='last' are also used
LEAF='leaf'
OPEN='open'

# -validate
# ALL='all', FOCUS='focus' and NONE='none' are also valid
KEY='key'
FOCUSIN='focusin'
FOCUSOUT='focusout'

# Validation reasons, in addition to the values above
FORCED='forced'

# Menu item types
CASCADE='cascade'
Expand All @@ -80,6 +143,10 @@
RADIOBUTTON='radiobutton'
SEPARATOR='separator'

# -type for menus
MENUBAR='menubar'
TEAROFF='tearoff'

# Selection modes for list boxes
SINGLE='single'
BROWSE='browse'
Expand Down Expand Up @@ -108,3 +175,4 @@
SCROLL='scroll'
UNITS='units'
PAGES='pages'
PIXELS='pixels'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add symbolic constants for Tk option values which were missing in
:mod:`!tkinter.constants`, such as ``READONLY``, ``TABULAR``,
``DETERMINATE``, ``MENUBAR`` and the names of the themed widget states.
Loading