CTKFileDialog-plus 1.0.0__tar.gz → 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of CTKFileDialog-plus might be problematic. Click here for more details.
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTKFileDialog_plus.egg-info/PKG-INFO +68 -14
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTKFileDialog_plus.egg-info/SOURCES.txt +17 -1
- ctkfiledialog_plus-2.0.0/CTkFileDialog/Dialog.py +25 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/_functions.py +521 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/_system.py +5 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/core/__init__.py +13 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/core/filesystem.py +97 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/core/search.py +13 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/core/sorting.py +41 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/preview/__init__.py +4 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/preview/media.py +126 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/resources/__init__.py +14 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/resources/icons.py +89 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/system/__init__.py +4 -0
- ctkfiledialog_plus-1.0.0/CTkFileDialog/_system.py → ctkfiledialog_plus-2.0.0/CTkFileDialog/system/platform.py +26 -8
- ctkfiledialog_plus-2.0.0/CTkFileDialog/ui/__init__.py +5 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/ui/default_dialog.py +1013 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/ui/mini_dialog.py +454 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/ui/tooltip.py +25 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/utils/__init__.py +9 -0
- ctkfiledialog_plus-2.0.0/CTkFileDialog/utils/helpers.py +61 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/PKG-INFO +68 -14
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/README.md +67 -13
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/pyproject.toml +1 -1
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/setup.py +1 -1
- ctkfiledialog_plus-1.0.0/CTkFileDialog/Dialog.py +0 -1535
- ctkfiledialog_plus-1.0.0/CTkFileDialog/_functions.py +0 -634
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTKFileDialog_plus.egg-info/dependency_links.txt +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTKFileDialog_plus.egg-info/requires.txt +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTKFileDialog_plus.egg-info/top_level.txt +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/Constants/__init__.py +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/Constants/constants.py +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/__init__.py +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/_IconsMini/file.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/_IconsMini/folder.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/bash.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/conf.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/css.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/exe.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/folder.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/gz.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/html.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/image.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/ini.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/javascript.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/js.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/json.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/markdown.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/odt.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/pdf.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/php.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/python.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/text.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTkFileDialog/icons/video.png +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/LICENSE +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/MANIFEST.in +0 -0
- {ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: CTKFileDialog-plus
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: A modern file dialog for CustomTkinter
|
|
5
5
|
Home-page: https://github.com/hmidani-abdelilah/CTkFileDialog-plus
|
|
6
6
|
Author: abdelilah
|
|
@@ -49,25 +49,23 @@ Dynamic: requires-python
|
|
|
49
49
|
## 📦 Installation
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
|
-
|
|
53
|
-
# Using bash
|
|
52
|
+
# Using bash
|
|
54
53
|
git clone https://github.com/hmidani-abdelilah/CTkFileDialog-plus
|
|
55
54
|
cd CTkFileDialog-plus
|
|
56
55
|
python3 -m venv .venv
|
|
57
56
|
source .venv/bin/activate
|
|
58
57
|
pip3 install -r requirements.txt
|
|
59
58
|
|
|
60
|
-
# On Windows
|
|
61
|
-
git clone https://github.com/hmidani-abdelilah/CTkFileDialog-plus
|
|
59
|
+
# On Windows
|
|
60
|
+
git clone https://github.com/hmidani-abdelilah/CTkFileDialog-plus
|
|
62
61
|
cd CTkFileDialog-plus
|
|
63
|
-
python3 -m venv .venv
|
|
64
|
-
.\.venv\Scripts\activate.ps1
|
|
65
|
-
pip3 install -r requirements.txt
|
|
66
|
-
|
|
67
|
-
# Or ussing pip
|
|
62
|
+
python3 -m venv .venv
|
|
63
|
+
.\.venv\Scripts\activate.ps1 # In PowerShell
|
|
64
|
+
pip3 install -r requirements.txt
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
# Or using pip
|
|
67
|
+
python3 -m venv .venv
|
|
68
|
+
source .venv/bin/activate # On PowerShell use .\.venv\Scripts\activate.ps1
|
|
71
69
|
pip3 install CTkFileDialog-plus
|
|
72
70
|
|
|
73
71
|
```
|
|
@@ -77,6 +75,57 @@ pip3 install CTkFileDialog-plus
|
|
|
77
75
|
|
|
78
76
|
---
|
|
79
77
|
|
|
78
|
+
## 📁 Project structure
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
CTkFileDialog-plus/
|
|
82
|
+
├── LICENSE # project license terms
|
|
83
|
+
├── README.md # user and developer documentation
|
|
84
|
+
├── requirements.txt # Python dependencies
|
|
85
|
+
├── test.py # general package usage example
|
|
86
|
+
├── test_save_as.py # save-as dialog regression/test example
|
|
87
|
+
├── CTkFileDialog/ # package source code
|
|
88
|
+
│ ├── __init__.py # public package API
|
|
89
|
+
│ ├── _functions.py # dialog helper functions exposed to users
|
|
90
|
+
│ ├── _system.py # cross-platform path handling support
|
|
91
|
+
│ ├── Dialog.py # dialog imports and public component exports
|
|
92
|
+
│ ├── Constants/ # reusable package constants
|
|
93
|
+
│ │ ├── __init__.py
|
|
94
|
+
│ │ └── constants.py
|
|
95
|
+
│ ├── core/ # core filesystem/search/sorting logic
|
|
96
|
+
│ │ ├── __init__.py
|
|
97
|
+
│ │ ├── filesystem.py
|
|
98
|
+
│ │ ├── search.py
|
|
99
|
+
│ │ └── sorting.py
|
|
100
|
+
│ ├── icons/ # icon assets for the dialogs
|
|
101
|
+
│ │ ├── _IconsMini/
|
|
102
|
+
│ │ └── *.png
|
|
103
|
+
│ ├── preview/ # image/video preview helpers
|
|
104
|
+
│ │ ├── __init__.py
|
|
105
|
+
│ │ └── media.py
|
|
106
|
+
│ ├── resources/ # shared resource loading utilities
|
|
107
|
+
│ │ ├── __init__.py
|
|
108
|
+
│ │ └── icons.py
|
|
109
|
+
│ ├── system/ # platform-specific system utilities
|
|
110
|
+
│ │ ├── __init__.py
|
|
111
|
+
│ │ └── platform.py
|
|
112
|
+
│ ├── ui/ # dialog UI implementations and widgets
|
|
113
|
+
│ │ ├── __init__.py
|
|
114
|
+
│ │ ├── default_dialog.py
|
|
115
|
+
│ │ ├── mini_dialog.py
|
|
116
|
+
│ │ └── tooltip.py
|
|
117
|
+
│ └── utils/ # small helper utilities
|
|
118
|
+
│ ├── __init__.py
|
|
119
|
+
│ └── helpers.py
|
|
120
|
+
├── Images/ # README screenshots showing light and dark themes
|
|
121
|
+
│ ├── MiniDialogDark.png
|
|
122
|
+
│ ├── MiniDialogLight.png
|
|
123
|
+
│ ├── NormalDialogDark.png
|
|
124
|
+
│ └── NormalDialogLight.png
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
80
129
|
## 🧪 Demo — All Methods
|
|
81
130
|
|
|
82
131
|
### 🗂️ Open File
|
|
@@ -327,6 +376,11 @@ def save_as_file():
|
|
|
327
376
|
file.close()
|
|
328
377
|
result_label.configure(text=f"File saved:\n{file.name}")
|
|
329
378
|
|
|
379
|
+
# Alternatively, asksaveasfile supports the context manager protocol:
|
|
380
|
+
# with asksaveasfile(autocomplete=True) as file:
|
|
381
|
+
# if file:
|
|
382
|
+
# file.write("This file was created using the demo.")
|
|
383
|
+
|
|
330
384
|
app = ctk.CTk()
|
|
331
385
|
app.title("asksaveasfile Demo")
|
|
332
386
|
app.geometry("500x200")
|
|
@@ -417,8 +471,8 @@ app.mainloop()
|
|
|
417
471
|
| `foldercreation`| Enable a "New Folder" button so the user can create folders from within the dialog (`True` by default). |
|
|
418
472
|
| `defaultext` | *(`asksaveasfilename`/`asksaveasfile` only)* Extension appended to the filename if the user didn't type one (default is none). |
|
|
419
473
|
| `style` | Defines the dialog style, by default it will be 'Default' but you can choose a small one ('Mini'). |
|
|
420
|
-
| `geometry` |
|
|
421
|
-
| `title` | Define the title
|
|
474
|
+
| `geometry` | Defines the dialog size. For functions that support both styles, pass a tuple `(default_geometry, mini_geometry)`. |
|
|
475
|
+
| `title` | Define the title for the dialog window. Defaults to `CTkFileDialog`. |
|
|
422
476
|
|
|
423
477
|
|
|
424
478
|
</div>
|
{ctkfiledialog_plus-1.0.0 → ctkfiledialog_plus-2.0.0}/CTKFileDialog_plus.egg-info/SOURCES.txt
RENAMED
|
@@ -14,6 +14,10 @@ CTkFileDialog/_functions.py
|
|
|
14
14
|
CTkFileDialog/_system.py
|
|
15
15
|
CTkFileDialog/Constants/__init__.py
|
|
16
16
|
CTkFileDialog/Constants/constants.py
|
|
17
|
+
CTkFileDialog/core/__init__.py
|
|
18
|
+
CTkFileDialog/core/filesystem.py
|
|
19
|
+
CTkFileDialog/core/search.py
|
|
20
|
+
CTkFileDialog/core/sorting.py
|
|
17
21
|
CTkFileDialog/icons/bash.png
|
|
18
22
|
CTkFileDialog/icons/conf.png
|
|
19
23
|
CTkFileDialog/icons/css.png
|
|
@@ -34,4 +38,16 @@ CTkFileDialog/icons/python.png
|
|
|
34
38
|
CTkFileDialog/icons/text.png
|
|
35
39
|
CTkFileDialog/icons/video.png
|
|
36
40
|
CTkFileDialog/icons/_IconsMini/file.png
|
|
37
|
-
CTkFileDialog/icons/_IconsMini/folder.png
|
|
41
|
+
CTkFileDialog/icons/_IconsMini/folder.png
|
|
42
|
+
CTkFileDialog/preview/__init__.py
|
|
43
|
+
CTkFileDialog/preview/media.py
|
|
44
|
+
CTkFileDialog/resources/__init__.py
|
|
45
|
+
CTkFileDialog/resources/icons.py
|
|
46
|
+
CTkFileDialog/system/__init__.py
|
|
47
|
+
CTkFileDialog/system/platform.py
|
|
48
|
+
CTkFileDialog/ui/__init__.py
|
|
49
|
+
CTkFileDialog/ui/default_dialog.py
|
|
50
|
+
CTkFileDialog/ui/mini_dialog.py
|
|
51
|
+
CTkFileDialog/ui/tooltip.py
|
|
52
|
+
CTkFileDialog/utils/__init__.py
|
|
53
|
+
CTkFileDialog/utils/helpers.py
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
"""Backward-compatibility shim.
|
|
3
|
+
|
|
4
|
+
Historically all dialog classes lived in this module. They have been
|
|
5
|
+
moved to ``CTkFileDialog.ui``. This file re-exports the public names so
|
|
6
|
+
any external ``from CTkFileDialog.Dialog import _DrawApp`` continues to
|
|
7
|
+
work.
|
|
8
|
+
"""
|
|
9
|
+
from .ui.default_dialog import DrawApp, _DrawApp
|
|
10
|
+
from .ui.mini_dialog import MiniDialog, _MiniDialog
|
|
11
|
+
from .ui.tooltip import CustomToolTip
|
|
12
|
+
from .system.platform import System as _System
|
|
13
|
+
|
|
14
|
+
# Historical private name
|
|
15
|
+
_CustomToolTip = CustomToolTip
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"DrawApp",
|
|
19
|
+
"_DrawApp",
|
|
20
|
+
"MiniDialog",
|
|
21
|
+
"_MiniDialog",
|
|
22
|
+
"CustomToolTip",
|
|
23
|
+
"_CustomToolTip",
|
|
24
|
+
"_System",
|
|
25
|
+
]
|
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
"""Public dialog functions — API surface is unchanged."""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import List, Literal, Optional, TextIO, Tuple, Union
|
|
6
|
+
|
|
7
|
+
from typeguard import typechecked
|
|
8
|
+
|
|
9
|
+
from .ui.default_dialog import _DrawApp
|
|
10
|
+
from .ui.mini_dialog import _MiniDialog
|
|
11
|
+
from .utils.helpers import apply_defaultext, normalize_filetypes
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Re-export helpers under historical private names for any external use
|
|
15
|
+
_normalize_filetypes = normalize_filetypes
|
|
16
|
+
_apply_defaultext = apply_defaultext
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@typechecked
|
|
20
|
+
def askopenfilename(
|
|
21
|
+
style: Literal["Mini", "Default"] = "Default",
|
|
22
|
+
filetypes: Optional[List[Union[str, Tuple[str, str]]]] = None,
|
|
23
|
+
hidden: bool = False,
|
|
24
|
+
preview_img: bool = False,
|
|
25
|
+
autocomplete: bool = False,
|
|
26
|
+
video_preview: bool = False,
|
|
27
|
+
initial_dir: str = ".",
|
|
28
|
+
tool_tip: bool = False,
|
|
29
|
+
foldercreation: bool = True,
|
|
30
|
+
geometry: Tuple[str, str] = ("1320x720", "500x400"),
|
|
31
|
+
title: str = "CTkFileDialog",
|
|
32
|
+
) -> str | None:
|
|
33
|
+
"""
|
|
34
|
+
Displays a file dialog for selecting a single file and returns the file path.
|
|
35
|
+
"""
|
|
36
|
+
normalized = normalize_filetypes(filetypes)
|
|
37
|
+
if style == "Default":
|
|
38
|
+
app = _DrawApp(
|
|
39
|
+
filetypes=normalized,
|
|
40
|
+
current_path=initial_dir,
|
|
41
|
+
hidden=hidden,
|
|
42
|
+
preview_img=preview_img,
|
|
43
|
+
method="askopenfilename",
|
|
44
|
+
autocomplete=autocomplete,
|
|
45
|
+
video_preview=video_preview,
|
|
46
|
+
tool_tip=tool_tip,
|
|
47
|
+
foldercreation=foldercreation,
|
|
48
|
+
geometry=geometry[0],
|
|
49
|
+
title=title,
|
|
50
|
+
)
|
|
51
|
+
app.app.wait_window()
|
|
52
|
+
return app.selected_file if app.selected_file else None
|
|
53
|
+
elif style == "Mini":
|
|
54
|
+
app = _MiniDialog(
|
|
55
|
+
method="askopenfilename",
|
|
56
|
+
filetypes=normalized,
|
|
57
|
+
initial_dir=initial_dir,
|
|
58
|
+
autocomplete=autocomplete,
|
|
59
|
+
hidden=hidden,
|
|
60
|
+
foldercreation=foldercreation,
|
|
61
|
+
geometry=geometry[1],
|
|
62
|
+
title=title,
|
|
63
|
+
)
|
|
64
|
+
return app.selected_path
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@typechecked
|
|
68
|
+
def askdirectory(
|
|
69
|
+
style: Literal["Default", "Mini"] = "Default",
|
|
70
|
+
filetypes: Optional[List[Union[str, Tuple[str, str]]]] = None,
|
|
71
|
+
hidden: bool = False,
|
|
72
|
+
autocomplete: bool = False,
|
|
73
|
+
initial_dir: str = ".",
|
|
74
|
+
tool_tip: bool = False,
|
|
75
|
+
foldercreation: bool = True,
|
|
76
|
+
geometry: Tuple[str, str] = ("1320x720", "500x400"),
|
|
77
|
+
title: str = "CTkFileDialog",
|
|
78
|
+
) -> str | None:
|
|
79
|
+
"""Displays a directory selection dialog and returns the selected path."""
|
|
80
|
+
normalized = normalize_filetypes(filetypes)
|
|
81
|
+
if style == "Default":
|
|
82
|
+
app = _DrawApp(
|
|
83
|
+
filetypes=normalized,
|
|
84
|
+
current_path=initial_dir,
|
|
85
|
+
hidden=hidden,
|
|
86
|
+
method="askdirectory",
|
|
87
|
+
autocomplete=autocomplete,
|
|
88
|
+
tool_tip=tool_tip,
|
|
89
|
+
foldercreation=foldercreation,
|
|
90
|
+
geometry=geometry[0],
|
|
91
|
+
title=title,
|
|
92
|
+
)
|
|
93
|
+
app.app.wait_window()
|
|
94
|
+
return app.selected_file if app.selected_file else None
|
|
95
|
+
elif style == "Mini":
|
|
96
|
+
app = _MiniDialog(
|
|
97
|
+
filetypes=normalized,
|
|
98
|
+
initial_dir=initial_dir,
|
|
99
|
+
hidden=hidden,
|
|
100
|
+
method="askdirectory",
|
|
101
|
+
autocomplete=autocomplete,
|
|
102
|
+
foldercreation=foldercreation,
|
|
103
|
+
title=title,
|
|
104
|
+
geometry=geometry[1],
|
|
105
|
+
)
|
|
106
|
+
return app.selected_path if app.selected_path else None
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@typechecked
|
|
110
|
+
def askopendirname(
|
|
111
|
+
style: Literal["Default", "Mini"] = "Default",
|
|
112
|
+
hidden: bool = False,
|
|
113
|
+
autocomplete: bool = False,
|
|
114
|
+
initial_dir: str = ".",
|
|
115
|
+
tool_tip: bool = False,
|
|
116
|
+
foldercreation: bool = True,
|
|
117
|
+
geometry: Tuple[str, str] = ("1320x720", "500x400"),
|
|
118
|
+
title: str = "CTkFileDialog",
|
|
119
|
+
) -> str:
|
|
120
|
+
"""Allow the user to choose a single directory."""
|
|
121
|
+
if style == "Default":
|
|
122
|
+
app = _DrawApp(
|
|
123
|
+
current_path=initial_dir,
|
|
124
|
+
hidden=hidden,
|
|
125
|
+
method="askdirectory",
|
|
126
|
+
autocomplete=autocomplete,
|
|
127
|
+
tool_tip=tool_tip,
|
|
128
|
+
foldercreation=foldercreation,
|
|
129
|
+
geometry=geometry[0],
|
|
130
|
+
title=title,
|
|
131
|
+
)
|
|
132
|
+
app.app.wait_window()
|
|
133
|
+
return app.selected_file if app.selected_file else ""
|
|
134
|
+
elif style == "Mini":
|
|
135
|
+
app = _MiniDialog(
|
|
136
|
+
initial_dir=initial_dir,
|
|
137
|
+
hidden=hidden,
|
|
138
|
+
method="askdirectory",
|
|
139
|
+
autocomplete=autocomplete,
|
|
140
|
+
foldercreation=foldercreation,
|
|
141
|
+
title=title,
|
|
142
|
+
geometry=geometry[1],
|
|
143
|
+
)
|
|
144
|
+
return app.selected_path if app.selected_path else ""
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
@typechecked
|
|
148
|
+
def askopendirnames(
|
|
149
|
+
style: Literal["Default", "Mini"] = "Default",
|
|
150
|
+
hidden: bool = False,
|
|
151
|
+
autocomplete: bool = False,
|
|
152
|
+
initial_dir: str = ".",
|
|
153
|
+
tool_tip: bool = False,
|
|
154
|
+
foldercreation: bool = True,
|
|
155
|
+
geometry: Tuple[str, str] = ("1320x720", "500x400"),
|
|
156
|
+
title: str = "CTkFileDialog",
|
|
157
|
+
) -> tuple[str, ...]:
|
|
158
|
+
"""Allow the user to choose multiple directories (Ctrl/Shift + click)."""
|
|
159
|
+
if style == "Default":
|
|
160
|
+
app = _DrawApp(
|
|
161
|
+
current_path=initial_dir,
|
|
162
|
+
hidden=hidden,
|
|
163
|
+
method="askdirectories",
|
|
164
|
+
autocomplete=autocomplete,
|
|
165
|
+
tool_tip=tool_tip,
|
|
166
|
+
foldercreation=foldercreation,
|
|
167
|
+
geometry=geometry[0],
|
|
168
|
+
title=title,
|
|
169
|
+
)
|
|
170
|
+
app.app.wait_window()
|
|
171
|
+
return tuple(app.selected_objects) if app.selected_objects else tuple()
|
|
172
|
+
elif style == "Mini":
|
|
173
|
+
app = _MiniDialog(
|
|
174
|
+
initial_dir=initial_dir,
|
|
175
|
+
hidden=hidden,
|
|
176
|
+
method="askdirectories",
|
|
177
|
+
autocomplete=autocomplete,
|
|
178
|
+
foldercreation=foldercreation,
|
|
179
|
+
title=title,
|
|
180
|
+
geometry=geometry[1],
|
|
181
|
+
)
|
|
182
|
+
return tuple(app.selected_paths) if app.selected_paths else tuple()
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
@typechecked
|
|
186
|
+
def askopenpathname(
|
|
187
|
+
style: Literal["Default", "Mini"] = "Default",
|
|
188
|
+
filetypes: Optional[List[Union[str, Tuple[str, str]]]] = None,
|
|
189
|
+
hidden: bool = False,
|
|
190
|
+
preview_img: bool = False,
|
|
191
|
+
autocomplete: bool = False,
|
|
192
|
+
video_preview: bool = False,
|
|
193
|
+
initial_dir: str = ".",
|
|
194
|
+
tool_tip: bool = False,
|
|
195
|
+
foldercreation: bool = True,
|
|
196
|
+
geometry: Tuple[str, str] = ("1320x720", "500x400"),
|
|
197
|
+
title: str = "CTkFileDialog",
|
|
198
|
+
) -> str:
|
|
199
|
+
"""Allow the user to choose a single file or folder."""
|
|
200
|
+
normalized = normalize_filetypes(filetypes)
|
|
201
|
+
if style == "Default":
|
|
202
|
+
app = _DrawApp(
|
|
203
|
+
filetypes=normalized,
|
|
204
|
+
current_path=initial_dir,
|
|
205
|
+
hidden=hidden,
|
|
206
|
+
preview_img=preview_img,
|
|
207
|
+
method="askopenpathname",
|
|
208
|
+
autocomplete=autocomplete,
|
|
209
|
+
video_preview=video_preview,
|
|
210
|
+
tool_tip=tool_tip,
|
|
211
|
+
foldercreation=foldercreation,
|
|
212
|
+
geometry=geometry[0],
|
|
213
|
+
title=title,
|
|
214
|
+
)
|
|
215
|
+
app.app.wait_window()
|
|
216
|
+
return app.selected_file if app.selected_file else ""
|
|
217
|
+
elif style == "Mini":
|
|
218
|
+
app = _MiniDialog(
|
|
219
|
+
method="askopenpathname",
|
|
220
|
+
filetypes=normalized,
|
|
221
|
+
initial_dir=initial_dir,
|
|
222
|
+
autocomplete=autocomplete,
|
|
223
|
+
hidden=hidden,
|
|
224
|
+
foldercreation=foldercreation,
|
|
225
|
+
geometry=geometry[1],
|
|
226
|
+
title=title,
|
|
227
|
+
)
|
|
228
|
+
return app.selected_path if app.selected_path else ""
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
@typechecked
|
|
232
|
+
def askopenpathnames(
|
|
233
|
+
style: Literal["Default", "Mini"] = "Default",
|
|
234
|
+
filetypes: Optional[List[Union[str, Tuple[str, str]]]] = None,
|
|
235
|
+
hidden: bool = False,
|
|
236
|
+
preview_img: bool = False,
|
|
237
|
+
autocomplete: bool = False,
|
|
238
|
+
video_preview: bool = False,
|
|
239
|
+
initial_dir: str = ".",
|
|
240
|
+
tool_tip: bool = False,
|
|
241
|
+
foldercreation: bool = True,
|
|
242
|
+
geometry: Tuple[str, str] = ("1320x720", "500x400"),
|
|
243
|
+
title: str = "CTkFileDialog",
|
|
244
|
+
) -> tuple[str, ...]:
|
|
245
|
+
"""Allow the user to choose multiple files and folders (Ctrl/Shift + click)."""
|
|
246
|
+
normalized = normalize_filetypes(filetypes)
|
|
247
|
+
if style == "Default":
|
|
248
|
+
app = _DrawApp(
|
|
249
|
+
filetypes=normalized,
|
|
250
|
+
current_path=initial_dir,
|
|
251
|
+
hidden=hidden,
|
|
252
|
+
preview_img=preview_img,
|
|
253
|
+
method="askopenpathnames",
|
|
254
|
+
autocomplete=autocomplete,
|
|
255
|
+
video_preview=video_preview,
|
|
256
|
+
tool_tip=tool_tip,
|
|
257
|
+
foldercreation=foldercreation,
|
|
258
|
+
geometry=geometry[0],
|
|
259
|
+
title=title,
|
|
260
|
+
)
|
|
261
|
+
app.app.wait_window()
|
|
262
|
+
return tuple(app.selected_objects) if app.selected_objects else tuple()
|
|
263
|
+
elif style == "Mini":
|
|
264
|
+
app = _MiniDialog(
|
|
265
|
+
filetypes=normalized,
|
|
266
|
+
initial_dir=initial_dir,
|
|
267
|
+
hidden=hidden,
|
|
268
|
+
autocomplete=autocomplete,
|
|
269
|
+
method="askopenpathnames",
|
|
270
|
+
foldercreation=foldercreation,
|
|
271
|
+
geometry=geometry[1],
|
|
272
|
+
title=title,
|
|
273
|
+
)
|
|
274
|
+
return tuple(app.selected_paths) if app.selected_paths else tuple()
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
@typechecked
|
|
278
|
+
def askopenfilenames(
|
|
279
|
+
style: Literal["Default", "Mini"] = "Default",
|
|
280
|
+
filetypes: Optional[List[Union[str, Tuple[str, str]]]] = None,
|
|
281
|
+
hidden: bool = False,
|
|
282
|
+
preview_img: bool = False,
|
|
283
|
+
autocomplete: bool = False,
|
|
284
|
+
video_preview: bool = False,
|
|
285
|
+
initial_dir: str = ".",
|
|
286
|
+
tool_tip: bool = False,
|
|
287
|
+
foldercreation: bool = True,
|
|
288
|
+
geometry: Tuple[str, str] = ("1320x720", "500x400"),
|
|
289
|
+
title: str = "CTkFileDialog",
|
|
290
|
+
) -> tuple[str, ...] | None:
|
|
291
|
+
"""Displays a file dialog for multiple file selection."""
|
|
292
|
+
normalized = normalize_filetypes(filetypes)
|
|
293
|
+
if style == "Default":
|
|
294
|
+
app = _DrawApp(
|
|
295
|
+
filetypes=normalized,
|
|
296
|
+
current_path=initial_dir,
|
|
297
|
+
hidden=hidden,
|
|
298
|
+
preview_img=preview_img,
|
|
299
|
+
method="askopenfilenames",
|
|
300
|
+
autocomplete=autocomplete,
|
|
301
|
+
video_preview=video_preview,
|
|
302
|
+
tool_tip=tool_tip,
|
|
303
|
+
foldercreation=foldercreation,
|
|
304
|
+
geometry=geometry[0],
|
|
305
|
+
title=title,
|
|
306
|
+
)
|
|
307
|
+
app.app.wait_window()
|
|
308
|
+
return tuple(app.selected_objects) if app.selected_objects else None
|
|
309
|
+
elif style == "Mini":
|
|
310
|
+
app = _MiniDialog(
|
|
311
|
+
filetypes=normalized,
|
|
312
|
+
initial_dir=initial_dir,
|
|
313
|
+
hidden=hidden,
|
|
314
|
+
method="askopenfilenames",
|
|
315
|
+
autocomplete=autocomplete,
|
|
316
|
+
foldercreation=foldercreation,
|
|
317
|
+
geometry=geometry[1],
|
|
318
|
+
title=title,
|
|
319
|
+
)
|
|
320
|
+
return tuple(app.selected_paths) if app.selected_paths else None
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
@typechecked
|
|
324
|
+
def asksaveasfilename(
|
|
325
|
+
style: Literal["Default", "Mini"] = "Default",
|
|
326
|
+
filetypes: Optional[List[Union[str, Tuple[str, str]]]] = None,
|
|
327
|
+
hidden: bool = False,
|
|
328
|
+
preview_img: bool = False,
|
|
329
|
+
autocomplete: bool = False,
|
|
330
|
+
video_preview: bool = False,
|
|
331
|
+
initial_dir: str = ".",
|
|
332
|
+
tool_tip: bool = False,
|
|
333
|
+
foldercreation: bool = True,
|
|
334
|
+
defaultext: Optional[str] = None,
|
|
335
|
+
geometry: Tuple[str, str] = ("1320x720", "500x400"),
|
|
336
|
+
title: str = "CTkFileDialog",
|
|
337
|
+
) -> str | None:
|
|
338
|
+
"""Displays a save file dialog and returns the selected path."""
|
|
339
|
+
normalized = normalize_filetypes(filetypes)
|
|
340
|
+
if style == "Default":
|
|
341
|
+
app = _DrawApp(
|
|
342
|
+
filetypes=normalized,
|
|
343
|
+
current_path=initial_dir,
|
|
344
|
+
hidden=hidden,
|
|
345
|
+
preview_img=preview_img,
|
|
346
|
+
method="asksaveasfilename",
|
|
347
|
+
autocomplete=autocomplete,
|
|
348
|
+
video_preview=video_preview,
|
|
349
|
+
tool_tip=tool_tip,
|
|
350
|
+
foldercreation=foldercreation,
|
|
351
|
+
geometry=geometry[0],
|
|
352
|
+
title=title,
|
|
353
|
+
)
|
|
354
|
+
app.app.wait_window()
|
|
355
|
+
return apply_defaultext(app.selected_file, defaultext) if app.selected_file else None
|
|
356
|
+
elif style == "Mini":
|
|
357
|
+
app = _MiniDialog(
|
|
358
|
+
filetypes=normalized,
|
|
359
|
+
initial_dir=initial_dir,
|
|
360
|
+
hidden=hidden,
|
|
361
|
+
method="asksaveasfilename",
|
|
362
|
+
autocomplete=autocomplete,
|
|
363
|
+
foldercreation=foldercreation,
|
|
364
|
+
geometry=geometry[1],
|
|
365
|
+
title=title,
|
|
366
|
+
)
|
|
367
|
+
return apply_defaultext(app.selected_path, defaultext) if app.selected_path else None
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
@typechecked
|
|
371
|
+
def asksaveasfile(
|
|
372
|
+
style: Literal["Default", "Mini"] = "Default",
|
|
373
|
+
mode: Literal["r", "rb", "r+", "rb+", "r+b", "w", "wb", "w+", "wb+", "a", "ab", "a+", "ab+", "x", "xb"] = "w",
|
|
374
|
+
filetypes: Optional[List[Union[str, Tuple[str, str]]]] = None,
|
|
375
|
+
hidden: bool = False,
|
|
376
|
+
preview_img: bool = False,
|
|
377
|
+
autocomplete: bool = False,
|
|
378
|
+
video_preview: bool = False,
|
|
379
|
+
initial_dir: str = ".",
|
|
380
|
+
tool_tip: bool = False,
|
|
381
|
+
foldercreation: bool = True,
|
|
382
|
+
defaultext: Optional[str] = None,
|
|
383
|
+
geometry: Tuple[str, str] = ("1320x720", "500x400"),
|
|
384
|
+
title: str = "CTkFileDialog",
|
|
385
|
+
**kwargs,
|
|
386
|
+
) -> TextIO | None:
|
|
387
|
+
"""Displays a save dialog and returns an open file object."""
|
|
388
|
+
normalized = normalize_filetypes(filetypes)
|
|
389
|
+
if style == "Default":
|
|
390
|
+
app = _DrawApp(
|
|
391
|
+
filetypes=normalized,
|
|
392
|
+
current_path=initial_dir,
|
|
393
|
+
hidden=hidden,
|
|
394
|
+
preview_img=preview_img,
|
|
395
|
+
method="asksaveasfile",
|
|
396
|
+
autocomplete=autocomplete,
|
|
397
|
+
video_preview=video_preview,
|
|
398
|
+
tool_tip=tool_tip,
|
|
399
|
+
foldercreation=foldercreation,
|
|
400
|
+
geometry=geometry[0],
|
|
401
|
+
title=title,
|
|
402
|
+
)
|
|
403
|
+
app.app.wait_window()
|
|
404
|
+
selected = apply_defaultext(app.selected_file, defaultext)
|
|
405
|
+
return open(selected, mode=mode, **kwargs) if selected else None
|
|
406
|
+
elif style == "Mini":
|
|
407
|
+
app = _MiniDialog(
|
|
408
|
+
filetypes=normalized,
|
|
409
|
+
initial_dir=initial_dir,
|
|
410
|
+
hidden=hidden,
|
|
411
|
+
method="asksaveasfile",
|
|
412
|
+
foldercreation=foldercreation,
|
|
413
|
+
geometry=geometry[1],
|
|
414
|
+
title=title,
|
|
415
|
+
)
|
|
416
|
+
selected = apply_defaultext(app.selected_path, defaultext)
|
|
417
|
+
return open(selected, mode=mode, **kwargs) if selected else None
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
@typechecked
|
|
421
|
+
def askopenfile(
|
|
422
|
+
style: Literal["Mini", "Default"] = "Default",
|
|
423
|
+
mode: Literal["r", "rb", "r+", "rb+", "r+b", "w", "wb", "w+", "wb+", "a", "ab", "a+", "ab+", "x", "xb"] = "r",
|
|
424
|
+
hidden: bool = False,
|
|
425
|
+
filetypes: Optional[List[Union[str, Tuple[str, str]]]] = None,
|
|
426
|
+
preview_img: bool = False,
|
|
427
|
+
autocomplete: bool = False,
|
|
428
|
+
video_preview: bool = False,
|
|
429
|
+
initial_dir: str = ".",
|
|
430
|
+
tool_tip: bool = False,
|
|
431
|
+
foldercreation: bool = True,
|
|
432
|
+
geometry: Tuple[str, str] = ("1320x720", "500x400"),
|
|
433
|
+
title: str = "CTkFileDialog",
|
|
434
|
+
**kwargs,
|
|
435
|
+
) -> TextIO | None:
|
|
436
|
+
"""Displays an open file dialog and returns an open file object."""
|
|
437
|
+
normalized = normalize_filetypes(filetypes)
|
|
438
|
+
if style == "Default":
|
|
439
|
+
app = _DrawApp(
|
|
440
|
+
filetypes=normalized,
|
|
441
|
+
current_path=initial_dir,
|
|
442
|
+
hidden=hidden,
|
|
443
|
+
preview_img=preview_img,
|
|
444
|
+
method="askopenfile",
|
|
445
|
+
autocomplete=autocomplete,
|
|
446
|
+
video_preview=video_preview,
|
|
447
|
+
tool_tip=tool_tip,
|
|
448
|
+
foldercreation=foldercreation,
|
|
449
|
+
geometry=geometry[0],
|
|
450
|
+
title=title,
|
|
451
|
+
)
|
|
452
|
+
app.app.wait_window()
|
|
453
|
+
return open(app.selected_file, mode=mode, **kwargs) if app.selected_file else None
|
|
454
|
+
elif style == "Mini":
|
|
455
|
+
app = _MiniDialog(
|
|
456
|
+
filetypes=normalized,
|
|
457
|
+
initial_dir=initial_dir,
|
|
458
|
+
hidden=hidden,
|
|
459
|
+
method="askopenfile",
|
|
460
|
+
autocomplete=autocomplete,
|
|
461
|
+
foldercreation=foldercreation,
|
|
462
|
+
geometry=geometry[1],
|
|
463
|
+
title=title,
|
|
464
|
+
)
|
|
465
|
+
return open(app.selected_path, mode=mode, **kwargs) if app.selected_path else None
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
@typechecked
|
|
469
|
+
def askopenfiles(
|
|
470
|
+
style: Literal["Default", "Mini"] = "Default",
|
|
471
|
+
mode: Literal["r", "rb", "r+", "rb+", "r+b", "w", "wb", "w+", "wb+", "a", "ab", "a+", "ab+", "x", "xb"] = "r",
|
|
472
|
+
hidden: bool = False,
|
|
473
|
+
filetypes: Optional[List[Union[str, Tuple[str, str]]]] = None,
|
|
474
|
+
preview_img: bool = False,
|
|
475
|
+
autocomplete: bool = False,
|
|
476
|
+
video_preview: bool = False,
|
|
477
|
+
initial_dir: str = ".",
|
|
478
|
+
tool_tip: bool = False,
|
|
479
|
+
foldercreation: bool = True,
|
|
480
|
+
geometry: Tuple[str, str] = ("1320x720", "500x400"),
|
|
481
|
+
title: str = "CTkFileDialog",
|
|
482
|
+
**kwargs,
|
|
483
|
+
) -> tuple[TextIO, ...] | None:
|
|
484
|
+
"""Displays a multi-file open dialog and returns multiple open file objects."""
|
|
485
|
+
normalized = normalize_filetypes(filetypes)
|
|
486
|
+
if style == "Default":
|
|
487
|
+
app = _DrawApp(
|
|
488
|
+
filetypes=normalized,
|
|
489
|
+
current_path=initial_dir,
|
|
490
|
+
hidden=hidden,
|
|
491
|
+
preview_img=preview_img,
|
|
492
|
+
method="askopenfilenames",
|
|
493
|
+
autocomplete=autocomplete,
|
|
494
|
+
video_preview=video_preview,
|
|
495
|
+
tool_tip=tool_tip,
|
|
496
|
+
foldercreation=foldercreation,
|
|
497
|
+
geometry=geometry[0],
|
|
498
|
+
title=title,
|
|
499
|
+
)
|
|
500
|
+
app.app.wait_window()
|
|
501
|
+
return (
|
|
502
|
+
tuple(open(f, mode=mode, **kwargs) for f in app.selected_objects)
|
|
503
|
+
if app.selected_objects
|
|
504
|
+
else None
|
|
505
|
+
)
|
|
506
|
+
elif style == "Mini":
|
|
507
|
+
app = _MiniDialog(
|
|
508
|
+
filetypes=normalized,
|
|
509
|
+
initial_dir=initial_dir,
|
|
510
|
+
hidden=hidden,
|
|
511
|
+
autocomplete=autocomplete,
|
|
512
|
+
method="askopenfilenames",
|
|
513
|
+
foldercreation=foldercreation,
|
|
514
|
+
geometry=geometry[1],
|
|
515
|
+
title=title,
|
|
516
|
+
)
|
|
517
|
+
return (
|
|
518
|
+
tuple(open(f, mode=mode, **kwargs) for f in app.selected_paths)
|
|
519
|
+
if app.selected_paths
|
|
520
|
+
else None
|
|
521
|
+
)
|