Skip to content

bpo-25237: Documentation for tkinter modules #1870

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 17 commits into from
Sep 10, 2019

Conversation

patel-nikhil
Copy link
Contributor

@patel-nikhil patel-nikhil commented May 30, 2017

Added documentation for tkinter modules where none existed

  • tkinter.colorchooser
  • tkinter.commondialog
  • tkinter.filedialog
  • tkinter.messagebox
  • tkinter.simpledialog
  • tkinter.dnd

https://bugs.python.org/issue25237

@mention-bot
Copy link

@NP123, thanks for your PR! By analyzing the history of the files in this pull request, we identified @birkenfeld, @ezio-melotti and @berkerpeksag to be potential reviewers.

Copy link
Member

@vadmium vadmium left a comment

Choose a reason for hiding this comment

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

I left comments for basic things that stuck out. There are also opportunities to clarify the stub text, add more detail, and organize it, but this looks like a decent start.

@patel-nikhil
Copy link
Contributor Author

Thanks for the critique; my apologies for the spelling and grammatical errors. I am working towards revising and improving it.

@ned-deily
Copy link
Member

@vadmium Are you OK with the changes? @roseman Would you be willing to review the proposed changes?


The *askcolor* method is a factory method that creates a color choosing
dialog.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should add that this call will wait for the user to make a selection, and then will return the color selected (or None) to the caller


.. seealso::

:mod:`tkinter.commondialog`, :ref:`tut-files`
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest putting the ask* functions first, since those are the preferred interface. For each, mention that these are modal dialogs, also that return value may be None.

As for Directory()/FileDialog() and friends, I'd rather see these after the interfaces that people use, and should explicitly say that they create these dialogs from scratch and they don't resemble the platform ones. (They should also probably be deprecated, but that's a separate issue)


The :mod:`tkinter.font` module provides the :class:`Font` class for creating
and using named fonts.

Copy link
Contributor

Choose a reason for hiding this comment

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

The whole idea of "named fonts" is a bit of a cognitive mismatch with font objects, i.e. from the Python point of view you just want a font object, and it being a "named" font doesn't make a lot of sense. (In Tk, the string name of the font plays the same role as an object reference). Could you add something like "Named fonts are Tk's way of defining a font as a single object, rather than specifying the font each time as a list of font attributes."?

Copy link
Member

Choose a reason for hiding this comment

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

I agree with this addition.

askokcancel(title=None, message=None, **options)
askretrycancel(title=None, message=None, **options)
askyesno(title=None, message=None, **options)
askyesnocancel(title=None, message=None, **options)
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, just to mention that these are all modal so the calls complete after the user dismisses the dialogs. Return values vary with the type of message box created, which will be some subset of ok, cancel, yes, no, retry, abort, ignore.

In the synopsis I would probably refer to these as "alert" dialogs, which is the more familiar name.

Copy link
Member

Choose a reason for hiding this comment

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

I suggested a synopsis change. The returns for each functions should be specified. The last four can be covered with
Return one of the alternatives in the function name after display a box.
What does askquestion return? An answer the user enters? If so, the synopsis needs a further change.

Copy link
Contributor

@roseman roseman left a comment

Choose a reason for hiding this comment

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

Thank you very much for doing this! Detailed comments are mostly either small clarifications or additions, or suggestions for emphasizing or deemphasizing certain parts.

@patel-nikhil
Copy link
Contributor Author

@roseman thanks for all the feedback!

@willingc
Copy link
Contributor

willingc commented Jun 5, 2018

Thanks for the review @roseman and for the persistence on the PR @NP123.

When you are both happy with the PR, please ping me for core review. Thanks.

cc/ @serhiy-storchaka FYI as tkinter expert

@roseman
Copy link
Contributor

roseman commented Jun 5, 2018

Looks good to me! @willingc

@patel-nikhil
Copy link
Contributor Author

@roseman thanks again. Thanks @willingc - please review when you get the chance. Any and all feedback will be appreciated.

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.

I presume this is based on docstrings. Missing one (like for class.init) need to be filled in. Pre-PEP8 style (passive verbs) needs to be changed (to active verbs).


The :mod:`tkinter.font` module provides the :class:`Font` class for creating
and using named fonts.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with this addition.

askokcancel(title=None, message=None, **options)
askretrycancel(title=None, message=None, **options)
askyesno(title=None, message=None, **options)
askyesnocancel(title=None, message=None, **options)
Copy link
Member

Choose a reason for hiding this comment

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

I suggested a synopsis change. The returns for each functions should be specified. The last four can be covered with
Return one of the alternatives in the function name after display a box.
What does askquestion return? An answer the user enters? If so, the synopsis needs a further change.

@serhiy-storchaka serhiy-storchaka self-requested a review October 6, 2018 19:51
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

I suggest to merge the documentation for all dialog related modules into a single page.

@@ -33,14 +33,19 @@ alternatives, see the :ref:`other-gui-packages` section.
.. toctree::

tkinter.rst
tkinter.colorchooser.rst
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 it would be better to merge the documentation for all dialog related modules into a single page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By these do you mean {commondialog, dialog, simpledialog} only? I feel the filedialog and colorchooser modules each have distinct enough functionality and usage that it would be cleaner to keep them separate.

Freezing Tkinter applications


Freezing Tkinter applications
Copy link
Member

Choose a reason for hiding this comment

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

What is changed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

3 trailing blank lines that were present in the existing version were removed for consistent formatting. They caused a warning\error in the CI build, being flagged as trailing whitespace.

@patel-nikhil
Copy link
Contributor Author

patel-nikhil commented Nov 14, 2018

I have made the requested changes; please review again

1 similar comment
@patel-nikhil
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

@matrixise matrixise added the docs Documentation in the Doc dir label May 15, 2019
Copy link
Member

@JulienPalard JulienPalard left a comment

Choose a reason for hiding this comment

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

Hi @patel-nikhil! Thanks for this huge piece of documentation. I marked as resolved all previous reviews that you successfully resolved, but ther's still some opened reviews. I also had to replicate some (half-fixed ones typically).

Can you take a look at it?

**Static factory functions**

The below functions when called create a modal, native look-and-feel dialog,
wait for the user's selection, then return the selected value(s) or None to the
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
wait for the user's selection, then return the selected value(s) or None to the
wait for the user's selection, then return the selected value(s) or `None` to the

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Am I correct in assuming you mean ``None`` instead of `None` since make check gives me 1 error with severity 2 (reason: default role used) when using single backquotes to surround None

Copy link
Member

Choose a reason for hiding this comment

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

Yes I meant None, thanks for proofreading my proofreading 👍

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

@patel-nikhil
Copy link
Contributor Author

I have made the requested changes; please review again.

@JulienPalard thanks for your efforts! I've read through the remaining previously open reviews, and the changes you highlighted in your comments, and have addressed them with my latest commit.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@terryjreedy, @JulienPalard: please review the changes made to this pull request.

@terryjreedy
Copy link
Member

I leave it a final review to Julien

@JulienPalard JulienPalard merged commit 80428ed into python:master Sep 10, 2019
@JulienPalard
Copy link
Member

@patel-nikhil thanks for this huge piece of documentation!

@@ -0,0 +1,230 @@
Tkinter Dialogs
Copy link
Member

Choose a reason for hiding this comment

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

A bit late to the party, but may I suggest that this file be renamed to tkinter.dialog.rst?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.