tk file/folder select
This commit is contained in:
parent
f08af8bb9b
commit
067deb5051
26
~/Python/Tk/select-file-folder.py
Normal file
26
~/Python/Tk/select-file-folder.py
Normal file
@ -0,0 +1,26 @@
|
||||
from tkinter import filedialog
|
||||
from tkinter import *
|
||||
|
||||
root = Tk()
|
||||
root.withdraw()
|
||||
|
||||
def select_file():
|
||||
file_selected = filedialog.askopenfilename(
|
||||
title='Open a file',
|
||||
initialdir='/',
|
||||
filetypes=(
|
||||
('Text files', '*.txt'),
|
||||
('All files', '*.*')
|
||||
)
|
||||
)
|
||||
|
||||
print(file_selected)
|
||||
|
||||
def select_folder():
|
||||
folder_selected = filedialog.askdirectory()
|
||||
|
||||
print(folder_selected)
|
||||
|
||||
if __name__ == '__main__':
|
||||
select_file()
|
||||
select_folder()
|
Loading…
Reference in New Issue
Block a user