Last active
June 8, 2024 20:49
-
-
Save vigilantPotato/828862512ea877d22cd89388327df7f1 to your computer and use it in GitHub Desktop.
How to use filedialog_1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
import tkinter, tkinter.filedialog | |
def get_filepath(): | |
filepath = tkinter.filedialog.askopenfilename( | |
title="slect txt file", | |
filetypes=[("txt files", "*.txt")], | |
) | |
filepath_result["text"] = filepath | |
if __name__ == "__main__": | |
ctypes.windll.shcore.SetProcessDpiAwareness(1) | |
root = tkinter.Tk() | |
#message to show filepath | |
filepath_result = tkinter.Message( | |
root, | |
bg="lightblue" | |
) | |
filepath_result.pack() | |
#filedialog button | |
open_filedialog_button = tkinter.Button( | |
root, | |
bg="cyan", | |
command=get_filepath, | |
text="file select", | |
width=15, | |
) | |
open_filedialog_button.pack() | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment