-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add defaults for tkinter __init__
methods
#11391
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
Conversation
NOTE: Listbox `exportselection` param type might be wrong, should perhaps be `bool`, not `int`, like all the other `exportselection` params
NOTE: not sure what to put for `Message(padx, pady)`. The default is always `"-1"` but the pad value must be positive, see https://tcl.tk/man/tcl8.6/TkCmd/options.htm#M-padx#:~:text=Command%2DLine%20Name%3A%20%2Dpadx,Specifies%20a%20non%2Dnegative%20value
Make it an actual `int` it is compatible with the `_TakeFocusValue` type
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.
Thanks for doing this! For now I went through Toplevel
and Button
options manually.
Are you going to make a separate PR that does this for I mostly use the ttk widgets in my projects, because I can apply an awesome theme to them. I think a separate PR for ttk widgets would be easier to review than adding their defaults to this PR. This way, we won't get confused about
This is small compared to my biggest autogenerated tkinter PR :) |
This comment has been minimized.
This comment has been minimized.
…0"` on all platforms
This comment has been minimized.
This comment has been minimized.
… a string For the rest of the integer-in-strings, the default value is consistently a string on all platforms, so I'm not sure if I should replace those with a plain integer (this would probably be more useful in IDEs but less accurate)
Yes |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
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.
Thanks! In separate PRs, we still need to add:
- the same defaults for
configure()
methods - defaults for ttk widgets.
Add defaults for
tkinter
's__init__
methods, see #10947The defaults I filled in are consistent across:
All available github actions runners:
ubuntu-20.04
,ubuntu-22.04
windows-2019
,windows-2022
macos-11
,macos-12
,macos-13
I used a script to generate the defaults into a JSON file (source code at https://github.com/MarcellPerger1/typeshed-tkinter-defaults), then I filled them into the arguments by hand (I also checked them with the tcl.tk documentation to ensure the defaults make sense).
I tried to fill the defaults in a way that keeps the defaults value consistent with the argument type (while still keeping it close to the types returned by
.cget
).Some notes about specific arguments:
variable
andtextvariable
: The default value (usingdict
) is consistently""
but this doesn't match the annotatedVariable
type so I didn't fill these inMessage(padx, pady)
: The default value is-1
which is not allowed according to the documentation so I didn't fill this inToplevel(use)
: The default value is always""
but this doesn't match the annotatedint
type so I didn't fill this inP.S. Sorry for the huge diff.