From 279ef338e54252dd94e24fc5d151576d870a3c77 Mon Sep 17 00:00:00 2001 From: Marcell Perger Date: Sat, 3 Feb 2024 22:34:08 +0000 Subject: [PATCH 01/14] Add defaults for tkinter.Canvas, Button --- stdlib/tkinter/__init__.pyi | 68 ++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index ff876d0bb88c..c3897f8bd045 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1006,46 +1006,46 @@ class Button(Widget): *, activebackground: str = ..., activeforeground: str = ..., - anchor: _Anchor = ..., + anchor: _Anchor = "center", background: str = ..., bd: _ScreenUnits = ..., # same as borderwidth bg: str = ..., # same as background - bitmap: str = ..., + bitmap: str = "", border: _ScreenUnits = ..., # same as borderwidth borderwidth: _ScreenUnits = ..., - command: _ButtonCommand = ..., - compound: _Compound = ..., - cursor: _Cursor = ..., - default: Literal["normal", "active", "disabled"] = ..., + command: _ButtonCommand = "", + compound: _Compound = "none", + cursor: _Cursor = "", + default: Literal["normal", "active", "disabled"] = "disabled", disabledforeground: str = ..., fg: str = ..., # same as foreground - font: _FontDescription = ..., + font: _FontDescription = "TkDefaultFont", foreground: str = ..., # width and height must be int for buttons containing just text, but # ints are also valid _ScreenUnits - height: _ScreenUnits = ..., + height: _ScreenUnits = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = ..., - image: _ImageSpec = ..., - justify: Literal["left", "center", "right"] = ..., + highlightthickness: _ScreenUnits = "1", + image: _ImageSpec = "", + justify: Literal["left", "center", "right"] = "center", name: str = ..., - overrelief: _Relief = ..., + overrelief: _Relief = "", padx: _ScreenUnits = ..., pady: _ScreenUnits = ..., relief: _Relief = ..., repeatdelay: int = ..., repeatinterval: int = ..., - state: Literal["normal", "active", "disabled"] = ..., - takefocus: _TakeFocusValue = ..., - text: float | str = ..., + state: Literal["normal", "active", "disabled"] = "normal", + takefocus: _TakeFocusValue = "", + text: float | str = "", # We allow the textvariable to be any Variable, not necessarily # StringVar. This is useful for e.g. a button that displays the value # of an IntVar. textvariable: Variable = ..., underline: int = ..., - width: _ScreenUnits = ..., - wraplength: _ScreenUnits = ..., + width: _ScreenUnits = 0, + wraplength: _ScreenUnits = "0", ) -> None: ... @overload def configure( @@ -1102,13 +1102,13 @@ class Canvas(Widget, XView, YView): cnf: dict[str, Any] | None = {}, *, background: str = ..., - bd: _ScreenUnits = ..., + bd: _ScreenUnits = "0", bg: str = ..., border: _ScreenUnits = ..., - borderwidth: _ScreenUnits = ..., - closeenough: float = ..., - confine: bool = ..., - cursor: _Cursor = ..., + borderwidth: _ScreenUnits = "0", + closeenough: float = 1.0, + confine: bool = True, + cursor: _Cursor = "", # canvas manual page has a section named COORDINATES, and the first # part of it describes _ScreenUnits. height: _ScreenUnits = ..., @@ -1116,27 +1116,27 @@ class Canvas(Widget, XView, YView): highlightcolor: str = ..., highlightthickness: _ScreenUnits = ..., insertbackground: str = ..., - insertborderwidth: _ScreenUnits = ..., - insertofftime: int = ..., - insertontime: int = ..., - insertwidth: _ScreenUnits = ..., + insertborderwidth: _ScreenUnits = "0", + insertofftime: int = 300, + insertontime: int = 600, + insertwidth: _ScreenUnits = "2", name: str = ..., offset=..., # undocumented - relief: _Relief = ..., + relief: _Relief = "flat", # Setting scrollregion to None doesn't reset it back to empty, # but setting it to () does. scrollregion: tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits] | tuple[()] = ..., selectbackground: str = ..., - selectborderwidth: _ScreenUnits = ..., + selectborderwidth: _ScreenUnits = "1", selectforeground: str = ..., # man page says that state can be 'hidden', but it can't - state: Literal["normal", "disabled"] = ..., - takefocus: _TakeFocusValue = ..., + state: Literal["normal", "disabled"] = "normal", + takefocus: _TakeFocusValue = "", width: _ScreenUnits = ..., - xscrollcommand: _XYScrollCommand = ..., - xscrollincrement: _ScreenUnits = ..., - yscrollcommand: _XYScrollCommand = ..., - yscrollincrement: _ScreenUnits = ..., + xscrollcommand: _XYScrollCommand = "", + xscrollincrement: _ScreenUnits = "0", + yscrollcommand: _XYScrollCommand = "", + yscrollincrement: _ScreenUnits = "0", ) -> None: ... @overload def configure( From c2faeb2047baa6f8cce2c8a3158f47eeeb3d2ef1 Mon Sep 17 00:00:00 2001 From: Marcell Perger <102254594+MarcellPerger1@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:31:53 +0000 Subject: [PATCH 02/14] Fix Canvas, start Checkbutton --- stdlib/tkinter/__init__.pyi | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index c3897f8bd045..13f5f96d27e1 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1043,7 +1043,7 @@ class Button(Widget): # StringVar. This is useful for e.g. a button that displays the value # of an IntVar. textvariable: Variable = ..., - underline: int = ..., + underline: int = -1, width: _ScreenUnits = 0, wraplength: _ScreenUnits = "0", ) -> None: ... @@ -1125,7 +1125,7 @@ class Canvas(Widget, XView, YView): relief: _Relief = "flat", # Setting scrollregion to None doesn't reset it back to empty, # but setting it to () does. - scrollregion: tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits] | tuple[()] = ..., + scrollregion: tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits] | tuple[()] = (), selectbackground: str = ..., selectborderwidth: _ScreenUnits = "1", selectforeground: str = ..., @@ -1742,21 +1742,21 @@ class Checkbutton(Widget): *, activebackground: str = ..., activeforeground: str = ..., - anchor: _Anchor = ..., + anchor: _Anchor = "center", background: str = ..., bd: _ScreenUnits = ..., bg: str = ..., - bitmap: str = ..., + bitmap: str = "", border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., - command: _ButtonCommand = ..., - compound: _Compound = ..., - cursor: _Cursor = ..., + command: _ButtonCommand = "", + compound: _Compound = "none", + cursor: _Cursor = "", disabledforeground: str = ..., fg: str = ..., - font: _FontDescription = ..., + font: _FontDescription = "TkDefaultFont", foreground: str = ..., - height: _ScreenUnits = ..., + height: _ScreenUnits = 0, highlightbackground: str = ..., highlightcolor: str = ..., highlightthickness: _ScreenUnits = ..., @@ -1778,21 +1778,21 @@ class Checkbutton(Widget): offvalue: Any = ..., onvalue: Any = ..., overrelief: _Relief = ..., - padx: _ScreenUnits = ..., - pady: _ScreenUnits = ..., - relief: _Relief = ..., + padx: _ScreenUnits = 1, + pady: _ScreenUnits = 1, + relief: _Relief = "flat", selectcolor: str = ..., - selectimage: _ImageSpec = ..., - state: Literal["normal", "active", "disabled"] = ..., - takefocus: _TakeFocusValue = ..., - text: float | str = ..., + selectimage: _ImageSpec = "", + state: Literal["normal", "active", "disabled"] = "normal", + takefocus: _TakeFocusValue = "", + text: float | str = "", textvariable: Variable = ..., - tristateimage: _ImageSpec = ..., - tristatevalue: Any = ..., - underline: int = ..., + tristateimage: _ImageSpec = "", + tristatevalue: Any = "", + underline: int = -1, variable: Variable | Literal[""] = ..., - width: _ScreenUnits = ..., - wraplength: _ScreenUnits = ..., + width: _ScreenUnits = 0, + wraplength: _ScreenUnits = "0", ) -> None: ... @overload def configure( From 43b0597cb5b7d0dd15de600f4cc39ad237676e69 Mon Sep 17 00:00:00 2001 From: Marcell Perger Date: Mon, 5 Feb 2024 21:31:36 +0000 Subject: [PATCH 03/14] Finish defaults for Checkbutton, Entry, Frame, Label --- stdlib/tkinter/__init__.pyi | 120 ++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 13f5f96d27e1..4b9832ba4d6b 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1759,10 +1759,10 @@ class Checkbutton(Widget): height: _ScreenUnits = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = ..., - image: _ImageSpec = ..., - indicatoron: bool = ..., - justify: Literal["left", "center", "right"] = ..., + highlightthickness: _ScreenUnits = "1", + image: _ImageSpec = "", + indicatoron: bool = True, + justify: Literal["left", "center", "right"] = "center", name: str = ..., offrelief: _Relief = ..., # The checkbutton puts a value to its variable when it's checked or @@ -1775,11 +1775,11 @@ class Checkbutton(Widget): # and list[int] are incompatible. Also, we would need a way to # specify "Checkbutton not associated with any variable", which is # done by setting variable to empty string (the default). - offvalue: Any = ..., - onvalue: Any = ..., - overrelief: _Relief = ..., - padx: _ScreenUnits = 1, - pady: _ScreenUnits = 1, + offvalue: Any = "0", + onvalue: Any = "1", + overrelief: _Relief = "", + padx: _ScreenUnits = "1", + pady: _ScreenUnits = "1", relief: _Relief = "flat", selectcolor: str = ..., selectimage: _ImageSpec = "", @@ -1790,7 +1790,7 @@ class Checkbutton(Widget): tristateimage: _ImageSpec = "", tristatevalue: Any = "", underline: int = -1, - variable: Variable | Literal[""] = ..., + variable: Variable | Literal[""] = "", width: _ScreenUnits = 0, wraplength: _ScreenUnits = "0", ) -> None: ... @@ -1864,39 +1864,39 @@ class Entry(Widget, XView): bg: str = ..., border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., - cursor: _Cursor = ..., + cursor: _Cursor = "xterm", disabledbackground: str = ..., disabledforeground: str = ..., - exportselection: bool = ..., + exportselection: bool = True, fg: str = ..., - font: _FontDescription = ..., + font: _FontDescription = "TkTextFont", foreground: str = ..., highlightbackground: str = ..., highlightcolor: str = ..., highlightthickness: _ScreenUnits = ..., insertbackground: str = ..., - insertborderwidth: _ScreenUnits = ..., - insertofftime: int = ..., - insertontime: int = ..., + insertborderwidth: _ScreenUnits = 0, + insertofftime: int = 300, + insertontime: int = 600, insertwidth: _ScreenUnits = ..., - invalidcommand: _EntryValidateCommand = ..., - invcmd: _EntryValidateCommand = ..., # same as invalidcommand - justify: Literal["left", "center", "right"] = ..., + invalidcommand: _EntryValidateCommand = "", + invcmd: _EntryValidateCommand = "", # same as invalidcommand + justify: Literal["left", "center", "right"] = "left", name: str = ..., readonlybackground: str = ..., - relief: _Relief = ..., + relief: _Relief = "sunken", selectbackground: str = ..., selectborderwidth: _ScreenUnits = ..., selectforeground: str = ..., - show: str = ..., - state: Literal["normal", "disabled", "readonly"] = ..., - takefocus: _TakeFocusValue = ..., + show: str = "", + state: Literal["normal", "disabled", "readonly"] = "normal", + takefocus: _TakeFocusValue = "", textvariable: Variable = ..., - validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: _EntryValidateCommand = ..., - vcmd: _EntryValidateCommand = ..., # same as validatecommand - width: int = ..., - xscrollcommand: _XYScrollCommand = ..., + validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = "none", + validatecommand: _EntryValidateCommand = "", + vcmd: _EntryValidateCommand = "", # same as validatecommand + width: int = 20, + xscrollcommand: _XYScrollCommand = "", ) -> None: ... @overload def configure( @@ -1971,25 +1971,25 @@ class Frame(Widget): cnf: dict[str, Any] | None = {}, *, background: str = ..., - bd: _ScreenUnits = ..., + bd: _ScreenUnits = 0, bg: str = ..., border: _ScreenUnits = ..., - borderwidth: _ScreenUnits = ..., - class_: str = ..., # can't be changed with configure() - colormap: Literal["new", ""] | Misc = ..., # can't be changed with configure() - container: bool = ..., # can't be changed with configure() - cursor: _Cursor = ..., - height: _ScreenUnits = ..., + borderwidth: _ScreenUnits = 0, + class_: str = "Frame", # can't be changed with configure() + colormap: Literal["new", ""] | Misc = "", # can't be changed with configure() + container: bool = False, # can't be changed with configure() + cursor: _Cursor = "", + height: _ScreenUnits = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = ..., + highlightthickness: _ScreenUnits = 0, name: str = ..., - padx: _ScreenUnits = ..., - pady: _ScreenUnits = ..., - relief: _Relief = ..., - takefocus: _TakeFocusValue = ..., - visual: str | tuple[str, int] = ..., # can't be changed with configure() - width: _ScreenUnits = ..., + padx: _ScreenUnits = "0", + pady: _ScreenUnits = "0", + relief: _Relief = "flat", + takefocus: _TakeFocusValue = 0, + visual: str | tuple[str, int] = "", # can't be changed with configure() + width: _ScreenUnits = 0, ) -> None: ... @overload def configure( @@ -2024,36 +2024,36 @@ class Label(Widget): *, activebackground: str = ..., activeforeground: str = ..., - anchor: _Anchor = ..., + anchor: _Anchor = "center", background: str = ..., bd: _ScreenUnits = ..., bg: str = ..., - bitmap: str = ..., + bitmap: str = "", border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., - compound: _Compound = ..., - cursor: _Cursor = ..., + compound: _Compound = "none", + cursor: _Cursor = "", disabledforeground: str = ..., fg: str = ..., - font: _FontDescription = ..., + font: _FontDescription = "TkDefaultFont", foreground: str = ..., - height: _ScreenUnits = ..., + height: _ScreenUnits = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = ..., - image: _ImageSpec = ..., - justify: Literal["left", "center", "right"] = ..., + highlightthickness: _ScreenUnits = "0", + image: _ImageSpec = "", + justify: Literal["left", "center", "right"] = "center", name: str = ..., - padx: _ScreenUnits = ..., - pady: _ScreenUnits = ..., - relief: _Relief = ..., - state: Literal["normal", "active", "disabled"] = ..., - takefocus: _TakeFocusValue = ..., - text: float | str = ..., + padx: _ScreenUnits = "1", + pady: _ScreenUnits = "1", + relief: _Relief = "flat", + state: Literal["normal", "active", "disabled"] = "normal", + takefocus: _TakeFocusValue = "0", + text: float | str = "", textvariable: Variable = ..., - underline: int = ..., - width: _ScreenUnits = ..., - wraplength: _ScreenUnits = ..., + underline: int = -1, + width: _ScreenUnits = 0, + wraplength: _ScreenUnits = "0", ) -> None: ... @overload def configure( From 7fd7b033b5dce69fb075b77c625e54a5b57c36f8 Mon Sep 17 00:00:00 2001 From: Marcell Perger <102254594+MarcellPerger1@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:28:15 +0000 Subject: [PATCH 04/14] Do LabelFrame, Listbox NOTE: Listbox `exportselection` param type might be wrong, should perhaps be `bool`, not `int`, like all the other `exportselection` params --- stdlib/tkinter/__init__.pyi | 62 ++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 4b9832ba4d6b..29ad86885c27 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -2104,21 +2104,21 @@ class Listbox(Widget, XView, YView): *, activestyle: Literal["dotbox", "none", "underline"] = ..., background: str = ..., - bd: _ScreenUnits = ..., + bd: _ScreenUnits = 1, bg: str = ..., border: _ScreenUnits = ..., - borderwidth: _ScreenUnits = ..., - cursor: _Cursor = ..., + borderwidth: _ScreenUnits = 1, + cursor: _Cursor = "", disabledforeground: str = ..., - exportselection: int = ..., + exportselection: int = 1, fg: str = ..., font: _FontDescription = ..., foreground: str = ..., - height: int = ..., + height: int = 10, highlightbackground: str = ..., highlightcolor: str = ..., highlightthickness: _ScreenUnits = ..., - justify: Literal["left", "center", "right"] = ..., + justify: Literal["left", "center", "right"] ="left", # There's no tkinter.ListVar, but seems like bare tkinter.Variable # actually works for this: # @@ -2132,20 +2132,20 @@ class Listbox(Widget, XView, YView): name: str = ..., relief: _Relief = ..., selectbackground: str = ..., - selectborderwidth: _ScreenUnits = ..., + selectborderwidth: _ScreenUnits = 0, selectforeground: str = ..., # from listbox man page: "The value of the [selectmode] option may be # arbitrary, but the default bindings expect it to be ..." # # I have never seen anyone setting this to something else than what # "the default bindings expect", but let's support it anyway. - selectmode: str = ..., - setgrid: bool = ..., - state: Literal["normal", "disabled"] = ..., - takefocus: _TakeFocusValue = ..., - width: int = ..., - xscrollcommand: _XYScrollCommand = ..., - yscrollcommand: _XYScrollCommand = ..., + selectmode: str = "browse", + setgrid: bool = False, + state: Literal["normal", "disabled"] = "normal", + takefocus: _TakeFocusValue = "", + width: int = 20, + xscrollcommand: _XYScrollCommand = "", + yscrollcommand: _XYScrollCommand = "", ) -> None: ... @overload def configure( @@ -3504,32 +3504,32 @@ class LabelFrame(Widget): cnf: dict[str, Any] | None = {}, *, background: str = ..., - bd: _ScreenUnits = ..., + bd: _ScreenUnits = 2, bg: str = ..., border: _ScreenUnits = ..., - borderwidth: _ScreenUnits = ..., - class_: str = ..., # can't be changed with configure() - colormap: Literal["new", ""] | Misc = ..., # can't be changed with configure() - container: bool = ..., # undocumented, can't be changed with configure() - cursor: _Cursor = ..., + borderwidth: _ScreenUnits = 2, + class_: str = "Labelframe", # can't be changed with configure() + colormap: Literal["new", ""] | Misc = "", # can't be changed with configure() + container: bool = False, # undocumented, can't be changed with configure() + cursor: _Cursor = "", fg: str = ..., - font: _FontDescription = ..., + font: _FontDescription = "TkDefaultFont", foreground: str = ..., - height: _ScreenUnits = ..., + height: _ScreenUnits = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = ..., + highlightthickness: _ScreenUnits = 0, # 'ne' and 'en' are valid labelanchors, but only 'ne' is a valid _Anchor. - labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = ..., + labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = "nw", labelwidget: Misc = ..., name: str = ..., - padx: _ScreenUnits = ..., - pady: _ScreenUnits = ..., - relief: _Relief = ..., - takefocus: _TakeFocusValue = ..., - text: float | str = ..., - visual: str | tuple[str, int] = ..., # can't be changed with configure() - width: _ScreenUnits = ..., + padx: _ScreenUnits = "0", + pady: _ScreenUnits = "0", + relief: _Relief = "groove", + takefocus: _TakeFocusValue = "0", + text: float | str = "", + visual: str | tuple[str, int] = "", # can't be changed with configure() + width: _ScreenUnits = 0, ) -> None: ... @overload def configure( From 37ff1a03751ab288863f1d632900b3a480495aa7 Mon Sep 17 00:00:00 2001 From: Marcell Perger Date: Fri, 9 Feb 2024 19:40:41 +0000 Subject: [PATCH 05/14] Defaults for Menu, Menubutton, Message 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 --- stdlib/tkinter/__init__.pyi | 66 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 29ad86885c27..75d6b0ae9729 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -2223,23 +2223,23 @@ class Menu(Widget): bg: str = ..., border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., - cursor: _Cursor = ..., + cursor: _Cursor = "arrow", disabledforeground: str = ..., fg: str = ..., font: _FontDescription = ..., foreground: str = ..., name: str = ..., - postcommand: Callable[[], object] | str = ..., + postcommand: Callable[[], object] | str = "", relief: _Relief = ..., selectcolor: str = ..., - takefocus: _TakeFocusValue = ..., + takefocus: _TakeFocusValue = "0", tearoff: int = ..., # I guess tearoffcommand arguments are supposed to be widget objects, # but they are widget name strings. Use nametowidget() to handle the # arguments of tearoffcommand. - tearoffcommand: Callable[[str, str], object] | str = ..., - title: str = ..., - type: Literal["menubar", "tearoff", "normal"] = ..., + tearoffcommand: Callable[[str, str], object] | str = "", + title: str = "", + type: Literal["menubar", "tearoff", "normal"] = "normal", ) -> None: ... @overload def configure( @@ -2491,35 +2491,35 @@ class Menubutton(Widget): background: str = ..., bd: _ScreenUnits = ..., bg: str = ..., - bitmap: str = ..., + bitmap: str = "", border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., - compound: _Compound = ..., - cursor: _Cursor = ..., - direction: Literal["above", "below", "left", "right", "flush"] = ..., + compound: _Compound = "none", + cursor: _Cursor = "", + direction: Literal["above", "below", "left", "right", "flush"] = "below", disabledforeground: str = ..., fg: str = ..., - font: _FontDescription = ..., + font: _FontDescription = "TkDefaultFont", foreground: str = ..., - height: _ScreenUnits = ..., + height: _ScreenUnits = "0", highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = ..., - image: _ImageSpec = ..., + highlightthickness: _ScreenUnits = 0, + image: _ImageSpec = "", indicatoron: bool = ..., justify: Literal["left", "center", "right"] = ..., menu: Menu = ..., name: str = ..., padx: _ScreenUnits = ..., pady: _ScreenUnits = ..., - relief: _Relief = ..., - state: Literal["normal", "active", "disabled"] = ..., - takefocus: _TakeFocusValue = ..., - text: float | str = ..., + relief: _Relief = "flat", + state: Literal["normal", "active", "disabled"] = "normal", + takefocus: _TakeFocusValue = "0", + text: float | str = "", textvariable: Variable = ..., - underline: int = ..., - width: _ScreenUnits = ..., - wraplength: _ScreenUnits = ..., + underline: int = -1, + width: _ScreenUnits = "0", + wraplength: _ScreenUnits = 0, ) -> None: ... @overload def configure( @@ -2571,30 +2571,30 @@ class Message(Widget): master: Misc | None = None, cnf: dict[str, Any] | None = {}, *, - anchor: _Anchor = ..., - aspect: int = ..., + anchor: _Anchor = "center", + aspect: int = 150, background: str = ..., - bd: _ScreenUnits = ..., + bd: _ScreenUnits = 1, bg: str = ..., border: _ScreenUnits = ..., - borderwidth: _ScreenUnits = ..., - cursor: _Cursor = ..., + borderwidth: _ScreenUnits = 1, + cursor: _Cursor = "", fg: str = ..., - font: _FontDescription = ..., + font: _FontDescription = "TkDefaultFont", foreground: str = ..., highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = ..., - justify: Literal["left", "center", "right"] = ..., + highlightthickness: _ScreenUnits = 0, + justify: Literal["left", "center", "right"] = "left", name: str = ..., padx: _ScreenUnits = ..., pady: _ScreenUnits = ..., - relief: _Relief = ..., - takefocus: _TakeFocusValue = ..., - text: float | str = ..., + relief: _Relief = "flat", + takefocus: _TakeFocusValue = "0", + text: float | str = "", textvariable: Variable = ..., # there's width but no height - width: _ScreenUnits = ..., + width: _ScreenUnits = 0, ) -> None: ... @overload def configure( From f1f45b02245de6751b15e8274956172d872e03d6 Mon Sep 17 00:00:00 2001 From: Marcell Perger Date: Fri, 9 Feb 2024 21:30:24 +0000 Subject: [PATCH 06/14] Defaults for PanedWindow, Radiobutton, Scale, Scrollbar --- stdlib/tkinter/__init__.pyi | 152 ++++++++++++++++++------------------ 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 75d6b0ae9729..53b06b4f1f37 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -2636,46 +2636,46 @@ class Radiobutton(Widget): *, activebackground: str = ..., activeforeground: str = ..., - anchor: _Anchor = ..., + anchor: _Anchor = "center", background: str = ..., bd: _ScreenUnits = ..., bg: str = ..., - bitmap: str = ..., + bitmap: str = "", border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., - command: _ButtonCommand = ..., - compound: _Compound = ..., - cursor: _Cursor = ..., + command: _ButtonCommand = "", + compound: _Compound = "none", + cursor: _Cursor = "", disabledforeground: str = ..., fg: str = ..., - font: _FontDescription = ..., + font: _FontDescription = "TkDefaultFont", foreground: str = ..., - height: _ScreenUnits = ..., + height: _ScreenUnits = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = ..., - image: _ImageSpec = ..., - indicatoron: bool = ..., - justify: Literal["left", "center", "right"] = ..., + highlightthickness: _ScreenUnits = "1", + image: _ImageSpec = "", + indicatoron: bool = True, + justify: Literal["left", "center", "right"] = "center", name: str = ..., offrelief: _Relief = ..., - overrelief: _Relief = ..., - padx: _ScreenUnits = ..., - pady: _ScreenUnits = ..., - relief: _Relief = ..., + overrelief: _Relief = "", + padx: _ScreenUnits = "1", + pady: _ScreenUnits = "1", + relief: _Relief = "flat", selectcolor: str = ..., - selectimage: _ImageSpec = ..., - state: Literal["normal", "active", "disabled"] = ..., - takefocus: _TakeFocusValue = ..., - text: float | str = ..., + selectimage: _ImageSpec = "", + state: Literal["normal", "active", "disabled"] = "normal", + takefocus: _TakeFocusValue = "", + text: float | str = "", textvariable: Variable = ..., - tristateimage: _ImageSpec = ..., - tristatevalue: Any = ..., - underline: int = ..., - value: Any = ..., + tristateimage: _ImageSpec = "", + tristatevalue: Any = "", + underline: int = -1, + value: Any = "", variable: Variable | Literal[""] = ..., - width: _ScreenUnits = ..., - wraplength: _ScreenUnits = ..., + width: _ScreenUnits = 0, + wraplength: _ScreenUnits = "0", ) -> None: ... @overload def configure( @@ -2740,40 +2740,40 @@ class Scale(Widget): *, activebackground: str = ..., background: str = ..., - bd: _ScreenUnits = ..., + bd: _ScreenUnits = "1", bg: str = ..., - bigincrement: float = ..., + bigincrement: float = 0.0, border: _ScreenUnits = ..., - borderwidth: _ScreenUnits = ..., + borderwidth: _ScreenUnits = 1, # don't know why the callback gets string instead of float - command: str | Callable[[str], object] = ..., - cursor: _Cursor = ..., - digits: int = ..., + command: str | Callable[[str], object] = "", + cursor: _Cursor = "", + digits: int = 0, fg: str = ..., - font: _FontDescription = ..., + font: _FontDescription = "TkDefaultFont", foreground: str = ..., - from_: float = ..., + from_: float = 0.0, highlightbackground: str = ..., highlightcolor: str = ..., highlightthickness: _ScreenUnits = ..., - label: str = ..., - length: _ScreenUnits = ..., + label: str = "", + length: _ScreenUnits = 100, name: str = ..., - orient: Literal["horizontal", "vertical"] = ..., - relief: _Relief = ..., - repeatdelay: int = ..., - repeatinterval: int = ..., - resolution: float = ..., - showvalue: bool = ..., - sliderlength: _ScreenUnits = ..., - sliderrelief: _Relief = ..., - state: Literal["normal", "active", "disabled"] = ..., - takefocus: _TakeFocusValue = ..., - tickinterval: float = ..., - to: float = ..., + orient: Literal["horizontal", "vertical"] = "vertical", + relief: _Relief = "flat", + repeatdelay: int = 300, + repeatinterval: int = 100, + resolution: float = 1.0, + showvalue: bool = True, + sliderlength: _ScreenUnits = 30, + sliderrelief: _Relief = "raised", + state: Literal["normal", "active", "disabled"] = "normal", + takefocus: _TakeFocusValue = "", + tickinterval: float = 0.0, + to: float = 100.0, troughcolor: str = ..., variable: IntVar | DoubleVar = ..., - width: _ScreenUnits = ..., + width: _ScreenUnits = 15, ) -> None: ... @overload def configure( @@ -2830,7 +2830,7 @@ class Scrollbar(Widget): cnf: dict[str, Any] | None = {}, *, activebackground: str = ..., - activerelief: _Relief = ..., + activerelief: _Relief = "raised", background: str = ..., bd: _ScreenUnits = ..., bg: str = ..., @@ -2840,19 +2840,19 @@ class Scrollbar(Widget): # 'SCROLLING COMMANDS' in scrollbar man page. There doesn't seem to # be any way to specify an overloaded callback function, so we say # that it can take any args while it can't in reality. - command: Callable[..., tuple[float, float] | None] | str = ..., - cursor: _Cursor = ..., - elementborderwidth: _ScreenUnits = ..., + command: Callable[..., tuple[float, float] | None] | str = "", + cursor: _Cursor = "", + elementborderwidth: _ScreenUnits = "-1", highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = ..., - jump: bool = ..., + highlightthickness: _ScreenUnits = "0", + jump: bool = False, name: str = ..., - orient: Literal["horizontal", "vertical"] = ..., + orient: Literal["horizontal", "vertical"] = "vertical", relief: _Relief = ..., - repeatdelay: int = ..., - repeatinterval: int = ..., - takefocus: _TakeFocusValue = ..., + repeatdelay: int = 300, + repeatinterval: int = 100, + takefocus: _TakeFocusValue = "", troughcolor: str = ..., width: _ScreenUnits = ..., ) -> None: ... @@ -3569,27 +3569,27 @@ class PanedWindow(Widget): cnf: dict[str, Any] | None = {}, *, background: str = ..., - bd: _ScreenUnits = ..., + bd: _ScreenUnits = 1, bg: str = ..., border: _ScreenUnits = ..., - borderwidth: _ScreenUnits = ..., - cursor: _Cursor = ..., - handlepad: _ScreenUnits = ..., - handlesize: _ScreenUnits = ..., - height: _ScreenUnits = ..., + borderwidth: _ScreenUnits = 1, + cursor: _Cursor = "", + handlepad: _ScreenUnits = 8, + handlesize: _ScreenUnits = "8", + height: _ScreenUnits = "", name: str = ..., - opaqueresize: bool = ..., - orient: Literal["horizontal", "vertical"] = ..., - proxybackground: str = ..., - proxyborderwidth: _ScreenUnits = ..., - proxyrelief: _Relief = ..., - relief: _Relief = ..., - sashcursor: _Cursor = ..., - sashpad: _ScreenUnits = ..., - sashrelief: _Relief = ..., - sashwidth: _ScreenUnits = ..., - showhandle: bool = ..., - width: _ScreenUnits = ..., + opaqueresize: bool = True, + orient: Literal["horizontal", "vertical"] = "horizontal", + proxybackground: str = "", + proxyborderwidth: _ScreenUnits = "2", + proxyrelief: _Relief = "flat", + relief: _Relief = "flat", + sashcursor: _Cursor = "", + sashpad: _ScreenUnits = 0, + sashrelief: _Relief = "flat", + sashwidth: _ScreenUnits = "3", + showhandle: bool = False, + width: _ScreenUnits = "", ) -> None: ... @overload def configure( From c76442778e0c9373f46221446f969df92e5143ad Mon Sep 17 00:00:00 2001 From: Marcell Perger Date: Fri, 9 Feb 2024 22:29:35 +0000 Subject: [PATCH 07/14] Defaults for Spinbox, Text, Toplevel --- stdlib/tkinter/__init__.pyi | 138 ++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 53b06b4f1f37..e28410ddebb8 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -949,28 +949,28 @@ class Toplevel(BaseWidget, Wm): cnf: dict[str, Any] | None = {}, *, background: str = ..., - bd: _ScreenUnits = ..., + bd: _ScreenUnits = 0, bg: str = ..., border: _ScreenUnits = ..., - borderwidth: _ScreenUnits = ..., - class_: str = ..., - colormap: Literal["new", ""] | Misc = ..., - container: bool = ..., - cursor: _Cursor = ..., - height: _ScreenUnits = ..., + borderwidth: _ScreenUnits = 0, + class_: str = "Toplevel", + colormap: Literal["new", ""] | Misc = "", + container: bool = False, + cursor: _Cursor = "", + height: _ScreenUnits = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = ..., + highlightthickness: _ScreenUnits = 0, menu: Menu = ..., name: str = ..., - padx: _ScreenUnits = ..., - pady: _ScreenUnits = ..., - relief: _Relief = ..., - screen: str = ..., # can't be changed after creating widget - takefocus: _TakeFocusValue = ..., + padx: _ScreenUnits = "0", + pady: _ScreenUnits = "0", + relief: _Relief = "flat", + screen: str = "", # can't be changed after creating widget + takefocus: _TakeFocusValue = "0", use: int = ..., - visual: str | tuple[str, int] = ..., - width: _ScreenUnits = ..., + visual: str | tuple[str, int] = "", + width: _ScreenUnits = 0, ) -> None: ... @overload def configure( @@ -2901,56 +2901,56 @@ class Text(Widget, XView, YView): master: Misc | None = None, cnf: dict[str, Any] | None = {}, *, - autoseparators: bool = ..., + autoseparators: bool = True, background: str = ..., bd: _ScreenUnits = ..., bg: str = ..., - blockcursor: bool = ..., + blockcursor: bool = False, border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., - cursor: _Cursor = ..., - endline: int | Literal[""] = ..., - exportselection: bool = ..., + cursor: _Cursor = "xterm", + endline: int | Literal[""] = "", + exportselection: bool = True, fg: str = ..., - font: _FontDescription = ..., + font: _FontDescription = "TkFixedFont", foreground: str = ..., # width is always int, but height is allowed to be ScreenUnits. # This doesn't make any sense to me, and this isn't documented. # The docs seem to say that both should be integers. - height: _ScreenUnits = ..., + height: _ScreenUnits = 24, highlightbackground: str = ..., highlightcolor: str = ..., highlightthickness: _ScreenUnits = ..., inactiveselectbackground: str = ..., insertbackground: str = ..., - insertborderwidth: _ScreenUnits = ..., - insertofftime: int = ..., - insertontime: int = ..., - insertunfocussed: Literal["none", "hollow", "solid"] = ..., + insertborderwidth: _ScreenUnits = 0, + insertofftime: int = 300, + insertontime: int = 600, + insertunfocussed: Literal["none", "hollow", "solid"] = "none", insertwidth: _ScreenUnits = ..., - maxundo: int = ..., + maxundo: int = 0, name: str = ..., - padx: _ScreenUnits = ..., - pady: _ScreenUnits = ..., + padx: _ScreenUnits = 1, + pady: _ScreenUnits = 1, relief: _Relief = ..., selectbackground: str = ..., selectborderwidth: _ScreenUnits = ..., selectforeground: str = ..., - setgrid: bool = ..., - spacing1: _ScreenUnits = ..., - spacing2: _ScreenUnits = ..., - spacing3: _ScreenUnits = ..., - startline: int | Literal[""] = ..., - state: Literal["normal", "disabled"] = ..., + setgrid: bool = False, + spacing1: _ScreenUnits = 0, + spacing2: _ScreenUnits = 0, + spacing3: _ScreenUnits = 0, + startline: int | Literal[""] = "", + state: Literal["normal", "disabled"] = "normal", # Literal inside Tuple doesn't actually work - tabs: _ScreenUnits | str | tuple[_ScreenUnits | str, ...] = ..., - tabstyle: Literal["tabular", "wordprocessor"] = ..., - takefocus: _TakeFocusValue = ..., - undo: bool = ..., - width: int = ..., - wrap: Literal["none", "char", "word"] = ..., - xscrollcommand: _XYScrollCommand = ..., - yscrollcommand: _XYScrollCommand = ..., + tabs: _ScreenUnits | str | tuple[_ScreenUnits | str, ...] = "", + tabstyle: Literal["tabular", "wordprocessor"] = "tabular", + takefocus: _TakeFocusValue = "", + undo: bool = False, + width: int = 80, + wrap: Literal["none", "char", "word"] = "char", + xscrollcommand: _XYScrollCommand = "", + yscrollcommand: _XYScrollCommand = "", ) -> None: ... @overload def configure( @@ -3371,51 +3371,51 @@ class Spinbox(Widget, XView): border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., buttonbackground: str = ..., - buttoncursor: _Cursor = ..., + buttoncursor: _Cursor = "", buttondownrelief: _Relief = ..., buttonuprelief: _Relief = ..., # percent substitutions don't seem to be supported, it's similar to Entry's validation stuff - command: Callable[[], object] | str | list[str] | tuple[str, ...] = ..., - cursor: _Cursor = ..., + command: Callable[[], object] | str | list[str] | tuple[str, ...] = "", + cursor: _Cursor = "xterm", disabledbackground: str = ..., disabledforeground: str = ..., - exportselection: bool = ..., + exportselection: bool = True, fg: str = ..., - font: _FontDescription = ..., + font: _FontDescription = "TkTextFont", foreground: str = ..., - format: str = ..., - from_: float = ..., + format: str = "", + from_: float = 0.0, highlightbackground: str = ..., highlightcolor: str = ..., highlightthickness: _ScreenUnits = ..., - increment: float = ..., + increment: float = 1.0, insertbackground: str = ..., - insertborderwidth: _ScreenUnits = ..., - insertofftime: int = ..., - insertontime: int = ..., + insertborderwidth: _ScreenUnits = 0, + insertofftime: int = 300, + insertontime: int = 600, insertwidth: _ScreenUnits = ..., - invalidcommand: _EntryValidateCommand = ..., - invcmd: _EntryValidateCommand = ..., - justify: Literal["left", "center", "right"] = ..., + invalidcommand: _EntryValidateCommand = "", + invcmd: _EntryValidateCommand = "", + justify: Literal["left", "center", "right"] = "left", name: str = ..., readonlybackground: str = ..., - relief: _Relief = ..., - repeatdelay: int = ..., - repeatinterval: int = ..., + relief: _Relief = "sunken", + repeatdelay: int = 400, + repeatinterval: int = 100, selectbackground: str = ..., selectborderwidth: _ScreenUnits = ..., selectforeground: str = ..., - state: Literal["normal", "disabled", "readonly"] = ..., - takefocus: _TakeFocusValue = ..., + state: Literal["normal", "disabled", "readonly"] = "normal", + takefocus: _TakeFocusValue = "", textvariable: Variable = ..., - to: float = ..., - validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: _EntryValidateCommand = ..., - vcmd: _EntryValidateCommand = ..., + to: float = 0.0, + validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = "none", + validatecommand: _EntryValidateCommand = "", + vcmd: _EntryValidateCommand = "", values: list[str] | tuple[str, ...] = ..., - width: int = ..., - wrap: bool = ..., - xscrollcommand: _XYScrollCommand = ..., + width: int = 20, + wrap: bool = False, + xscrollcommand: _XYScrollCommand = "", ) -> None: ... @overload def configure( From 8e2d210b6284c2abaafa4d4bdb8a473d611b313d Mon Sep 17 00:00:00 2001 From: Marcell Perger Date: Fri, 9 Feb 2024 22:32:54 +0000 Subject: [PATCH 08/14] Fix `takefocus` defaults Make it an actual `int` it is compatible with the `_TakeFocusValue` type --- stdlib/tkinter/__init__.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index e28410ddebb8..37d86581633b 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -967,7 +967,7 @@ class Toplevel(BaseWidget, Wm): pady: _ScreenUnits = "0", relief: _Relief = "flat", screen: str = "", # can't be changed after creating widget - takefocus: _TakeFocusValue = "0", + takefocus: _TakeFocusValue = 0, use: int = ..., visual: str | tuple[str, int] = "", width: _ScreenUnits = 0, @@ -2048,7 +2048,7 @@ class Label(Widget): pady: _ScreenUnits = "1", relief: _Relief = "flat", state: Literal["normal", "active", "disabled"] = "normal", - takefocus: _TakeFocusValue = "0", + takefocus: _TakeFocusValue = 0, text: float | str = "", textvariable: Variable = ..., underline: int = -1, @@ -2232,7 +2232,7 @@ class Menu(Widget): postcommand: Callable[[], object] | str = "", relief: _Relief = ..., selectcolor: str = ..., - takefocus: _TakeFocusValue = "0", + takefocus: _TakeFocusValue = 0, tearoff: int = ..., # I guess tearoffcommand arguments are supposed to be widget objects, # but they are widget name strings. Use nametowidget() to handle the @@ -2514,7 +2514,7 @@ class Menubutton(Widget): pady: _ScreenUnits = ..., relief: _Relief = "flat", state: Literal["normal", "active", "disabled"] = "normal", - takefocus: _TakeFocusValue = "0", + takefocus: _TakeFocusValue = 0, text: float | str = "", textvariable: Variable = ..., underline: int = -1, @@ -2590,7 +2590,7 @@ class Message(Widget): padx: _ScreenUnits = ..., pady: _ScreenUnits = ..., relief: _Relief = "flat", - takefocus: _TakeFocusValue = "0", + takefocus: _TakeFocusValue = 0, text: float | str = "", textvariable: Variable = ..., # there's width but no height @@ -3526,7 +3526,7 @@ class LabelFrame(Widget): padx: _ScreenUnits = "0", pady: _ScreenUnits = "0", relief: _Relief = "groove", - takefocus: _TakeFocusValue = "0", + takefocus: _TakeFocusValue = 0, text: float | str = "", visual: str | tuple[str, int] = "", # can't be changed with configure() width: _ScreenUnits = 0, From b017ed57712d04a100477d8c1d577054cee433b6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 10 Feb 2024 08:27:57 +0000 Subject: [PATCH 09/14] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/tkinter/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 17f05dea6e67..7e9e1b2073eb 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -2118,7 +2118,7 @@ class Listbox(Widget, XView, YView): highlightbackground: str = ..., highlightcolor: str = ..., highlightthickness: _ScreenUnits = ..., - justify: Literal["left", "center", "right"] ="left", + justify: Literal["left", "center", "right"] = "left", # There's no tkinter.ListVar, but seems like bare tkinter.Variable # actually works for this: # From f8cbe44a2c45d47f4b2b505007ced5dd557a197a Mon Sep 17 00:00:00 2001 From: Marcell Perger Date: Sat, 10 Feb 2024 10:21:44 +0000 Subject: [PATCH 10/14] Use `0` instead of `"0"`, except where the default is consistently `"0"` on all platforms --- stdlib/tkinter/__init__.pyi | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 7e9e1b2073eb..fd9d7049fc08 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -963,8 +963,8 @@ class Toplevel(BaseWidget, Wm): highlightthickness: _ScreenUnits = 0, menu: Menu = ..., name: str = ..., - padx: _ScreenUnits = "0", - pady: _ScreenUnits = "0", + padx: _ScreenUnits = 0, + pady: _ScreenUnits = 0, relief: _Relief = "flat", screen: str = "", # can't be changed after creating widget takefocus: _TakeFocusValue = 0, @@ -1045,7 +1045,7 @@ class Button(Widget): textvariable: Variable = ..., underline: int = -1, width: _ScreenUnits = 0, - wraplength: _ScreenUnits = "0", + wraplength: _ScreenUnits = 0, ) -> None: ... @overload def configure( @@ -1792,7 +1792,7 @@ class Checkbutton(Widget): underline: int = -1, variable: Variable | Literal[""] = "", width: _ScreenUnits = 0, - wraplength: _ScreenUnits = "0", + wraplength: _ScreenUnits = 0, ) -> None: ... @overload def configure( @@ -1984,8 +1984,8 @@ class Frame(Widget): highlightcolor: str = ..., highlightthickness: _ScreenUnits = 0, name: str = ..., - padx: _ScreenUnits = "0", - pady: _ScreenUnits = "0", + padx: _ScreenUnits = 0, + pady: _ScreenUnits = 0, relief: _Relief = "flat", takefocus: _TakeFocusValue = 0, visual: str | tuple[str, int] = "", # can't be changed with configure() @@ -2040,7 +2040,7 @@ class Label(Widget): height: _ScreenUnits = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = "0", + highlightthickness: _ScreenUnits = 0, image: _ImageSpec = "", justify: Literal["left", "center", "right"] = "center", name: str = ..., @@ -2053,7 +2053,7 @@ class Label(Widget): textvariable: Variable = ..., underline: int = -1, width: _ScreenUnits = 0, - wraplength: _ScreenUnits = "0", + wraplength: _ScreenUnits = 0, ) -> None: ... @overload def configure( @@ -2675,7 +2675,7 @@ class Radiobutton(Widget): value: Any = "", variable: Variable | Literal[""] = ..., width: _ScreenUnits = 0, - wraplength: _ScreenUnits = "0", + wraplength: _ScreenUnits = 0, ) -> None: ... @overload def configure( @@ -3523,8 +3523,8 @@ class LabelFrame(Widget): labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = "nw", labelwidget: Misc = ..., name: str = ..., - padx: _ScreenUnits = "0", - pady: _ScreenUnits = "0", + padx: _ScreenUnits = 0, + pady: _ScreenUnits = 0, relief: _Relief = "groove", takefocus: _TakeFocusValue = 0, text: float | str = "", From 0ec7559c0186e35f0abbb60164ca186997a011dc Mon Sep 17 00:00:00 2001 From: Marcell Perger Date: Sat, 10 Feb 2024 10:45:45 +0000 Subject: [PATCH 11/14] Replace `""` with `` where it isn't consistently in 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) --- stdlib/tkinter/__init__.pyi | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index fd9d7049fc08..7b9e570a2b61 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1026,7 +1026,7 @@ class Button(Widget): height: _ScreenUnits = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = "1", + highlightthickness: _ScreenUnits = 1, image: _ImageSpec = "", justify: Literal["left", "center", "right"] = "center", name: str = ..., @@ -1759,7 +1759,7 @@ class Checkbutton(Widget): height: _ScreenUnits = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = "1", + highlightthickness: _ScreenUnits = 1, image: _ImageSpec = "", indicatoron: bool = True, justify: Literal["left", "center", "right"] = "center", @@ -1778,8 +1778,8 @@ class Checkbutton(Widget): offvalue: Any = "0", onvalue: Any = "1", overrelief: _Relief | Literal[""] = "", - padx: _ScreenUnits = "1", - pady: _ScreenUnits = "1", + padx: _ScreenUnits = 1, + pady: _ScreenUnits = 1, relief: _Relief = "flat", selectcolor: str = ..., selectimage: _ImageSpec = "", @@ -2044,8 +2044,8 @@ class Label(Widget): image: _ImageSpec = "", justify: Literal["left", "center", "right"] = "center", name: str = ..., - padx: _ScreenUnits = "1", - pady: _ScreenUnits = "1", + padx: _ScreenUnits = 1, + pady: _ScreenUnits = 1, relief: _Relief = "flat", state: Literal["normal", "active", "disabled"] = "normal", takefocus: _TakeFocusValue = 0, @@ -2653,15 +2653,15 @@ class Radiobutton(Widget): height: _ScreenUnits = 0, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = "1", + highlightthickness: _ScreenUnits = 1, image: _ImageSpec = "", indicatoron: bool = True, justify: Literal["left", "center", "right"] = "center", name: str = ..., offrelief: _Relief = ..., overrelief: _Relief | Literal[""] = "", - padx: _ScreenUnits = "1", - pady: _ScreenUnits = "1", + padx: _ScreenUnits = 1, + pady: _ScreenUnits = 1, relief: _Relief = "flat", selectcolor: str = ..., selectimage: _ImageSpec = "", @@ -2740,7 +2740,7 @@ class Scale(Widget): *, activebackground: str = ..., background: str = ..., - bd: _ScreenUnits = "1", + bd: _ScreenUnits = 1, bg: str = ..., bigincrement: float = 0.0, border: _ScreenUnits = ..., @@ -3575,19 +3575,19 @@ class PanedWindow(Widget): borderwidth: _ScreenUnits = 1, cursor: _Cursor = "", handlepad: _ScreenUnits = 8, - handlesize: _ScreenUnits = "8", + handlesize: _ScreenUnits = 8, height: _ScreenUnits = "", name: str = ..., opaqueresize: bool = True, orient: Literal["horizontal", "vertical"] = "horizontal", proxybackground: str = "", - proxyborderwidth: _ScreenUnits = "2", + proxyborderwidth: _ScreenUnits = 2, proxyrelief: _Relief = "flat", relief: _Relief = "flat", sashcursor: _Cursor = "", sashpad: _ScreenUnits = 0, sashrelief: _Relief = "flat", - sashwidth: _ScreenUnits = "3", + sashwidth: _ScreenUnits = 3, showhandle: bool = False, width: _ScreenUnits = "", ) -> None: ... From 86a7120ed4aed76353362672b3bfff960fe68637 Mon Sep 17 00:00:00 2001 From: Marcell Perger Date: Sat, 10 Feb 2024 11:17:50 +0000 Subject: [PATCH 12/14] Replace integer-in-strings with integers --- stdlib/tkinter/__init__.pyi | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 7b9e570a2b61..6901e936db34 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1102,10 +1102,10 @@ class Canvas(Widget, XView, YView): cnf: dict[str, Any] | None = {}, *, background: str = ..., - bd: _ScreenUnits = "0", + bd: _ScreenUnits = 0, bg: str = ..., border: _ScreenUnits = ..., - borderwidth: _ScreenUnits = "0", + borderwidth: _ScreenUnits = 0, closeenough: float = 1.0, confine: bool = True, cursor: _Cursor = "", @@ -1116,10 +1116,10 @@ class Canvas(Widget, XView, YView): highlightcolor: str = ..., highlightthickness: _ScreenUnits = ..., insertbackground: str = ..., - insertborderwidth: _ScreenUnits = "0", + insertborderwidth: _ScreenUnits = 0, insertofftime: int = 300, insertontime: int = 600, - insertwidth: _ScreenUnits = "2", + insertwidth: _ScreenUnits = 2, name: str = ..., offset=..., # undocumented relief: _Relief = "flat", @@ -1127,16 +1127,16 @@ class Canvas(Widget, XView, YView): # but setting it to () does. scrollregion: tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits] | tuple[()] = (), selectbackground: str = ..., - selectborderwidth: _ScreenUnits = "1", + selectborderwidth: _ScreenUnits = 1, selectforeground: str = ..., # man page says that state can be 'hidden', but it can't state: Literal["normal", "disabled"] = "normal", takefocus: _TakeFocusValue = "", width: _ScreenUnits = ..., xscrollcommand: _XYScrollCommand = "", - xscrollincrement: _ScreenUnits = "0", + xscrollincrement: _ScreenUnits = 0, yscrollcommand: _XYScrollCommand = "", - yscrollincrement: _ScreenUnits = "0", + yscrollincrement: _ScreenUnits = 0, ) -> None: ... @overload def configure( @@ -1775,8 +1775,8 @@ class Checkbutton(Widget): # and list[int] are incompatible. Also, we would need a way to # specify "Checkbutton not associated with any variable", which is # done by setting variable to empty string (the default). - offvalue: Any = "0", - onvalue: Any = "1", + offvalue: Any = 0, + onvalue: Any = 1, overrelief: _Relief | Literal[""] = "", padx: _ScreenUnits = 1, pady: _ScreenUnits = 1, @@ -2501,7 +2501,7 @@ class Menubutton(Widget): fg: str = ..., font: _FontDescription = "TkDefaultFont", foreground: str = ..., - height: _ScreenUnits = "0", + height: _ScreenUnits = 0, highlightbackground: str = ..., highlightcolor: str = ..., highlightthickness: _ScreenUnits = 0, @@ -2518,7 +2518,7 @@ class Menubutton(Widget): text: float | str = "", textvariable: Variable = ..., underline: int = -1, - width: _ScreenUnits = "0", + width: _ScreenUnits = 0, wraplength: _ScreenUnits = 0, ) -> None: ... @overload @@ -2842,10 +2842,10 @@ class Scrollbar(Widget): # that it can take any args while it can't in reality. command: Callable[..., tuple[float, float] | None] | str = "", cursor: _Cursor = "", - elementborderwidth: _ScreenUnits = "-1", + elementborderwidth: _ScreenUnits = -1, highlightbackground: str = ..., highlightcolor: str = ..., - highlightthickness: _ScreenUnits = "0", + highlightthickness: _ScreenUnits = 0, jump: bool = False, name: str = ..., orient: Literal["horizontal", "vertical"] = "vertical", From e08fb1264c14cde9eaee095eac129d1d842c2a78 Mon Sep 17 00:00:00 2001 From: Marcell Perger Date: Sat, 10 Feb 2024 17:43:30 +0000 Subject: [PATCH 13/14] Fix type of `variable` --- stdlib/tkinter/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 6901e936db34..1c5c57be8c43 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1790,7 +1790,7 @@ class Checkbutton(Widget): tristateimage: _ImageSpec = "", tristatevalue: Any = "", underline: int = -1, - variable: Variable | Literal[""] = "", + variable: Variable | Literal[""] = ..., width: _ScreenUnits = 0, wraplength: _ScreenUnits = 0, ) -> None: ... From 0bb7d06c8376b0e8614a02e553a0accfce93fb93 Mon Sep 17 00:00:00 2001 From: Marcell Perger Date: Sat, 10 Feb 2024 17:47:18 +0000 Subject: [PATCH 14/14] Add defaults for `border` argument --- stdlib/tkinter/__init__.pyi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 1c5c57be8c43..ea852f00e7f9 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -951,7 +951,7 @@ class Toplevel(BaseWidget, Wm): background: str = ..., bd: _ScreenUnits = 0, bg: str = ..., - border: _ScreenUnits = ..., + border: _ScreenUnits = 0, borderwidth: _ScreenUnits = 0, class_: str = "Toplevel", colormap: Literal["new", ""] | Misc = "", @@ -1104,7 +1104,7 @@ class Canvas(Widget, XView, YView): background: str = ..., bd: _ScreenUnits = 0, bg: str = ..., - border: _ScreenUnits = ..., + border: _ScreenUnits = 0, borderwidth: _ScreenUnits = 0, closeenough: float = 1.0, confine: bool = True, @@ -1973,7 +1973,7 @@ class Frame(Widget): background: str = ..., bd: _ScreenUnits = 0, bg: str = ..., - border: _ScreenUnits = ..., + border: _ScreenUnits = 0, borderwidth: _ScreenUnits = 0, class_: str = "Frame", # can't be changed with configure() colormap: Literal["new", ""] | Misc = "", # can't be changed with configure() @@ -2106,7 +2106,7 @@ class Listbox(Widget, XView, YView): background: str = ..., bd: _ScreenUnits = 1, bg: str = ..., - border: _ScreenUnits = ..., + border: _ScreenUnits = 1, borderwidth: _ScreenUnits = 1, cursor: _Cursor = "", disabledforeground: str = ..., @@ -2576,7 +2576,7 @@ class Message(Widget): background: str = ..., bd: _ScreenUnits = 1, bg: str = ..., - border: _ScreenUnits = ..., + border: _ScreenUnits = 1, borderwidth: _ScreenUnits = 1, cursor: _Cursor = "", fg: str = ..., @@ -2743,7 +2743,7 @@ class Scale(Widget): bd: _ScreenUnits = 1, bg: str = ..., bigincrement: float = 0.0, - border: _ScreenUnits = ..., + border: _ScreenUnits = 1, borderwidth: _ScreenUnits = 1, # don't know why the callback gets string instead of float command: str | Callable[[str], object] = "", @@ -3506,7 +3506,7 @@ class LabelFrame(Widget): background: str = ..., bd: _ScreenUnits = 2, bg: str = ..., - border: _ScreenUnits = ..., + border: _ScreenUnits = 2, borderwidth: _ScreenUnits = 2, class_: str = "Labelframe", # can't be changed with configure() colormap: Literal["new", ""] | Misc = "", # can't be changed with configure() @@ -3571,7 +3571,7 @@ class PanedWindow(Widget): background: str = ..., bd: _ScreenUnits = 1, bg: str = ..., - border: _ScreenUnits = ..., + border: _ScreenUnits = 1, borderwidth: _ScreenUnits = 1, cursor: _Cursor = "", handlepad: _ScreenUnits = 8,