tk file/folder select

This commit is contained in:
Alexander Popov 2023-06-05 21:55:36 +03:00
parent f08af8bb9b
commit 067deb5051
Signed by: iiiypuk
GPG Key ID: E47FE0AB36CD5ED6

View 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()