Skip to content

Commit 29c17ff

Browse files
authored
Improve tkinter.simpledialog (#8243)
1 parent 4e4de7f commit 29c17ff

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

stdlib/tkinter/simpledialog.pyi

+33-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
from tkinter import Event, Misc, Toplevel
2-
from typing import Any
1+
from tkinter import Event, Frame, Misc, Toplevel
32

43
class Dialog(Toplevel):
54
def __init__(self, parent: Misc | None, title: str | None = ...) -> None: ...
6-
def body(self, master) -> None: ...
5+
def body(self, master: Frame) -> Misc | None: ...
76
def buttonbox(self) -> None: ...
7+
def ok(self, event: Event[Misc] | None = ...) -> None: ...
8+
def cancel(self, event: Event[Misc] | None = ...) -> None: ...
9+
def validate(self) -> bool: ...
10+
def apply(self) -> None: ...
811

912
class SimpleDialog:
1013
def __init__(
@@ -22,6 +25,30 @@ class SimpleDialog:
2225
def wm_delete_window(self) -> None: ...
2326
def done(self, num: int) -> None: ...
2427

25-
def askfloat(title: str | None, prompt: str, **kwargs: Any) -> float | None: ...
26-
def askinteger(title: str | None, prompt: str, **kwargs: Any) -> int | None: ...
27-
def askstring(title: str | None, prompt: str, **kwargs: Any) -> str | None: ...
28+
def askfloat(
29+
title: str | None,
30+
prompt: str,
31+
*,
32+
initialvalue: float | None = ...,
33+
minvalue: float | None = ...,
34+
maxvalue: float | None = ...,
35+
parent: Misc | None = ...,
36+
) -> float | None: ...
37+
def askinteger(
38+
title: str | None,
39+
prompt: str,
40+
*,
41+
initialvalue: int | None = ...,
42+
minvalue: int | None = ...,
43+
maxvalue: int | None = ...,
44+
parent: Misc | None = ...,
45+
) -> int | None: ...
46+
def askstring(
47+
title: str | None,
48+
prompt: str,
49+
*,
50+
initialvalue: str | None = ...,
51+
show: str | None = ...,
52+
# minvalue/maxvalue is accepted but not useful.
53+
parent: Misc | None = ...,
54+
) -> str | None: ...

tests/stubtest_allowlists/py3_common.txt

-4
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,6 @@ multiprocessing.synchronize.Semaphore.get_value
284284
socket.CAPI
285285
tkinter.Misc.config
286286
tkinter.font.Font.counter
287-
tkinter.simpledialog.Dialog.apply
288-
tkinter.simpledialog.Dialog.cancel
289-
tkinter.simpledialog.Dialog.ok
290-
tkinter.simpledialog.Dialog.validate
291287
tkinter.tix.CObjView
292288
tkinter.tix.DialogShell
293289
tkinter.tix.ExFileSelectDialog

0 commit comments

Comments
 (0)