Skip to content

Commit e51f393

Browse files
authored
Merge pull request #156 from kujirahand/samples_for_148
Samples for #148 This pull request improves the documentation and usability of the popup_get_file dialog in the TkEasyGUI library, and enhances the overall clarity of the README and API documentation. The main changes include expanded usage examples and parameter explanations for file dialogs, updates to installation instructions, and alignment of documentation with recent code changes.
2 parents 2723aa5 + 118cda1 commit e51f393

6 files changed

Lines changed: 1177 additions & 1095 deletions

File tree

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
`TkEasyGUI` is the easiest library for creating GUIs in Python.
88

9+
<img src="https://github.com/kujirahand/tkeasygui-python/raw/main/docs/image/icon256.png" width="256" alt="TkEasyGUI is the easiest library for creating GUIs in Python.">
10+
911
This library allows you to easily create GUI applications with Python.
1012
Since it is based on Tkinter, it runs consistently on Windows, macOS, and Linux.
1113
With a variety of built-in dialogs and customizable forms, you can develop applications effortlessly.
@@ -23,6 +25,7 @@ With a variety of built-in dialogs and customizable forms, you can develop appli
2325
Install package from [PyPI](https://pypi.org/project/TkEasyGUI/).
2426

2527
```sh
28+
# Install package from PyPI
2629
pip install TkEasyGUI
2730
# or
2831
python -m pip install TkEasyGUI
@@ -31,7 +34,13 @@ python -m pip install TkEasyGUI
3134
Install package from [GitHub Repository](https://github.com/kujirahand/tkeasygui-python).
3235

3336
```sh
37+
# Install package from GitHub Repository
3438
python -m pip install git+https://github.com/kujirahand/tkeasygui-python
39+
# or
40+
# Clone the repository and install
41+
git clone https://github.com/kujirahand/tkeasygui-python
42+
cd tkeasygui-python
43+
python -m pip install .
3544
```
3645

3746
## Features of This Library
@@ -79,6 +88,17 @@ if form:
7988

8089
<img src="https://github.com/kujirahand/tkeasygui-python/raw/main/docs/image/sample3.png" width="300" alt="TkEasyGUI">
8190

91+
A file selection dialog is also available.
92+
93+
```py
94+
import TkEasyGUI as eg
95+
# Show File dialog
96+
file_path = eg.popup_get_file("Select a file")
97+
eg.print(f"You selected: {file_path}")
98+
```
99+
100+
<img src="https://github.com/kujirahand/tkeasygui-python/raw/main/docs/image/sample-popup_get_file.png" width="300" alt="TkEasyGUI">
101+
82102
### More Dialogs
83103

84104
`TkEasyGUI` provides a variety of dialogs. For example, a color selection dialog, a file selection dialog, and a calendar dialog.
@@ -176,8 +196,6 @@ There are other helpful articles as well.
176196
- Methods such as Copy, Paste, and Cut are added to text boxes (Multiline/Input).
177197
- The system's default color scheme is utilized.
178198

179-
<img src="https://github.com/kujirahand/tkeasygui-python/raw/main/docs/image/icon256.png" width="256" alt="TkEasyGUI Logo">
180-
181199
## Additional Information
182200

183201
### How to run on Raspberry Pi?

TkEasyGUI/dialogs.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,32 @@ 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+
import TkEasyGUI as eg
731+
732+
# select a file to open
733+
file_path = eg.popup_get_file("Select a file to open:", "Open File")
734+
print(file_path)
735+
# select a file to save
736+
save_path = eg.popup_get_file("Select a file to save:", "Save File", save_as=True)
737+
print(save_path)
738+
# select multiple files
739+
files = eg.popup_get_file("Select files:", "Open Files", multiple_files=True)
740+
files_list = files.split(eg.FILES_DELIMITER) if files else []
741+
eg.popup_listbox(files_list, "Selected Files")
742+
# select only text files
743+
text_file = eg.popup_get_file("Select a text file:", "Open Text File", file_types=[("Text Files", "*.txt")])
744+
print(text_file)
745+
```
746+
"""
722747
from . import widgets as eg
723748

724749
if title is None:

0 commit comments

Comments
 (0)