|
1 | | -from tkinter import Button, Entry, Frame, Listbox, Scrollbar, Toplevel, commondialog |
2 | | -from typing import Any, ClassVar, Dict, Optional, Tuple |
| 1 | +from _typeshed import StrOrBytesPath |
| 2 | +from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, _TkinterSequence, commondialog |
| 3 | +from typing import IO, Any, ClassVar, Dict, Iterable, Optional, Tuple |
| 4 | +from typing_extensions import Literal |
3 | 5 |
|
4 | 6 | dialogstates: Dict[Any, Tuple[Any, Any]] |
5 | 7 |
|
@@ -57,11 +59,75 @@ class SaveAs(_Dialog): |
57 | 59 | class Directory(commondialog.Dialog): |
58 | 60 | command: ClassVar[str] = ... |
59 | 61 |
|
60 | | -def askopenfilename(**options): ... |
61 | | -def asksaveasfilename(**options): ... |
62 | | -def askopenfilenames(**options): ... |
63 | | -def askopenfile(mode: str = ..., **options): ... |
64 | | -def askopenfiles(mode: str = ..., **options): ... |
65 | | -def asksaveasfile(mode: str = ..., **options): ... |
66 | | -def askdirectory(**options): ... |
| 62 | +# TODO: command kwarg available on macos |
| 63 | +def asksaveasfilename( |
| 64 | + *, |
| 65 | + confirmoverwrite: bool | None = ..., |
| 66 | + defaultextension: str | None = ..., |
| 67 | + filetypes: Iterable[Tuple[str, str] | Tuple[str, _TkinterSequence[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 |
| 74 | +def askopenfilename( |
| 75 | + *, |
| 76 | + defaultextension: str | None = ..., |
| 77 | + filetypes: Iterable[Tuple[str, str] | Tuple[str, _TkinterSequence[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 |
| 84 | +def askopenfilenames( |
| 85 | + *, |
| 86 | + defaultextension: str | None = ..., |
| 87 | + filetypes: Iterable[Tuple[str, str] | Tuple[str, _TkinterSequence[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, ...]: ... |
| 94 | +def askdirectory( |
| 95 | + *, initialdir: StrOrBytesPath | None = ..., mustexist: bool | None = ..., parent: Misc | None = ..., title: str | None = ... |
| 96 | +) -> str: ... # can be empty string |
| 97 | + |
| 98 | +# TODO: If someone actually uses these, overload to have the actual return type of open(..., mode) |
| 99 | +def asksaveasfile( |
| 100 | + mode: str = ..., |
| 101 | + *, |
| 102 | + confirmoverwrite: bool | None = ..., |
| 103 | + defaultextension: str | None = ..., |
| 104 | + filetypes: Iterable[Tuple[str, str] | Tuple[str, _TkinterSequence[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: ... |
| 111 | +def askopenfile( |
| 112 | + mode: str = ..., |
| 113 | + *, |
| 114 | + defaultextension: str | None = ..., |
| 115 | + filetypes: Iterable[Tuple[str, str] | Tuple[str, _TkinterSequence[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: ... |
| 122 | +def askopenfiles( |
| 123 | + mode: str = ..., |
| 124 | + *, |
| 125 | + defaultextension: str | None = ..., |
| 126 | + filetypes: Iterable[Tuple[str, str] | Tuple[str, _TkinterSequence[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 |
67 | 133 | def test() -> None: ... |
0 commit comments