2
I have the following Python code using the library tkinter
:
from tkinter import *
class Application:
def __init__(self, master=None):
self.widget1 = Frame(master)
self.widget1.pack()
self.msg = Label(self.widget1, text="Busque o arquivo")
self.msg["font"] = ("Calibri", "9", "italic")
self.msg.pack()
self.sair = Button(self.widget1)
self.sair["text"] = "Buscar"
self.sair["font"] = ("Calibri", "9")
self.sair["width"] = 10
self.sair["command"] = self.mudarTexto
self.sair.pack()
self.msg2 = Label(self.widget1, text="")
self.msg2["font"] = ("Calibri", "9", "italic")
self.msg2.pack()
def mudarTexto(self):
if self.msg["text"] == "Busque o arquivo":
#Teria que abrir a pasta do windows aqui
self.msg2["text"] = "NOME DO ARQUIVO AQUI"
root = Tk()
Application(root)
root.mainloop()
At the moment this code just prints a message when the button is pressed, however, I would like to click the button, open a folder in windows to select only one file, and that after selected and given the Ok, the file name was printed in the program.