Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-126008: Improve docstrings for Tkinter cget and configure methods#133303

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
serhiy-storchaka wants to merge2 commits intopython:main
base:main
Choose a base branch
Loading
fromserhiy-storchaka:docs-tkinter-configure

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchakaserhiy-storchaka commentedMay 2, 2025
edited by bedevere-appbot
Loading

  • Explain the behavior of Widget.configure() depending on arguments.
  • Unify descriptions.
  • Replace "resource" with "option".

…thods* Explain the behavior of Widget.configure() depending on arguments.* Unify descriptions.* Replace "resource" with "option".
option(s) to have the given value(s); in this case the
command returns an empty string. The following options
are supported:
"""Query or modify the configuration options for window TAGORID.
Copy link
Member

Choose a reason for hiding this comment

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

It took me a while to understand whatTAGORID meant, maybe it'd be better if we match the parameter name, i.e. usetarOrId (and similar for the other cases)?

Copy link
Member

Choose a reason for hiding this comment

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

As I indicated elsewhere, I think the raw test should be*tagOrID* as italicizing option names is better than all-capping them.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

In THIS file, capitalization is used for parameter names. It is not ideal, but we should be consistent.

Actions are bound to events byresources (e.g. keyword argument
command) or with themethodbind.
Actions are bound to events byoptions (e.g. keyword argument
command) or with the bind() method.
Copy link
Member

Choose a reason for hiding this comment

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

'command' needs to be marked as literal string.

Suggested change
command)orwiththebind()method.
`command`)orwiththebind()method.

Not sure if suggestion is correct, but as is, I initially read this 'keyword-option-command' as 1 compound noun.

Also, line 28, in the example, which is what got me to parse this correctly, needs 2 spaces after commas.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

What aboutthe command keyword argument?

Copy link
Member

Choose a reason for hiding this comment

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

OK

@@ -1827,18 +1827,24 @@ def _configure(self, cmd, cnf, kw):
# These used to be defined in Widget:

def configure(self, cnf=None, **kw):
"""Configure resourcesofa widget.
"""Query or modify the configuration optionsofthe 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
"""Queryormodifytheconfigurationoptionsofthewidget.
"""Queryormodifytheconfigurationoptionsofwidget*self*.

The expand text below is very nice.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

* and other markup is not used in docstrings. At least not in this file.

return self.tk.call(
(self._w, 'itemcget') + (tagOrId, '-'+option))

def itemconfigure(self, tagOrId, cnf=None, **kw):
"""Configure resources of an item TAGORID.
"""Query or modify the configuration options of an item TAGORID.
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
"""QueryormodifytheconfigurationoptionsofanitemTAGORID.
"""Queryormodifytheconfigurationoptionsofitem*tagOrID*.

Just remembered that

Copy link
Member

Choose a reason for hiding this comment

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

https://peps.python.org/pep-0257/#multi-line-docstrings says "Do not use the Emacs convention of mentioning the arguments of functions or methods in upper case in running text. Python is case sensitive and the argument names can be used for keyword arguments, so the docstring should document the correct argument names." 'tagOrID' is an example of why not. It goes on to suggest " It is best to list each argument on a separate line. For example:..." but this tends to bloat the doc. Don't add *s if you do not want, but please drop the all caps at least here.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Using different convention for different methods will do more harm than good. This is a different issue, we will change the convention after fixing all docstrings.

option(s) to have the given value(s); in this case the
command returns an empty string. The following options
are supported:
"""Query or modify the configuration options for window TAGORID.
Copy link
Member

Choose a reason for hiding this comment

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

As I indicated elsewhere, I think the raw test should be*tagOrID* as italicizing option names is better than all-capping them.

@bedevere-app
Copy link

When you're done making the requested changes, leave the comment:I have made the requested changes; please review again.

@serhiy-storchakaserhiy-storchaka added the needs backport to 3.14bugs and security fixes labelMay 8, 2025
@serhiy-storchakaserhiy-storchaka requested a review froma teamMay 13, 2025 10:36
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tomasr8tomasr8tomasr8 left review comments

@terryjreedyterryjreedyterryjreedy requested changes

Assignees
No one assigned
Labels
awaiting changesdocsDocumentation in the Doc dirneeds backport to 3.13bugs and security fixesneeds backport to 3.14bugs and security fixesskip news
Projects
Status: Todo
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@serhiy-storchaka@tomasr8@terryjreedy

[8]ページ先頭

©2009-2025 Movatter.jp