CTKFileDialog-plus 0.5.1__tar.gz → 0.5.3__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.
Files changed (36) hide show
  1. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTKFileDialog_plus.egg-info/PKG-INFO +95 -25
  2. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/Dialog.py +71 -130
  3. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/_functions.py +90 -33
  4. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/PKG-INFO +95 -25
  5. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/README.md +94 -22
  6. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/pyproject.toml +2 -2
  7. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/setup.py +1 -2
  8. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTKFileDialog_plus.egg-info/SOURCES.txt +0 -0
  9. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTKFileDialog_plus.egg-info/dependency_links.txt +0 -0
  10. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTKFileDialog_plus.egg-info/requires.txt +0 -0
  11. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTKFileDialog_plus.egg-info/top_level.txt +0 -0
  12. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/Constants/__init__.py +0 -0
  13. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/Constants/constants.py +0 -0
  14. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/__init__.py +0 -0
  15. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/_system.py +0 -0
  16. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/bash.png +0 -0
  17. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/conf.png +0 -0
  18. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/css.png +0 -0
  19. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/exe.png +0 -0
  20. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/folder.png +0 -0
  21. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/gz.png +0 -0
  22. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/html.png +0 -0
  23. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/image.png +0 -0
  24. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/ini.png +0 -0
  25. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/javascript.png +0 -0
  26. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/js.png +0 -0
  27. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/json.png +0 -0
  28. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/markdown.png +0 -0
  29. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/odt.png +0 -0
  30. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/pdf.png +0 -0
  31. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/php.png +0 -0
  32. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/python.png +0 -0
  33. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/text.png +0 -0
  34. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/CTkFileDialog/icons/video.png +0 -0
  35. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/MANIFEST.in +0 -0
  36. {ctkfiledialog_plus-0.5.1 → ctkfiledialog_plus-0.5.3}/setup.cfg +0 -0
@@ -1,10 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: CTKFileDialog-plus
3
- Version: 0.5.1
3
+ Version: 0.5.3
4
4
  Summary: A modern file dialog for CustomTkinter
5
5
  Home-page: https://github.com/hmidani-abdelilah/CTkFileDialog-plus
6
6
  Author: abdelilah
7
- Author-email: abdelilah <hmidaniabdelilah92@gmail.com>
8
7
  Requires-Python: >=3.7
9
8
  Description-Content-Type: text/markdown
10
9
  Requires-Dist: customtkinter
@@ -13,11 +12,10 @@ Requires-Dist: opencv-python
13
12
  Requires-Dist: CTkMessagebox
14
13
  Requires-Dist: CTkToolTip
15
14
  Requires-Dist: typeguard
16
- Dynamic: author
17
15
  Dynamic: home-page
18
16
  Dynamic: requires-python
19
17
 
20
- <h1 align="center">CTkFileDialog-plus</h1>
18
+ <h1 align="center">CTkFileDialog</h1>
21
19
 
22
20
  <h3 align="center">A modern and fully customizable File Dialog for CustomTkinter — a must-have extension pack!</h3>
23
21
 
@@ -29,6 +27,7 @@ Dynamic: requires-python
29
27
  ## 🚀 Features
30
28
 
31
29
  - 🔍 Autocomplete in the path entry field (with `Tab`, `Up`, and `Down`)
30
+ - 🧩 Flexible filetype filters: accepts simple extensions **or** tkinter-style `(label, pattern)` tuples (patterns may contain multiple space‑separated globs). Wildcards like `*`/`*.*` are treated as match‑all.
32
31
  - � Search/filter files in real-time
33
32
  - 🖼️ Live image preview
34
33
  - 🎥 Video thumbnail preview
@@ -61,10 +60,10 @@ python3 -m venv .venv
61
60
  .\.venv\Scripts\activate.ps1 # In Powershell
62
61
  pip3 install -r requirements.txt
63
62
 
64
- # Or using pip
63
+ # Or ussing pip
65
64
 
66
65
  python3 -m venv .venv
67
- source .venv/bin/activate # In Powershell -> .\.venv\Scripts\activate.ps1
66
+ source .venv/bin/activate # In powershell -> .\.venv\Scripts\activate.ps1
68
67
  pip3 install CTkFileDialog-plus
69
68
 
70
69
  ```
@@ -86,7 +85,18 @@ ctk.set_appearance_mode("Dark")
86
85
  ctk.set_default_color_theme("blue")
87
86
 
88
87
  def open_file():
89
- path = askopenfilename(preview_img=True, autocomplete=True)
88
+ # you can pass simple extensions...
89
+ # path = askopenfilename(preview_img=True, autocomplete=True)
90
+ # or tkinter‑style tuples with labels and multiple globs:
91
+ path = askopenfilename(
92
+ filetypes=[
93
+ ("Text files","*.txt"),
94
+ ("Python","*.py *.pyw"),
95
+ ("All","*.*"),
96
+ ],
97
+ preview_img=True,
98
+ autocomplete=True,
99
+ )
90
100
  if path:
91
101
  result_label.configure(text=f"Selected file:\n{path}")
92
102
 
@@ -105,7 +115,6 @@ app.mainloop()
105
115
 
106
116
  ### 🗂️ Open Multiple Files
107
117
 
108
-
109
118
  ```python
110
119
  import customtkinter as ctk
111
120
  from CTkFileDialog import askopenfilenames
@@ -114,7 +123,11 @@ ctk.set_appearance_mode("Dark")
114
123
  ctk.set_default_color_theme("blue")
115
124
 
116
125
  def open_files():
117
- paths = askopenfilenames(preview_img=True, autocomplete=True)
126
+ paths = askopenfilenames(
127
+ filetypes=[("Images","*.jpg *.png"), ("All","*.*")],
128
+ preview_img=True,
129
+ autocomplete=True,
130
+ )
118
131
  if paths:
119
132
  result_label.configure(text="Selected files:\n" + "\n".join(paths))
120
133
 
@@ -195,11 +208,11 @@ ctk.set_appearance_mode("Dark")
195
208
  ctk.set_default_color_theme("blue")
196
209
 
197
210
  def save_as_file():
198
- f = asksaveasfile(autocomplete=True)
199
- if f:
200
- f.write("This file was created using the demo.")
201
- f.close()
202
- result_label.configure(text=f"File saved:\n{f.name}")
211
+ file = asksaveasfile(autocomplete=True)
212
+ if file:
213
+ file.write("This file was created using the demo.")
214
+ file.close()
215
+ result_label.configure(text=f"File saved:\n{file.name}")
203
216
 
204
217
  app = ctk.CTk()
205
218
  app.title("asksaveasfile Demo")
@@ -211,6 +224,68 @@ result_label.pack()
211
224
 
212
225
  app.mainloop()
213
226
  ```
227
+
228
+ ---
229
+
230
+ ### 📂 Open File as Object
231
+
232
+ ```python
233
+ import customtkinter as ctk
234
+ from CTkFileDialog import askopenfile
235
+
236
+ ctk.set_appearance_mode("Dark")
237
+ ctk.set_default_color_theme("blue")
238
+
239
+ def open_file_obj():
240
+ f = askopenfile(mode='rb',
241
+ filetypes=[("Binary","*.bin"), ("All","*.*")])
242
+ if f:
243
+ data = f.read()
244
+ f.close()
245
+ result_label.configure(text=f"Read {len(data)} bytes from {f.name}")
246
+
247
+ app = ctk.CTk()
248
+ app.title("askopenfile Demo")
249
+ app.geometry("500x200")
250
+
251
+ ctk.CTkButton(app, text="Open File Object", command=open_file_obj).pack(pady=20)
252
+ result_label = ctk.CTkLabel(app, text="Waiting for file selection...")
253
+ result_label.pack()
254
+
255
+ app.mainloop()
256
+ ```
257
+
258
+ ---
259
+
260
+ ### 📂 Open Multiple Files as Objects
261
+
262
+ ```python
263
+ import customtkinter as ctk
264
+ from CTkFileDialog import askopenfiles
265
+
266
+ ctk.set_appearance_mode("Dark")
267
+ ctk.set_default_color_theme("blue")
268
+
269
+ def open_files_obj():
270
+ files = askopenfiles(mode='r', filetypes=[("Text","*.txt")])
271
+ if files:
272
+ for f in files:
273
+ content = f.read()
274
+ f.close()
275
+ print(f"{f.name}: {len(content)} chars")
276
+ result_label.configure(text=f"Opened {len(files)} files, see console output.")
277
+
278
+ app = ctk.CTk()
279
+ app.title("askopenfiles Demo")
280
+ app.geometry("500x200")
281
+
282
+ ctk.CTkButton(app, text="Open Files Objects", command=open_files_obj).pack(pady=20)
283
+ result_label = ctk.CTkLabel(app, text="Waiting for file selection...")
284
+ result_label.pack()
285
+
286
+ app.mainloop()
287
+ ```
288
+
214
289
  ---
215
290
 
216
291
  ## 🧩 Parameters
@@ -219,15 +294,16 @@ app.mainloop()
219
294
 
220
295
  | Parameter | Description |
221
296
  |----------------|-----------------------------------------------------------------------------|
297
+ | `filetypes` | Optional filter list: either `['.txt', '.md']` or `[('Text','*.txt'),('Py','*.py *.pyw'),('All','*.*')]`. Wildcards are normalized internally. |
222
298
  | `hidden` | Show hidden files or directories (`False` by default). |
223
299
  | `preview_img` | Enable image preview in the file dialog. |
224
300
  | `video_preview` | Show first frame of video files as thumbnail (experimental). |
225
301
  | `autocomplete` | Enable path autocompletion with `Tab`, `Up`, and `Down`. |
226
302
  | `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" |
303
+ | `tool_tip` | Enable the tool tip. |
304
+ | `style` | Defines the dialog style, by default it will be 'Default' but you can choose a small one ('Mini'). |
305
+ | `geometry` | You define the geometry string in a tuple: Example ('NormalGM', 'MiniGeometry'). |
306
+ | `title` | Define the title from the app, default will be "CTkFileDialog". |
231
307
 
232
308
 
233
309
  </div>
@@ -320,7 +396,7 @@ root.mainloop()
320
396
 
321
397
  ## Mini Dialog
322
398
 
323
- The mini dialog is a compact alternative to the Default dialog. It does not support `tooltip`, `preview_img`, or `video_preview`.
399
+ 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
400
 
325
401
  ## 🌙 Dark Mode Preview
326
402
 
@@ -335,9 +411,3 @@ The mini dialog is a compact alternative to the Default dialog. It does not supp
335
411
  </p>
336
412
 
337
413
  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
@@ -212,17 +212,26 @@ class _DrawApp():
212
212
 
213
213
  # If it's a file and we're in save-as mode
214
214
  if self.method in ['asksaveasfile', 'asksaveasfilename']:
215
- # In save-as mode, we just select the file path
216
- # The file will be created/overwritten when user confirms
215
+ if os.path.isfile(path):
216
+ msg = CTkMessagebox(
217
+ message='This file exists. Do you want to overwrite it?',
218
+ icon='warning',
219
+ title='Warning',
220
+ option_1='Yes',
221
+ option_2='No'
222
+ )
223
+ if msg.get() == 'No':
224
+ return
217
225
  self._temp_item = path
218
- self.update_entry(path)
226
+ self.close_app()
219
227
  return
220
228
 
221
229
  if self.method == 'askopenfile':
222
230
  if not os.path.isfile(path):
231
+
223
232
  CTkMessagebox(message='File not found!', title='Error', icon='cancel')
224
233
  self.PathEntry.delete(0, ctk.END)
225
- self.PathEntry.insert(0, str(self.current_path))
234
+ self.PathEntry.insert(0, self.current_path)
226
235
  return
227
236
 
228
237
  self._temp_item = path
@@ -242,104 +251,38 @@ class _DrawApp():
242
251
  return
243
252
 
244
253
  except PermissionError:
254
+
245
255
  CTkMessagebox(message='Permission denied!', title='Error', icon='cancel')
246
- except FileNotFoundError:
256
+ except FileNotFoundError:
257
+
247
258
  CTkMessagebox(message='File Not Found!', title='Error', icon='cancel')
248
259
 
249
260
  def close_app(self):
250
- # Handle save-as filename dialog
251
261
  if self.method == 'asksaveasfilename':
252
- path = self.PathEntry.get().strip()
253
- if not path:
254
- CTkMessagebox(message='Please enter a filename!', title='Error', icon='cancel')
255
- return
256
-
257
- # Check if it's a valid path
258
- path = os.path.abspath(os.path.expanduser(os.path.expandvars(path)))
259
-
260
- # Don't allow directories as filenames
261
- if os.path.isdir(path):
262
- CTkMessagebox(message='A directory with this name exists. Please enter a filename.', title='Error', icon='cancel')
263
- return
264
-
265
- # Check if file exists and ask for confirmation
266
- if os.path.exists(path):
267
- msg = CTkMessagebox(
268
- message='This file already exists. Do you want to overwrite it?',
269
- icon='warning',
270
- title='File Exists',
271
- option_1='Yes',
272
- option_2='No'
273
- )
274
- if msg.get() == 'No':
275
- return
276
-
277
- self.selected_file = path
278
- self.protocol_windows()
279
- self.app.destroy()
280
- return
281
-
282
- # Handle save-as file dialog
283
- if self.method == 'asksaveasfile':
284
- path = self.PathEntry.get().strip()
285
- if not path:
286
- CTkMessagebox(message='Please enter a filename!', title='Error', icon='cancel')
287
- return
288
-
289
- path = os.path.abspath(os.path.expanduser(os.path.expandvars(path)))
290
-
291
- if os.path.isdir(path):
292
- CTkMessagebox(message='A directory with this name exists. Please enter a filename.', title='Error', icon='cancel')
293
- return
294
-
295
- if os.path.exists(path):
296
- msg = CTkMessagebox(
297
- message='This file already exists. Do you want to overwrite it?',
298
- icon='warning',
299
- title='File Exists',
300
- option_1='Yes',
301
- option_2='No'
302
- )
303
- if msg.get() == 'No':
304
- return
305
-
306
- self.selected_file = path
307
- self.protocol_windows()
308
- self.app.destroy()
309
- return
262
+ if not os.path.isdir(self.PathEntry.get()): self.selected_file = self.PathEntry.get()
310
263
 
311
- # Handle single file open
312
- if self.method == 'askopenfile':
313
- if not self._temp_item:
314
- CTkMessagebox(message='Please select a file!', title='Error', icon='cancel')
315
- return
316
-
317
- self.selected_file = self._temp_item
318
- self.protocol_windows()
264
+ if self._temp_item:
265
+ self.protocol_windows()
319
266
  self.app.destroy()
320
- return
321
-
322
- # Handle single file/directory selection
323
- if self.method in ['askopenfilename', 'askdirectory']:
324
- if not self._temp_item:
325
- CTkMessagebox(message='Please select a file or directory!', title='Error', icon='cancel')
267
+ if self.method == 'asksaveasfile':
268
+ self.selected_file = self._temp_item
269
+ return
270
+ elif self.method == 'askopenfile':
271
+ self.selected_file = self._temp_item
272
+ else:
273
+ self.selected_file = self._temp_item
326
274
  return
327
-
328
- self.selected_file = self._temp_item
329
- self.protocol_windows()
330
- self.app.destroy()
331
- return
332
275
 
333
- # Handle multiple files selection
334
276
  if len(self._temp_items) >= 1:
335
277
  self.protocol_windows()
336
278
  self.app.destroy()
337
- if self.method in ["askopenfilenames", "askopenfiles"]:
279
+ if self.method == "askopenfilenames" or self.method == "askopenfiles":
338
280
  seen = set()
339
281
  self.selected_objects = [
340
282
  f for f in self._temp_items
341
283
  if not os.path.isdir(f) and f not in seen and not seen.add(f)
342
284
  ]
285
+
343
286
  return
344
287
 
345
288
 
@@ -557,37 +500,54 @@ class _DrawApp():
557
500
 
558
501
 
559
502
  def event_scroll(self):
560
-
503
+ """Bind mouse-wheel events so file list scrolls in Default dialog.
504
+
505
+ Previous code attached handlers to the internal canvas only which
506
+ meant wheel rotation would sometimes be ignored (especially when
507
+ focus was on another widget). On X11 ``<MouseWheel>`` may not
508
+ fire at all, so we also listen for ``<Button-4>``/``<Button-5>``.
509
+ The handler performs a hit-test to ensure scrolling only occurs
510
+ when the pointer is above the scrollable area.
511
+ """
512
+
561
513
  canvas = self.CenterSideFrame._parent_canvas
562
514
 
563
515
  def _on_mousewheel(event):
564
516
  try:
565
- x_root, y_root = event.x_root, event.y_root
566
-
567
- # Coordinates and size of the scrollable frame
568
- x1 = self.CenterSideFrame.winfo_rootx()
569
- y1 = self.CenterSideFrame.winfo_rooty()
570
- x2 = x1 + self.CenterSideFrame.winfo_width()
571
- y2 = y1 + self.CenterSideFrame.winfo_height()
572
- if x1 <= x_root <= x2 and y1 <= y_root <= y2:
573
-
574
- if event.num == 4:
517
+ # only scroll when pointer is over the frame
518
+ x_root = getattr(event, 'x_root', None)
519
+ y_root = getattr(event, 'y_root', None)
520
+ if x_root is not None and y_root is not None:
521
+ x1 = self.CenterSideFrame.winfo_rootx()
522
+ y1 = self.CenterSideFrame.winfo_rooty()
523
+ x2 = x1 + self.CenterSideFrame.winfo_width()
524
+ y2 = y1 + self.CenterSideFrame.winfo_height()
525
+ if not (x1 <= x_root <= x2 and y1 <= y_root <= y2):
526
+ return
527
+
528
+ # handle scroll events from different platforms
529
+ if hasattr(event, 'num'):
530
+ if event.num == 4:
575
531
  canvas.yview_scroll(-1, "units")
576
- elif event.num == 5:
532
+ self._check_scroll(self.app)
533
+ return "break"
534
+ elif event.num == 5:
577
535
  canvas.yview_scroll(1, "units")
578
- else:
579
- canvas.yview_scroll(-int(event.delta / 120), "units")
580
-
581
- # Trigger lazy loading check
536
+ self._check_scroll(self.app)
537
+ return "break"
538
+
539
+ if hasattr(event, 'delta'):
540
+ canvas.yview_scroll(-int(event.delta / 120), "units")
582
541
  self._check_scroll(self.app)
583
542
  return "break"
584
- except Exception as e:
543
+ except Exception:
585
544
  pass
586
545
 
587
- canvas.bind_all("<MouseWheel>", _on_mousewheel)
588
- canvas.bind("<Button-4>", _on_mousewheel)
589
- canvas.bind("<Button-5>", _on_mousewheel)
590
- canvas.bind("<MouseWheel>", _on_mousewheel)
546
+ # bind to the top–level window so scrolling works regardless of
547
+ # focus or which child widget generated the event
548
+ self.app.bind_all("<MouseWheel>", _on_mousewheel)
549
+ self.app.bind_all("<Button-4>", _on_mousewheel)
550
+ self.app.bind_all("<Button-5>", _on_mousewheel)
591
551
 
592
552
  # Bind to all child widgets
593
553
  for widget in canvas.winfo_children():
@@ -644,12 +604,8 @@ class _DrawApp():
644
604
  hover_color="#8da3ae",
645
605
  text_color="#000000" if self.current_theme.lower() == 'light' else '#cccccc',
646
606
  )
647
- if os.path.isdir(r):
607
+ if os.path.isdir(r):
648
608
  self.navigate_to(path=r, master=master)
649
- elif self.method in ['asksaveasfile', 'asksaveasfilename']:
650
- # In save-as mode, select the file (don't navigate)
651
- self._temp_item = r
652
- self.update_entry(r)
653
609
  else:
654
610
  self._temp_items.append(r)
655
611
 
@@ -1378,20 +1334,13 @@ class _MiniDialog():
1378
1334
  path = os.path.join(self.initial_dir, path)
1379
1335
 
1380
1336
  if self.method in ['asksaveasfile', 'asksaveasfilename']:
1381
- # Validate filename
1382
- if not path:
1383
- CTkMessagebox(message='Please enter a filename!', title='Error', icon='cancel')
1384
- return
1385
-
1386
- if os.path.isdir(path):
1387
- CTkMessagebox(message='A directory with this name exists. Please enter a filename.', title='Error', icon='cancel')
1337
+ if not path or os.path.isdir(path):
1388
1338
  return
1389
1339
 
1390
- # Check if file exists and ask for confirmation
1391
- if os.path.exists(path):
1340
+ if os.path.exists(path) and self._extra_method != 'askopenfile':
1392
1341
  opts = CTkMessagebox(
1393
- message='This file already exists. Do you want to overwrite it?',
1394
- title='File Exists',
1342
+ message='This file already exists! Do you want to overwrite it?',
1343
+ title='Error',
1395
1344
  icon='warning',
1396
1345
  option_1='Yes',
1397
1346
  option_2='No'
@@ -1441,10 +1390,6 @@ class _MiniDialog():
1441
1390
  idx = items.index(selected_item)
1442
1391
  if hasattr(self, 'absolute_paths') and idx < len(self.absolute_paths):
1443
1392
  self.selected_item = self.absolute_paths[idx]
1444
-
1445
- # For save-as dialogs, update the path entry with selected file
1446
- if self.method in ['asksaveasfile', 'asksaveasfilename']:
1447
- self.update_entry(self.selected_item)
1448
1393
  except (ValueError, IndexError):
1449
1394
  pass
1450
1395
 
@@ -1468,10 +1413,6 @@ class _MiniDialog():
1468
1413
  # If it's a file:
1469
1414
  self.path_entry.delete(0, ctk.END)
1470
1415
  self.path_entry.insert(0, self.selected_item)
1471
-
1472
- # For files in open mode, auto-select and return
1473
- if self.method in ['askopenfile', 'askopenfilename']:
1474
- self._on_select()
1475
1416
 
1476
1417
 
1477
1418
  def _up(self):