snipplets.dev/code/Python/Tk/select-file-folder.py
2023-09-26 22:05:13 +03:00

27 lines
499 B
Python

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