1 from _typeshed import StrOrBytesPath
2 from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, commondialog
3 from typing import IO, Any, ClassVar, Iterable, Tuple
4 from typing_extensions import Literal
6 dialogstates: dict[Any, tuple[Any, Any]]
25 self, master, title: Any | None = ...
26 ) -> None: ... # title is usually a str or None, but e.g. int doesn't raise en exception either
28 def go(self, dir_or_file: Any = ..., pattern: str = ..., default: str = ..., key: Any | None = ...): ...
29 def quit(self, how: Any | None = ...) -> None: ...
30 def dirs_double_event(self, event) -> None: ...
31 def dirs_select_event(self, event) -> None: ...
32 def files_double_event(self, event) -> None: ...
33 def files_select_event(self, event) -> None: ...
34 def ok_event(self, event) -> None: ...
35 def ok_command(self) -> None: ...
36 def filter_command(self, event: Any | None = ...) -> None: ...
37 def get_filter(self): ...
38 def get_selection(self): ...
39 def cancel_command(self, event: Any | None = ...) -> None: ...
40 def set_filter(self, dir, pat) -> None: ...
41 def set_selection(self, file) -> None: ...
43 class LoadFileDialog(FileDialog):
45 def ok_command(self) -> None: ...
47 class SaveFileDialog(FileDialog):
49 def ok_command(self): ...
51 class _Dialog(commondialog.Dialog): ...
54 command: ClassVar[str]
56 class SaveAs(_Dialog):
57 command: ClassVar[str]
59 class Directory(commondialog.Dialog):
60 command: ClassVar[str]
62 # TODO: command kwarg available on macos
63 def asksaveasfilename(
65 confirmoverwrite: bool | None = ...,
66 defaultextension: str | None = ...,
67 filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ...,
68 initialdir: StrOrBytesPath | None = ...,
69 initialfile: StrOrBytesPath | None = ...,
70 parent: Misc | None = ...,
71 title: str | None = ...,
72 typevariable: StringVar | str | None = ...,
73 ) -> str: ... # can be empty string
76 defaultextension: str | None = ...,
77 filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ...,
78 initialdir: StrOrBytesPath | None = ...,
79 initialfile: StrOrBytesPath | None = ...,
80 parent: Misc | None = ...,
81 title: str | None = ...,
82 typevariable: StringVar | str | None = ...,
83 ) -> str: ... # can be empty string
86 defaultextension: str | None = ...,
87 filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ...,
88 initialdir: StrOrBytesPath | None = ...,
89 initialfile: StrOrBytesPath | None = ...,
90 parent: Misc | None = ...,
91 title: str | None = ...,
92 typevariable: StringVar | str | None = ...,
93 ) -> Literal[""] | Tuple[str, ...]: ...
95 *, initialdir: StrOrBytesPath | None = ..., mustexist: bool | None = ..., parent: Misc | None = ..., title: str | None = ...
96 ) -> str: ... # can be empty string
98 # TODO: If someone actually uses these, overload to have the actual return type of open(..., mode)
102 confirmoverwrite: bool | None = ...,
103 defaultextension: str | None = ...,
104 filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ...,
105 initialdir: StrOrBytesPath | None = ...,
106 initialfile: StrOrBytesPath | None = ...,
107 parent: Misc | None = ...,
108 title: str | None = ...,
109 typevariable: StringVar | str | None = ...,
110 ) -> IO[Any] | None: ...
114 defaultextension: str | None = ...,
115 filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ...,
116 initialdir: StrOrBytesPath | None = ...,
117 initialfile: StrOrBytesPath | None = ...,
118 parent: Misc | None = ...,
119 title: str | None = ...,
120 typevariable: StringVar | str | None = ...,
121 ) -> IO[Any] | None: ...
125 defaultextension: str | None = ...,
126 filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ...,
127 initialdir: StrOrBytesPath | None = ...,
128 initialfile: StrOrBytesPath | None = ...,
129 parent: Misc | None = ...,
130 title: str | None = ...,
131 typevariable: StringVar | str | None = ...,
132 ) -> Tuple[IO[Any], ...]: ... # can be empty tuple
133 def test() -> None: ...