Repository navigation
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
Changes from 1 commit
fdc96ed
35c6465
df696bb
0f468bc
c25db70
9068406
0054844
57553df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,8 @@ Or, more often:: | |
| .. 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. | ||
| application, and initialize a Tcl interpreter for this widget. 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: | ||
|
|
@@ -79,11 +80,11 @@ Or, more often:: | |
| 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]``). | ||
| 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 in :meth:`readprofile` | ||
| and used as the name with which Tcl is invoked (*argv0* in *interp*). | ||
| Name of the widget class. Used as a profile file and also as the name | ||
| with which Tcl is invoked (*argv0* in *interp*). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So about baseName and className... My understanding is that className is the equivalent of wish's "-name" option. So this provides the default title for the root window, the class of the root window (which can be used in bindings and option database), and would be what is returned by "tk appname" (sometimes used for inter-application communication). It appears that baseName isn't passed into Tcl/Tk at all. About those profile files that can be read in... does anyone know what they're intended to be used for, if they've ever been documented, and if they're actually used at all? It reads like a per-application 'automatically inject your own code' which seems a bit strange.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried out specifying className on a call and it seems to lower case the first letter: root = tkinter.Tk(className='TEST')creates a window with the name Looking through the documentation, it looks like However, the send command in tkinter has: def send(self, interp, cmd, *args):
"""Send Tcl command CMD to different interpreter INTERP to be executed."""
return self.tk.call(('send', interp, cmd) + args)As far as the profile files, there was a security patch in the past.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why the first letter is lowercased - it's Tkinter that's doing it, though for what reason I can't guess. From the Tcl side it's perfectly ok with the first letter of argv0 capitalized. My instinct therefore is not to document it. Note that the classname for the window will lowercase everything except for uppercasing the first letter, e.g. "Test" with your example. I think the first letter uppercase is used for user class names vs. builtin ones like 'button' etc. I was playing around with different things using this: I'd suggest not documenting this conversion either. Anyone who needs to get the exact capitalization of the classname will know how to get it through introspection. I also don't imagine that 'send' would be used much by Tkinter apps (it was a useful thing a long while ago, not so much now). Any suggestions how to proceed with regard to the readprofile() thing, i.e. what on earth it is for and if it should still be there? @serhiy-storchaka ? |
||
| *useTk* | ||
| If ``True``, initialize the Tk subsystem. The :func:`tkinter.Tcl() <Tcl>` | ||
| function sets this to ``False``. | ||
|
|
@@ -100,13 +101,34 @@ Or, more often:: | |
| 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) | ||
| :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` environmental variable or, if that | ||
| isn't defined, then :attr:`os.curdir`. | ||
|
|
||
| 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`. | ||
| .. attribute:: tk | ||
|
|
||
| The ``_tkinter.tkapp`` object created by instantiating :class:`Tk`. This | ||
|
JulienPalard marked this conversation as resolved.
Outdated
|
||
| provides access to the C methods and attributes, including the Tcl | ||
|
willingc marked this conversation as resolved.
Outdated
|
||
| 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 descendents of this widget as a :class:`dict` with the child widget | ||
| names as the keys and the child instance objects as the values. | ||
|
willingc marked this conversation as resolved.
Outdated
|
||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.