mirror of
https://github.com/python/cpython.git
synced 2025-08-19 00:00:48 +00:00
bpo-13553: Document tkinter.Tk args (GH-4786)
(cherry picked from commit c56e2bb994
)
Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
This commit is contained in:
parent
826ceab488
commit
5ed2f11834
3 changed files with 67 additions and 10 deletions
|
@ -124,16 +124,72 @@ the modern themed widget set and API::
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
|
|
||||||
|
|
||||||
.. class:: Tk(screenName=None, baseName=None, className='Tk', useTk=1)
|
.. class:: Tk(screenName=None, baseName=None, className='Tk', useTk=True, sync=False, use=None)
|
||||||
|
|
||||||
The :class:`Tk` class is instantiated without arguments. This creates a toplevel
|
Construct a toplevel Tk widget, which is usually the main window of an
|
||||||
widget of Tk which usually is the main window of an application. Each instance
|
application, and initialize a Tcl interpreter for this widget. Each
|
||||||
has its own associated Tcl interpreter.
|
instance has its own associated Tcl interpreter.
|
||||||
|
|
||||||
.. FIXME: The following keyword arguments are currently recognized:
|
The :class:`Tk` class is typically instantiated using all default values.
|
||||||
|
However, the following keyword arguments are currently recognized:
|
||||||
|
|
||||||
|
*screenName*
|
||||||
|
When given (as a string), sets the :envvar:`DISPLAY` environment
|
||||||
|
variable. (X11 only)
|
||||||
|
*baseName*
|
||||||
|
Name of the profile file. By default, *baseName* is derived from the
|
||||||
|
program name (``sys.argv[0]``).
|
||||||
|
*className*
|
||||||
|
Name of the widget class. Used as a profile file and also as the name
|
||||||
|
with which Tcl is invoked (*argv0* in *interp*).
|
||||||
|
*useTk*
|
||||||
|
If ``True``, initialize the Tk subsystem. The :func:`tkinter.Tcl() <Tcl>`
|
||||||
|
function sets this to ``False``.
|
||||||
|
*sync*
|
||||||
|
If ``True``, execute all X server commands synchronously, so that errors
|
||||||
|
are reported immediately. Can be used for debugging. (X11 only)
|
||||||
|
*use*
|
||||||
|
Specifies the *id* of the window in which to embed the application,
|
||||||
|
instead of it being created as an independent toplevel window. *id* 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
|
||||||
|
:meth:`winfo_id`).
|
||||||
|
|
||||||
|
Note that on some platforms this will only work correctly if *id* refers
|
||||||
|
to a Tk frame or toplevel that has its -container option enabled.
|
||||||
|
|
||||||
|
:class:`Tk` reads and interprets profile files, named
|
||||||
|
:file:`.{className}.tcl` and :file:`.{baseName}.tcl`, into the Tcl
|
||||||
|
interpreter and calls :func:`exec` on the contents of
|
||||||
|
:file:`.{className}.py` and :file:`.{baseName}.py`. The path for the
|
||||||
|
profile files is the :envvar:`HOME` environment variable or, if that
|
||||||
|
isn't defined, then :attr:`os.curdir`.
|
||||||
|
|
||||||
|
.. attribute:: tk
|
||||||
|
|
||||||
|
The Tk application object created by instantiating :class:`Tk`. This
|
||||||
|
provides access to the Tcl interpreter. Each widget that is attached
|
||||||
|
the same instance of :class:`Tk` has the same value for its :attr:`tk`
|
||||||
|
attribute.
|
||||||
|
|
||||||
|
.. attribute:: master
|
||||||
|
|
||||||
|
The widget object that contains this widget. For :class:`Tk`, the
|
||||||
|
*master* is :const:`None` because it is the main window. The terms
|
||||||
|
*master* and *parent* are similar and sometimes used interchangeably
|
||||||
|
as argument names; however, calling :meth:`winfo_parent` returns a
|
||||||
|
string of the widget name whereas :attr:`master` returns the object.
|
||||||
|
*parent*/*child* reflects the tree-like relationship while
|
||||||
|
*master*/*slave* reflects the container structure.
|
||||||
|
|
||||||
|
.. attribute:: children
|
||||||
|
|
||||||
|
The immediate descendants of this widget as a :class:`dict` with the
|
||||||
|
child widget names as the keys and the child instance objects as the
|
||||||
|
values.
|
||||||
|
|
||||||
|
|
||||||
.. function:: Tcl(screenName=None, baseName=None, className='Tk', useTk=0)
|
.. function:: Tcl(screenName=None, baseName=None, className='Tk', useTk=False)
|
||||||
|
|
||||||
The :func:`Tcl` function is a factory function which creates an object much like
|
The :func:`Tcl` function is a factory function which creates an object much like
|
||||||
that created by the :class:`Tk` class, except that it does not initialize the Tk
|
that created by the :class:`Tk` class, except that it does not initialize the Tk
|
||||||
|
|
|
@ -2099,7 +2099,7 @@ class Wm:
|
||||||
the bitmap if None is given.
|
the bitmap if None is given.
|
||||||
|
|
||||||
Under Windows, the DEFAULT parameter can be used to set the icon
|
Under Windows, the DEFAULT parameter can be used to set the icon
|
||||||
for the widget and any descendents that don't have an icon set
|
for the widget and any descendants that don't have an icon set
|
||||||
explicitly. DEFAULT can be the relative path to a .ico file
|
explicitly. DEFAULT can be the relative path to a .ico file
|
||||||
(example: root.iconbitmap(default='myicon.ico') ). See Tk
|
(example: root.iconbitmap(default='myicon.ico') ). See Tk
|
||||||
documentation for more information."""
|
documentation for more information."""
|
||||||
|
@ -2345,9 +2345,9 @@ class Tk(Misc, Wm):
|
||||||
_default_root = None
|
_default_root = None
|
||||||
|
|
||||||
def readprofile(self, baseName, className):
|
def readprofile(self, baseName, className):
|
||||||
"""Internal function. It reads BASENAME.tcl and CLASSNAME.tcl into
|
"""Internal function. It reads .BASENAME.tcl and .CLASSNAME.tcl into
|
||||||
the Tcl Interpreter and calls exec on the contents of BASENAME.py and
|
the Tcl Interpreter and calls exec on the contents of .BASENAME.py and
|
||||||
CLASSNAME.py if such a file exists in the home directory."""
|
.CLASSNAME.py if such a file exists in the home directory."""
|
||||||
import os
|
import os
|
||||||
if 'HOME' in os.environ: home = os.environ['HOME']
|
if 'HOME' in os.environ: home = os.environ['HOME']
|
||||||
else: home = os.curdir
|
else: home = os.curdir
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Document tkinter.Tk args.
|
Loading…
Add table
Add a link
Reference in a new issue