Visitar URL original
bpo-13553: Document tkinter.Tk args by csabella · Pull Request #4786 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Additional changes
  • Loading branch information
csabella committed Dec 12, 2017
commit df696bb123fa2c0a213b9a1acc6c523bfc3a44a5
44 changes: 28 additions & 16 deletions Doc/library/tkinter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,44 @@ Or, more often::

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

Toplevel Tk widget, which is usually the main window of an application.
Each instance has its own associated Tcl interpreter.
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*
Sets the :envvar:`DISPLAY` environmental variable. (X11 only)
When given (as a string), sets the :envvar:`DISPLAY` environmental
variable. (X11 only)
Comment thread
JulienPalard marked this conversation as resolved.
*baseName*
Reads the profile file :file:`{baseName}.tcl` into the Tcl interpreter
and calls :func:`exec` on the contents of :file:`{baseName}.py`.
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 name
(:file:`{className}.tcl` and :file:`{className}.py` load before the
*baseName* files), and also used as the name with which Tcl is
invoked (*argv0* in *interp*).
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. :func:`Tcl` sets this to
``False``.
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.
If ``True``, execute all X server commands synchronously, so that errors
are reported immediately.
Comment thread
willingc marked this conversation as resolved.
Outdated
*use*
Specifies that the main window for the application is to be embedded in
the window whose identifier is given, instead of being created as an
independent toplevel window.
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
Copy Markdown
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
Copy Markdown
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)
Comment thread
JulienPalard marked this conversation as resolved.
Outdated

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
Copy Markdown
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
Copy Markdown
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)
Expand Down