Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Hpmason
Copy link

@Hpmason Hpmason commented Dec 8, 2020

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.

@github-actions
Copy link

github-actions bot commented Jan 9, 2021

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Jan 9, 2021
@@ -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):
Copy link
Member

Choose a reason for hiding this comment

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

Spelling: inherited; omitted

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Member

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]

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

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

Lowercase t for tkinter?

Copy link
Member

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)

Suggested change
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
Copy link
Member

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.

Copy link
Member

@terryjreedy terryjreedy Nov 3, 2023

Choose a reason for hiding this comment

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

Suggested change
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.
Copy link
Member

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 . . ."

Copy link
Member

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
Copy link
Member

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

Copy link
Member

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.
Copy link
Member

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
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

Minimal change:

Suggested 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,
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

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

Spelling: width

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.. method:: resizable(widht=None, height=None)
.. method:: resizable(width=None, height=None)

@python python deleted a comment from the-knights-who-say-ni Aug 12, 2021
@terryjreedy terryjreedy changed the title bpo-42560: Add more tkinter documentation bpo-42560: Document more tkinter.Tk methods Aug 12, 2021
Copy link
Member

@terryjreedy terryjreedy left a 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.

@bedevere-bot
Copy link

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@Hpmason
Copy link
Author

Hpmason commented Aug 12, 2021

Sorry, I have been busy with work and have not had the chance to go over the suggested edits.
I saw that markroseman on the issue tracker suggested some good changes. I would don't see myself having the time to making those, and would be more than happy to let him take over if he wants to work on those changes.

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Aug 2, 2022
@serhiy-storchaka serhiy-storchaka self-requested a review November 2, 2023 18:27
@Hpmason Hpmason closed this Nov 2, 2023
@terryjreedy
Copy link
Member

@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.

@terryjreedy terryjreedy reopened this Nov 3, 2023
@terryjreedy terryjreedy changed the title bpo-42560: Document more tkinter.Tk methods gh-86726: Document more tkinter.Tk methods Nov 3, 2023

.. method:: after_idle(func, *args)

Call FUNC once if the Tcl main loop has no event to
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.
Copy link
Member

@terryjreedy terryjreedy Nov 3, 2023

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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`.

Comment on lines +228 to +233
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
Copy link
Member

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.

Suggested change
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.
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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".
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Return width of this widget.
Return the width of this widget.


.. method:: winfo_id()

Return identifier ID for this widget.
Copy link
Member

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'?

Comment on lines +401 to +402
Return the number of pixels of the height of the screen of this widget
in pixel.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.

Comment on lines +406 to +407
Return the number of pixels of the width of the screen of
this widget in pixel.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.

Comment on lines +457 to +460
ButtonPress, Button, Expose, Motion, ButtonRelease
FocusIn, MouseWheel, Circulate, FocusOut, Property,
Colormap, Gravity Reparent, Configure, KeyPress, Key,
Unmap, Deactivate, KeyRelease Visibility, Destroy,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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,

Comment on lines +590 to +592
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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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)
Copy link
Member

@terryjreedy terryjreedy Nov 3, 2023

Choose a reason for hiding this comment

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

Suggested change
.. method:: iconphoto(defualt=False, *args)
.. method:: iconphoto(default=False, *args)

The misspelling is NOT in the signature.

Comment on lines +3 to +4

Descriptions taken from source code docstrings.
Copy link
Member

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.

Suggested change
Descriptions taken from source code docstrings.

@terryjreedy
Copy link
Member

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.

@serhiy-storchaka
Copy link
Member

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.

@hpmason hpmason mannequin mentioned this pull request Nov 3, 2023
@Hpmason
Copy link
Author

Hpmason commented Nov 4, 2023

@Hpmason Please do not delete your branch if you have not yet. ...

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.

@terryjreedy
Copy link
Member

Yes, leave this alone for now. Thanks for the effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting changes docs Documentation in the Doc dir
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

7 participants