CTKFileDialog-plus 0.3.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.
- ctkfiledialog_plus-0.3.0/CTKFileDialog_plus.egg-info/PKG-INFO +343 -0
- ctkfiledialog_plus-0.3.0/CTKFileDialog_plus.egg-info/SOURCES.txt +34 -0
- ctkfiledialog_plus-0.3.0/CTKFileDialog_plus.egg-info/dependency_links.txt +1 -0
- ctkfiledialog_plus-0.3.0/CTKFileDialog_plus.egg-info/requires.txt +6 -0
- ctkfiledialog_plus-0.3.0/CTKFileDialog_plus.egg-info/top_level.txt +1 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/Constants/__init__.py +37 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/Constants/constants.py +39 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/Dialog.py +1409 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/__init__.py +27 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/_functions.py +371 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/_system.py +70 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/bash.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/conf.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/css.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/exe.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/folder.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/gz.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/html.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/image.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/ini.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/javascript.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/js.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/json.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/markdown.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/odt.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/pdf.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/php.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/python.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/text.png +0 -0
- ctkfiledialog_plus-0.3.0/CTkFileDialog/icons/video.png +0 -0
- ctkfiledialog_plus-0.3.0/MANIFEST.in +3 -0
- ctkfiledialog_plus-0.3.0/PKG-INFO +343 -0
- ctkfiledialog_plus-0.3.0/README.md +324 -0
- ctkfiledialog_plus-0.3.0/pyproject.toml +22 -0
- ctkfiledialog_plus-0.3.0/setup.cfg +4 -0
- ctkfiledialog_plus-0.3.0/setup.py +23 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: CTKFileDialog-plus
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: A modern file dialog for CustomTkinter
|
|
5
|
+
Home-page: https://github.com/hmidani-abdelilah/CTkFileDialog-plus
|
|
6
|
+
Author: abdelilah
|
|
7
|
+
Author-email: abdelilah <hmidaniabdelilah92@gmail.com>
|
|
8
|
+
Requires-Python: >=3.7
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: customtkinter
|
|
11
|
+
Requires-Dist: Pillow
|
|
12
|
+
Requires-Dist: opencv-python
|
|
13
|
+
Requires-Dist: CTkMessagebox
|
|
14
|
+
Requires-Dist: CTkToolTip
|
|
15
|
+
Requires-Dist: typeguard
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: home-page
|
|
18
|
+
Dynamic: requires-python
|
|
19
|
+
|
|
20
|
+
<h1 align="center">CTkFileDialog</h1>
|
|
21
|
+
|
|
22
|
+
<h3 align="center">A modern and fully customizable File Dialog for CustomTkinter โ a must-have extension pack!</h3>
|
|
23
|
+
|
|
24
|
+
> [!WARNING]
|
|
25
|
+
> Unfortunately parameters like `video_preview`, `preview_img`, and `tooltip` are not compatible with the mini dialog and will not be applied. View modes and sorting are exclusive to the Default dialog.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## ๐ Features
|
|
30
|
+
|
|
31
|
+
- ๐ Autocomplete in the path entry field (with `Tab`, `Up`, and `Down`)
|
|
32
|
+
- ๏ฟฝ Search/filter files in real-time
|
|
33
|
+
- ๐ผ๏ธ Live image preview
|
|
34
|
+
- ๐ฅ Video thumbnail preview
|
|
35
|
+
- ๐ Directory selection
|
|
36
|
+
- ๐พ Save file dialog (return path or open file)
|
|
37
|
+
- โ Tooltip support
|
|
38
|
+
- ๐ฅ๏ธ Shell Path Syntax Support
|
|
39
|
+
- โจ๏ธ Backspace using Alt + Left Arrow shortcut
|
|
40
|
+
- ๐ Multiple view modes (Grid and List view in Default dialog)
|
|
41
|
+
- ๐ Sort files by name, date, size, type, or last modified
|
|
42
|
+
- ๐ก Data type validation at runtime and for static type analyzers
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## ๐ฆ Installation
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
|
|
50
|
+
# Using bash
|
|
51
|
+
git clone https://github.com/hmidani-abdelilah/CTkFileDialog-plus
|
|
52
|
+
cd CTkFileDialog-plus
|
|
53
|
+
python3 -m venv .venv
|
|
54
|
+
source .venv/bin/activate
|
|
55
|
+
pip3 install -r requirements.txt
|
|
56
|
+
|
|
57
|
+
# On Windows
|
|
58
|
+
git clone https://github.com/hmidani-abdelilah/CTkFileDialog-plus
|
|
59
|
+
cd CTkFileDialog-plus
|
|
60
|
+
python3 -m venv .venv
|
|
61
|
+
.\.venv\Scripts\activate.ps1 # In Powershell
|
|
62
|
+
pip3 install -r requirements.txt
|
|
63
|
+
|
|
64
|
+
# Or ussing pip
|
|
65
|
+
|
|
66
|
+
python3 -m venv .venv
|
|
67
|
+
source .venv/bin/activate # In powershell -> .\.venv\Scripts\activate.ps1
|
|
68
|
+
pip3 install CTkFileDialog-plus
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
> [!WARNING]
|
|
73
|
+
> You should install the [Hack Nerd Fonts](https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.1/Hack.zip) if u wanna see the icons without problems :)
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## ๐งช Demo โ All Methods
|
|
78
|
+
|
|
79
|
+
### ๐๏ธ Open File
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
import customtkinter as ctk
|
|
83
|
+
from CTkFileDialog import askopenfilename
|
|
84
|
+
|
|
85
|
+
ctk.set_appearance_mode("Dark")
|
|
86
|
+
ctk.set_default_color_theme("blue")
|
|
87
|
+
|
|
88
|
+
def open_file():
|
|
89
|
+
path = askopenfilename(preview_img=True, autocomplete=True)
|
|
90
|
+
if path:
|
|
91
|
+
result_label.configure(text=f"Selected file:\n{path}")
|
|
92
|
+
|
|
93
|
+
app = ctk.CTk()
|
|
94
|
+
app.title("askopenfilename Demo")
|
|
95
|
+
app.geometry("500x200")
|
|
96
|
+
|
|
97
|
+
ctk.CTkButton(app, text="Open File", command=open_file).pack(pady=20)
|
|
98
|
+
result_label = ctk.CTkLabel(app, text="Waiting for file selection...")
|
|
99
|
+
result_label.pack()
|
|
100
|
+
|
|
101
|
+
app.mainloop()
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### ๐๏ธ Open Multiple Files
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
import customtkinter as ctk
|
|
111
|
+
from CTkFileDialog import askopenfilenames
|
|
112
|
+
|
|
113
|
+
ctk.set_appearance_mode("Dark")
|
|
114
|
+
ctk.set_default_color_theme("blue")
|
|
115
|
+
|
|
116
|
+
def open_files():
|
|
117
|
+
paths = askopenfilenames(preview_img=True, autocomplete=True)
|
|
118
|
+
if paths:
|
|
119
|
+
result_label.configure(text="Selected files:\n" + "\n".join(paths))
|
|
120
|
+
|
|
121
|
+
app = ctk.CTk()
|
|
122
|
+
app.title("askopenfilenames Demo")
|
|
123
|
+
app.geometry("500x300")
|
|
124
|
+
|
|
125
|
+
ctk.CTkButton(app, text="Open Multiple Files", command=open_files).pack(pady=20)
|
|
126
|
+
result_label = ctk.CTkLabel(app, text="Waiting for file selection...", wraplength=450)
|
|
127
|
+
result_label.pack()
|
|
128
|
+
|
|
129
|
+
app.mainloop()
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### ๐ Select Directory
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
import customtkinter as ctk
|
|
138
|
+
from CTkFileDialog import askdirectory
|
|
139
|
+
|
|
140
|
+
ctk.set_appearance_mode("Dark")
|
|
141
|
+
ctk.set_default_color_theme("blue")
|
|
142
|
+
|
|
143
|
+
def select_directory():
|
|
144
|
+
folder = askdirectory(autocomplete=True)
|
|
145
|
+
if folder:
|
|
146
|
+
result_label.configure(text=f"Selected directory:\n{folder}")
|
|
147
|
+
|
|
148
|
+
app = ctk.CTk()
|
|
149
|
+
app.title("askdirectory Demo")
|
|
150
|
+
app.geometry("500x200")
|
|
151
|
+
|
|
152
|
+
ctk.CTkButton(app, text="Select Directory", command=select_directory).pack(pady=20)
|
|
153
|
+
result_label = ctk.CTkLabel(app, text="Waiting for directory selection...")
|
|
154
|
+
result_label.pack()
|
|
155
|
+
|
|
156
|
+
app.mainloop()
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
### ๐พ Save As (get path only)
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
import customtkinter as ctk
|
|
165
|
+
from CTkFileDialog import asksaveasfilename
|
|
166
|
+
|
|
167
|
+
ctk.set_appearance_mode("Dark")
|
|
168
|
+
ctk.set_default_color_theme("blue")
|
|
169
|
+
|
|
170
|
+
def save_as_filename():
|
|
171
|
+
path = asksaveasfilename(autocomplete=True)
|
|
172
|
+
if path:
|
|
173
|
+
result_label.configure(text=f"Save file as:\n{path}")
|
|
174
|
+
|
|
175
|
+
app = ctk.CTk()
|
|
176
|
+
app.title("asksaveasfilename Demo")
|
|
177
|
+
app.geometry("500x200")
|
|
178
|
+
|
|
179
|
+
ctk.CTkButton(app, text="Save As (Filename Only)", command=save_as_filename).pack(pady=20)
|
|
180
|
+
result_label = ctk.CTkLabel(app, text="Waiting for filename...")
|
|
181
|
+
result_label.pack()
|
|
182
|
+
|
|
183
|
+
app.mainloop()
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
### ๐พ Save As (write to file)
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
import customtkinter as ctk
|
|
192
|
+
from CTkFileDialog import asksaveasfile
|
|
193
|
+
|
|
194
|
+
ctk.set_appearance_mode("Dark")
|
|
195
|
+
ctk.set_default_color_theme("blue")
|
|
196
|
+
|
|
197
|
+
def save_as_file():
|
|
198
|
+
file = asksaveasfile(autocomplete=True)
|
|
199
|
+
if file:
|
|
200
|
+
file.write("This file was created using the demo.")
|
|
201
|
+
file.close()
|
|
202
|
+
result_label.configure(text=f"File saved:\n{file.name}")
|
|
203
|
+
|
|
204
|
+
app = ctk.CTk()
|
|
205
|
+
app.title("asksaveasfile Demo")
|
|
206
|
+
app.geometry("500x200")
|
|
207
|
+
|
|
208
|
+
ctk.CTkButton(app, text="Save As (Real File)", command=save_as_file).pack(pady=20)
|
|
209
|
+
result_label = ctk.CTkLabel(app, text="Waiting for save location...")
|
|
210
|
+
result_label.pack()
|
|
211
|
+
|
|
212
|
+
app.mainloop()
|
|
213
|
+
```
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## ๐งฉ Parameters
|
|
217
|
+
|
|
218
|
+
<div align="center">
|
|
219
|
+
|
|
220
|
+
| Parameter | Description |
|
|
221
|
+
|----------------|-----------------------------------------------------------------------------|
|
|
222
|
+
| `hidden` | Show hidden files or directories (`False` by default). |
|
|
223
|
+
| `preview_img` | Enable image preview in the file dialog. |
|
|
224
|
+
| `video_preview` | Show first frame of video files as thumbnail (experimental). |
|
|
225
|
+
| `autocomplete` | Enable path autocompletion with `Tab`, `Up`, and `Down`. |
|
|
226
|
+
| `initial_dir` | Set the initial directory when opening the dialog. |
|
|
227
|
+
| `tool_tip` | Enable the tool tip. |
|
|
228
|
+
| `style` | Defines the dialog style, by default it will be 'Default' but you can choose a small one ('Mini') |
|
|
229
|
+
| `geometry` | You define the geometry string in a tuple: Example ('NormalGM', 'MiniGeometry') |
|
|
230
|
+
| `title` | Define the title from the app, default will be "CTkFileDialog" |
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## ๐ Dark Mode Preview
|
|
238
|
+
|
|
239
|
+
<p align="center">
|
|
240
|
+
<img src="https://raw.githubusercontent.com/hmidani-abdelilah/CTkFileDialog-plus/refs/heads/main/Images/NormalDialogDark.png" width="80%">
|
|
241
|
+
</p>
|
|
242
|
+
|
|
243
|
+
## โ๏ธ Light Mode Preview
|
|
244
|
+
|
|
245
|
+
<p align="center">
|
|
246
|
+
<img src="https://raw.githubusercontent.com/hmidani-abdelilah/CTkFileDialog-plus/refs/heads/main/Images/NormalDialogLight.png" width="80%">
|
|
247
|
+
</p>
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## ๐ฏ Using New Features
|
|
252
|
+
|
|
253
|
+
### ๐ Search/Filter Files
|
|
254
|
+
Both Default and Mini dialogs include a search bar. Simply type in the search field to filter files and directories in real-time:
|
|
255
|
+
```python
|
|
256
|
+
file = askopenfilename(style='Default')
|
|
257
|
+
# Use the search bar in the dialog to filter results
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### ๐ View Modes (Default Dialog Only)
|
|
261
|
+
The Default dialog supports two view modes:
|
|
262
|
+
- **Grid View**: Icon-based grid layout (default)
|
|
263
|
+
- **List View**: Detailed list with file info (size, date modified, type)
|
|
264
|
+
|
|
265
|
+
Toggle between modes using the view buttons in the toolbar.
|
|
266
|
+
|
|
267
|
+
### ๐ Sorting Options (Default Dialog Only)
|
|
268
|
+
Sort files by:
|
|
269
|
+
- Name (alphabetical)
|
|
270
|
+
- Date (creation/modification time)
|
|
271
|
+
- Type (file extension)
|
|
272
|
+
- Size (file size)
|
|
273
|
+
- Last Modified (most recent first)
|
|
274
|
+
|
|
275
|
+
Select a sort option from the sort menu in the toolbar.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
This module has constants that can be used outside or inside the dialog, they are used to obtain paths like /home/user or /home/user/.config/
|
|
280
|
+
Here is a basic example
|
|
281
|
+
|
|
282
|
+
```python3
|
|
283
|
+
#!/usr/bin/env python3
|
|
284
|
+
import customtkinter as ctk
|
|
285
|
+
from CTkFileDialog import askopenfilename
|
|
286
|
+
from CTkFileDialog.Constants import HOME
|
|
287
|
+
|
|
288
|
+
root = ctk.CTk()
|
|
289
|
+
|
|
290
|
+
def open_file():
|
|
291
|
+
f = askopenfilename(initial_dir=HOME, autocomplete=True)
|
|
292
|
+
if f:
|
|
293
|
+
print(f"file selected: {f}")
|
|
294
|
+
|
|
295
|
+
ctk.CTkButton(master=root, command=open_file, text="Open File").pack(padx=10, pady=10, anchor=ctk.CENTER)
|
|
296
|
+
|
|
297
|
+
root.mainloop()
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## And here are the constants available from the package
|
|
301
|
+
|
|
302
|
+
<div align="center">
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
| Parameter | Description |
|
|
306
|
+
|----------------|-----------------------------------------------------------------------------|
|
|
307
|
+
| `PWD` | Current working directory (e.g., where the program was launched) |
|
|
308
|
+
| `HOME` | User's home directory (e.g., /home/user or C:\Users\user) |
|
|
309
|
+
| `TEMP` | Temporary directory (fallback to /tmp if no env vars are set) |
|
|
310
|
+
| `CONFIG_DIR` | XDG-compliant user configuration directory (default: ~/.config) |
|
|
311
|
+
| `CACHE_DIR` | XDG-compliant user cache directory (default: ~/.cache) |
|
|
312
|
+
| `PATH` | System PATH split into a list of directories |
|
|
313
|
+
| `DATA_DIR` | XDG-compliant user data directory (default: ~/.local/share) |
|
|
314
|
+
| `VENV` | Active Python virtual environment (venv or conda), fallback to PWD |
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
</div>
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## Mini Dialog
|
|
322
|
+
|
|
323
|
+
This is a parameter of the file dialog, but it's more powerful than the default one. As I mentioned earlier, it doesn't support parameters like tooltip, preview_img, or video_preview.
|
|
324
|
+
|
|
325
|
+
## ๐ Dark Mode Preview
|
|
326
|
+
|
|
327
|
+
<p align="center">
|
|
328
|
+
<img src="https://raw.githubusercontent.com/hmidani-abdelilah/CTkFileDialog-plus/refs/heads/main/Images/MiniDialogDark.png" width="80%">
|
|
329
|
+
</p>
|
|
330
|
+
|
|
331
|
+
## โ๏ธ Light Mode Preview
|
|
332
|
+
|
|
333
|
+
<p align="center">
|
|
334
|
+
<img src="https://raw.githubusercontent.com/hmidani-abdelilah/CTkFileDialog-plus/refs/heads/main/Images/MiniDialogLight.png" width="80%">
|
|
335
|
+
</p>
|
|
336
|
+
|
|
337
|
+
The mini design created by [user](https://github.com/limafresh), and the default design created by [user](https://github.com/SelfDreamer) and all credit goes to them. I also want to thank them for creating that design in advance.
|
|
338
|
+
|
|
339
|
+
## I translate the code to English and add this futures:
|
|
340
|
+
|
|
341
|
+
- ๏ฟฝ Search/filter files in real-time
|
|
342
|
+
- ๐ Multiple view modes (Grid and List view in Default dialog)
|
|
343
|
+
- ๐ Sort files by name, date, size, type, or last modified
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
CTKFileDialog_plus.egg-info/PKG-INFO
|
|
6
|
+
CTKFileDialog_plus.egg-info/SOURCES.txt
|
|
7
|
+
CTKFileDialog_plus.egg-info/dependency_links.txt
|
|
8
|
+
CTKFileDialog_plus.egg-info/requires.txt
|
|
9
|
+
CTKFileDialog_plus.egg-info/top_level.txt
|
|
10
|
+
CTkFileDialog/Dialog.py
|
|
11
|
+
CTkFileDialog/__init__.py
|
|
12
|
+
CTkFileDialog/_functions.py
|
|
13
|
+
CTkFileDialog/_system.py
|
|
14
|
+
CTkFileDialog/Constants/__init__.py
|
|
15
|
+
CTkFileDialog/Constants/constants.py
|
|
16
|
+
CTkFileDialog/icons/bash.png
|
|
17
|
+
CTkFileDialog/icons/conf.png
|
|
18
|
+
CTkFileDialog/icons/css.png
|
|
19
|
+
CTkFileDialog/icons/exe.png
|
|
20
|
+
CTkFileDialog/icons/folder.png
|
|
21
|
+
CTkFileDialog/icons/gz.png
|
|
22
|
+
CTkFileDialog/icons/html.png
|
|
23
|
+
CTkFileDialog/icons/image.png
|
|
24
|
+
CTkFileDialog/icons/ini.png
|
|
25
|
+
CTkFileDialog/icons/javascript.png
|
|
26
|
+
CTkFileDialog/icons/js.png
|
|
27
|
+
CTkFileDialog/icons/json.png
|
|
28
|
+
CTkFileDialog/icons/markdown.png
|
|
29
|
+
CTkFileDialog/icons/odt.png
|
|
30
|
+
CTkFileDialog/icons/pdf.png
|
|
31
|
+
CTkFileDialog/icons/php.png
|
|
32
|
+
CTkFileDialog/icons/python.png
|
|
33
|
+
CTkFileDialog/icons/text.png
|
|
34
|
+
CTkFileDialog/icons/video.png
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CTkFileDialog
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module is part of the CTkFileDialog library.
|
|
3
|
+
|
|
4
|
+
It defines system path constants that point to useful directories such as the
|
|
5
|
+
user's home, config, cache, and data folders, as well as the system PATH and temp directory.
|
|
6
|
+
|
|
7
|
+
These constants follow the XDG Base Directory Specification where possible,
|
|
8
|
+
and serve as a utility for file dialogs and other filesystem operations within the library.
|
|
9
|
+
|
|
10
|
+
Available constants:
|
|
11
|
+
|
|
12
|
+
- PWD: Current working directory where the program was launched.
|
|
13
|
+
- HOME: User's home directory.
|
|
14
|
+
- TEMP: Temporary directory, resolved from common environment variables or defaulting to /tmp.
|
|
15
|
+
- CONFIG_DIR: XDG-compliant user configuration directory (e.g., ~/.config).
|
|
16
|
+
- CACHE_DIR: XDG-compliant user cache directory (e.g., ~/.cache).
|
|
17
|
+
- DATA_DIR: XDG-compliant user data directory (e.g., ~/.local/share).
|
|
18
|
+
- PATH: List of directories in the system PATH environment variable.
|
|
19
|
+
- VENV: Path to the active Python virtual environment (VIRTUAL_ENV or CONDA_PREFIX).
|
|
20
|
+
|
|
21
|
+
Author: Flick
|
|
22
|
+
Repository: https://github.com/FlickGMD/CTkFileDialog
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from .constants import PWD, HOME, PATH, TEMP, CONFIG_DIR, CACHE_DIR, DATA_DIR, VENV, PATHS
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
'PWD',
|
|
29
|
+
'HOME',
|
|
30
|
+
'PATH',
|
|
31
|
+
'TEMP',
|
|
32
|
+
'CACHE_DIR',
|
|
33
|
+
'CONFIG_DIR',
|
|
34
|
+
'DATA_DIR',
|
|
35
|
+
'VENV',
|
|
36
|
+
'PATHS',
|
|
37
|
+
]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
# Current working directory (e.g., where the program was launched)
|
|
6
|
+
PWD = str(Path.cwd())
|
|
7
|
+
|
|
8
|
+
# User's home directory (e.g., /home/user or C:\Users\user)
|
|
9
|
+
HOME = str(Path.home())
|
|
10
|
+
|
|
11
|
+
# System PATH split into a list of directories
|
|
12
|
+
PATH = os.getenv('PATH').split(os.pathsep)
|
|
13
|
+
|
|
14
|
+
# Temporary directory (fallback to /tmp if no env vars are set)
|
|
15
|
+
TEMP = os.getenv('TMPDIR') or os.getenv('TEMP') or os.getenv('TMP')
|
|
16
|
+
|
|
17
|
+
# XDG-compliant user configuration directory (default: ~/.config)
|
|
18
|
+
CONFIG_DIR = os.getenv('XDG_CONFIG_HOME', str(Path(HOME) / '.config'))
|
|
19
|
+
|
|
20
|
+
# XDG-compliant user cache directory (default: ~/.cache)
|
|
21
|
+
CACHE_DIR = os.getenv('XDG_CACHE_HOME', str(Path(HOME) / '.cache'))
|
|
22
|
+
|
|
23
|
+
# XDG-compliant user data directory (default: ~/.local/share)
|
|
24
|
+
DATA_DIR = os.getenv('XDG_DATA_HOME', str(Path(HOME) / '.local' / 'share'))
|
|
25
|
+
|
|
26
|
+
# Active Python virtual environment (venv or conda), fallback to PWD
|
|
27
|
+
VENV = os.getenv("VIRTUAL_ENV") or os.getenv("CONDA_PREFIX") or PWD
|
|
28
|
+
|
|
29
|
+
# All paths in a single dictionary for easy access
|
|
30
|
+
PATHS = {
|
|
31
|
+
"HOME": HOME,
|
|
32
|
+
"PWD": PWD,
|
|
33
|
+
"TEMP": TEMP,
|
|
34
|
+
"CONFIG_DIR": CONFIG_DIR,
|
|
35
|
+
"DATA_DIR": DATA_DIR,
|
|
36
|
+
"CACHE_DIR": CACHE_DIR,
|
|
37
|
+
"PATH": PATH,
|
|
38
|
+
'VENV': VENV
|
|
39
|
+
}
|