Skip to content

Commit 3dc58b9

Browse files
committed
add document for popup_get_file
1 parent 350388b commit 3dc58b9

3 files changed

Lines changed: 1135 additions & 1093 deletions

File tree

TkEasyGUI/dialogs.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,30 @@ def popup_get_file(
718718
no_window: Optional[bool] = None, # for compatibility
719719
**kw,
720720
) -> Optional[str]:
721-
"""Popup a file selection dialog. Return the file selected."""
721+
"""
722+
Popup a file selection dialog. Return the file selected.
723+
724+
- if `save_as` is False, show open file dialog.
725+
- if `save_as` is True, show save as dialog.
726+
- if `multiple_files` is True, can select multiple files and return a string joined by `files_delimiter`(default is FILES_DELIMITER).
727+
- `file_types` is a list of tuples (description, file extension) or a list of file extensions. For example: [("Text Files", "*.txt"), ("All Files", "*.*")] or ["*.txt", "*.py"].
728+
729+
```py
730+
# select a file to open
731+
file_path = eg.popup_get_file("Select a file to open:", "Open File")
732+
print(file_path)
733+
# select a file to save
734+
save_path = eg.popup_get_file("Select a file to save:", "Save File", save_as=True)
735+
print(save_path)
736+
# select multiple files
737+
files = eg.popup_get_file("Select files:", "Open Files", multiple_files=True)
738+
files_list = files.split(eg.FILES_DELIMITER) if files else []
739+
eg.popup_listbox(files_list, "Selected Files")
740+
# select only text files
741+
text_file = eg.popup_get_file("Select a text file:", "Open Text File", file_types=[("Text Files", "*.txt")])
742+
print(text_file)
743+
```
744+
"""
722745
from . import widgets as eg
723746

724747
if title is None:

0 commit comments

Comments
 (0)