1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How can I update a text name on a label on Tkinter:

Discussão em 'Python' iniciado por Stack, Novembro 22, 2025.

  1. Stack

    Stack Membro Participativo

    I want that when I upload a file, the label changes its name to file name to filename name.

    #File class
    class File:
    def __init__(self):
    self.filename = None
    def getFile(self):
    self.filename = filedialog.askopenfilename()
    #Button class
    class importtextName(File):
    def __init__(self):
    self.name = "Select a file to encrypt: "
    def update(self, filename):
    self.name = self.filename

    #Layout Encrypt:
    importtext = importtextName()
    importtext = tk.Label(layoutframe, text=importtext.name)
    importtext.grid(column=0, row=0, sticky=tk.EW, padx=5, pady=5)

    #Redirection to import function
    file = File()
    button_encrypt = tk.Button(layoutframe, text="Encrypt", fg="green", command=file.getFile)
    button_encrypt.grid(column=1, row=0, sticky=tk.EW, padx=5, pady=5)

    Continue reading...

Compartilhe esta Página