-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathfile_dialog.py
More file actions
26 lines (24 loc) · 852 Bytes
/
file_dialog.py
File metadata and controls
26 lines (24 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Specify the title and message and filter to txt files
file = open_file_dialog(
"Open a single file", "Choose something interesting", filter=".txt"
)
print(file) # Python tempfile.NamedTemporaryFile object
print(file.filename()) # Filename that was selected in the dialog
print(file.read())
file.close()
files = open_files_dialog("Open multiple files") # message is optional
print(
files
) # Array of tempfile.NamedTemporaryFile objects (even if you select only one)
for file in files:
print(file.filename())
print(file.read())
file.close()
# Specify the title and message
file = open_bucket_dialog(
"Open a file from the buckets", "Choose something interesting"
)
print(file) # Python tempfile.NamedTemporaryFile object
print(file.filename()) # Filename that was selected in the dialog
print(file.read())
file.close()