Skip to content

bpo-13553: Document tkinter.Tk args #4786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
53 changes: 43 additions & 10 deletions Doc/library/tkinter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,49 @@ Or, more often::
from tkinter import *


.. class:: Tk(screenName=None, baseName=None, className='Tk', useTk=1)

The :class:`Tk` class is instantiated without arguments. This creates a toplevel
widget of Tk which usually is the main window of an application. Each instance
has its own associated Tcl interpreter.

.. FIXME: The following keyword arguments are currently recognized:


.. function:: Tcl(screenName=None, baseName=None, className='Tk', useTk=0)
.. class:: Tk(screenName=None, baseName=None, className='Tk', useTk=True, sync=False, use=None)

Construct a toplevel Tk widget, which is usually the main window of an
application. Each instance has its own associated Tcl interpreter.

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` environmental
variable. (X11 only)
*baseName*
Name of the profile file used in :meth:`readprofile`. By default,
*baseName* is derived from the program name (``sys.argv[0]``).
*className*
Name of the widget class. Used as a profile file in :meth:`readprofile`
and used 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.
*use*
Specifies the *id* of the main window in which to embed the application,
instead of it being created as an independent toplevel window. *id* must
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be "Specifies the id of the window". This whole piece was used for application embedding (think web browser plugins). Therefore, it would be almost always the case that you'd embed inside a specific subwindow somewhere, not directly in the "main" window of the application (which I'd read as toplevel)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I think I had taken this from the wish man page and unintentionally changed the meaning slightly with my edit.

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.

.. method:: readprofile(self, baseName, className)

Read the profile files, :file:`.{className}.tcl` and
:file:`.{baseName}.tcl`, into the Tcl interpreter and call :func:`exec`
on the contents of :file:`.{className}.py` and :file:`.{baseName}.py`.
The path for the profile files is the :envvar:`HOME` environmental
variable or, if that isn't defined, then :attr:`os.curdir`.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we are documenting the Tk class. Would it be worth it to document Tk attributes? master, children and tk.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current page reads more like a 'getting started' or 'how to', so I wasn't sure how much detail to add. I know there's a separate bug issue where Terry figured out the difference between master and parent, so maybe it would be worthwhile to include that here?


.. function:: Tcl(screenName=None, baseName=None, className='Tk', useTk=False)

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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document tkinter.Tk args.