-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-86726: Document more tkinter.Tk methods #23689
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
base: main
Are you sure you want to change the base?
Conversation
|
This PR is stale because it has been open for 30 days with no activity. |
| @@ -95,6 +95,568 @@ Or, more often:: | |||
|
|
|||
| .. FIXME: The following keyword arguments are currently recognized: | |||
|
|
|||
| Methods inheritted from :class:`Misc` parent class (some methods ommited): | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling: inherited; omitted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Methods inheritted from :class:`Misc` parent class (some methods ommited): | |
| Methods inherited from :class:`!Misc` parent class (some methods omited): |
Made spelling fixes; Added ! to Misc since there is not such doc section.
|
|
||
| .. method:: destroy() | ||
|
|
||
| Destroy this and all descendants widgets. This will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all descendant widgets [without the trailing s]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Destroy this and all descendants widgets. This will | |
| Destroy this and all descendant widgets. This will |
| @@ -0,0 +1,4 @@ | |||
| Added most (not all) of the methods for the `Tkinter.Tk` class. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lowercase t for tkinter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.x module name is tkinter (was Tkinter before)
| Added most (not all) of the methods for the `Tkinter.Tk` class. | |
| Added most (not all) of the methods for the `tkinter.Tk` class. |
|
|
||
| Call function once after given time. | ||
|
|
||
| MS specifies the time in milliseconds. FUNC gives the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter names are normally marked up in italics rather than all caps, i.e. *Ms* and *Func* in this case. See my createfilehandler entry at the bottom, or the other Python RST documentation files for examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| MS specifies the time in milliseconds. FUNC gives the | |
| *Ms* specifies the time in milliseconds. *Func* is the function |
| .. method:: after_idle(func, *args) | ||
|
|
||
| Call FUNC once if the Tcl main loop has no event to | ||
| process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more of a complaint about the original docstring, but the if suggests the function may not be called. I would drop it and write "Call func once the main loop has no event . . ."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggestion should have been attached to the previous line. To implement the suggestion, I have to attach it there.
| whether this is a topmost window (displays above all other | ||
| windows). | ||
|
|
||
| On Macintosh, XXXXX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this line could be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. There are attributes common to all systems, 1 common to Windows and Mac, and specific ones for each system. Revision needed. https://www.tcl.tk/man/tcl8.6/TkCmd/wm.html
|
|
||
| Store VALUE in WM_COMMAND property. It is the command | ||
| which shall be used to invoke the application. Return current | ||
| command if VALUE is None. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy and paste mistake?
|
|
||
| .. method:: geometry(newGeometry=None) | ||
|
|
||
| Set geometry to NEWGEOMETRY of the form =widthxheight+x+y. Return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to mark up or otherwise differentiate the variables from the syntax. E.g. the TK manual uses italic width, height, x and y.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minimal change:
| Set geometry to NEWGEOMETRY of the form =widthxheight+x+y. Return | |
| Set geometry to *newGeometry* of the form =widthxheight+x+y. Return |
| .. method:: manage(widget) | ||
|
|
||
| The widget specified will become a stand alone top-level window. | ||
| The window will be decorated with the window managers title bar, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apostrophe for window manager's
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The window will be decorated with the window managers title bar, | |
| The window will be decorated with the window manager's title bar, |
| Return the function bound to NAME if None is given. NAME could be | ||
| e.g. "WM_SAVE_YOURSELF" or "WM_DELETE_WINDOW". | ||
|
|
||
| .. method:: resizable(widht=None, height=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling: width
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .. method:: resizable(widht=None, height=None) | |
| .. method:: resizable(width=None, height=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc for a particular widget should have none of the inherited methods and all of the added methods. The inherited methods should be documented and listed just once and referenced from each widget. The NMT Shipman docs called the inherited methods (at least those in Misc) 'Universal methods'. We need similar redundancy avoidance in our docs.
@Hpmason Martin made numberous specific suggestions. Do you plan to respond, or was this a one-shot contribution?
@vadmium If you had used the 'Insert a suggestion' feature, the first icon on the top row of icons, then I believe I as well as OP Hpmason could just clisk 'Accept' for each one.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
Sorry, I have been busy with work and have not had the chance to go over the suggested edits. |
|
@Hpmason Please do not delete your branch if you have not yet. Serhiy, the main tkinter maintainer, just indicated an interest in reviewing this. He, with a review from me, merge another tkinter doc patch a day or two ago. With him involved, it am going to review and check the existing suggestions. |
|
|
||
| .. method:: after_idle(func, *args) | ||
|
|
||
| Call FUNC once if the Tcl main loop has no event to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Call FUNC once if the Tcl main loop has no event to | |
| Call *func* the next time the Tcl main loop has no event to |
| Cancel scheduling of function identified with ID. | ||
|
|
||
| Identifier returned by :meth:`~Tk.after` or :meth:`~Tk.after_idle` must be | ||
| given as first parameter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| given as first parameter. |
This line is merged into the previous line by my previous suggestion.
|
|
||
| Cancel scheduling of function identified with ID. | ||
|
|
||
| Identifier returned by :meth:`~Tk.after` or :meth:`~Tk.after_idle` must be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Identifier returned by :meth:`~Tk.after` or :meth:`~Tk.after_idle` must be | |
| This is the identifier returned by :meth:`~Tk.after` or :meth:`~Tk.after_idle`. |
| Retrieve data from the clipboard on window's display. | ||
|
|
||
| The window keyword defaults to the root window of the Tkinter | ||
| application. | ||
|
|
||
| The type keyword specifies the form in which the data is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: at least on Windows, there is only one clipboard, even when there are multiple screens.
| Retrieve data from the clipboard on window's display. | |
| The window keyword defaults to the root window of the Tkinter | |
| application. | |
| The type keyword specifies the form in which the data is | |
| Return data from the clipboard. | |
| The *window* keyword defaults to the root window of the Tkinter | |
| application. The *type* keyword specifies the form in which the data is |
|
|
||
| .. method:: clipboard_clear(**kw) | ||
|
|
||
| Clear the data in the Tk clipboard. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "Tk clipboard" should be explained.
|
|
||
| .. method:: grab_current() | ||
|
|
||
| Return widget which has currently the grab in this application |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Return widget which has currently the grab in this application | |
| Return the widget that currently has the grab in this application |
|
|
||
| .. method:: selection_own_get(**kw) | ||
|
|
||
| Return owner of X selection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Return owner of X selection. | |
| Return the owner of the X selection. |
|
|
||
| .. method:: winfo_geometry() | ||
|
|
||
| Return geometry string for this widget in the form "widthxheight+X+Y". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Return geometry string for this widget in the form "widthxheight+X+Y". | |
| Return the geometry string for this widget in the form "widthxheight+X+Y". |
|
|
||
| .. method:: winfo_width() | ||
|
|
||
| Return width of this widget. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Return width of this widget. | |
| Return the width of this widget. |
|
|
||
| .. method:: winfo_id() | ||
|
|
||
| Return identifier ID for this widget. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return the identifier? Return an identifier? Omit 'ID'?
| Return the number of pixels of the height of the screen of this widget | ||
| in pixel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Return the number of pixels of the height of the screen of this widget | |
| in pixel. | |
| Return the height of the screen of this widget in pixels. |
| Return the number of pixels of the width of the screen of | ||
| this widget in pixel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Return the number of pixels of the width of the screen of | |
| this widget in pixel. | |
| Return the width of the screen of this widget in pixels. |
| ButtonPress, Button, Expose, Motion, ButtonRelease | ||
| FocusIn, MouseWheel, Circulate, FocusOut, Property, | ||
| Colormap, Gravity Reparent, Configure, KeyPress, Key, | ||
| Unmap, Deactivate, KeyRelease Visibility, Destroy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ButtonPress, Button, Expose, Motion, ButtonRelease | |
| FocusIn, MouseWheel, Circulate, FocusOut, Property, | |
| Colormap, Gravity Reparent, Configure, KeyPress, Key, | |
| Unmap, Deactivate, KeyRelease Visibility, Destroy, | |
| ButtonPress, Button, Expose, Motion, ButtonRelease, | |
| FocusIn, MouseWheel, Circulate, FocusOut, Property, | |
| Colormap, Gravity, Reparent, Configure, KeyPress, Key, | |
| Unmap, Deactivate, KeyRelease, Visibility, Destroy, |
| Store VALUE in WM_COMMAND property. It is the command | ||
| which shall be used to invoke the application. Return current | ||
| command if VALUE is None. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Store VALUE in WM_COMMAND property. It is the command | |
| which shall be used to invoke the application. Return current | |
| command if VALUE is None. | |
| Deiconify this widget. If it was never mapped it will not be mapped. | |
| On Windows it will raise this widget and give it the focus. |
Pasted.
| Set the name of the icon for this widget. Return the name if | ||
| None is given. | ||
|
|
||
| .. method:: iconphoto(defualt=False, *args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .. method:: iconphoto(defualt=False, *args) | |
| .. method:: iconphoto(default=False, *args) |
The misspelling is NOT in the signature.
|
|
||
| Descriptions taken from source code docstrings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed for blurb, as oposed to checkin message.
| Descriptions taken from source code docstrings. |
|
In this review, I implemented nearly all of vadmium's suggestions. Some appear attached to his suggestions, others appear separately because he only attached comments to 1 line and not necessarily the one that needed change. It would probably be easier to review my suggestions on the 'file' page where they should be in order. Serhiy, I left suggestions for you to review and merge (click button) and resolve (click other button if needed). Some of these changes should be propagated back to the docstrings. You can decide which. Once these are all resolved, I can look through again. |
|
I currently work on alternative PR. While this PR copies from docstrings to the documentation, I copy directly from Tk docs. Docstrings are less detailed and may be outdated, as they were based on old Tk docs. |
Sorry, I saw the merge to sync with the main branch and assumed it was some sort of bulk change, so I had closed this MR since it is outdated. I can apply the changes suggested to let this move along, though it sounds like Serhiy is working on a more updated version that more closely matches the Tk docs. |
|
Yes, leave this alone for now. Thanks for the effort. |
Added most (not all) of the methods for the Tk class.
This also includes parent class methods from the WM and Misc classes in the same module.
Descriptions taken from source code docstrings.