[Python] Why my button starts the function without pressing it? [duplicate]

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

  1. Stack

    Stack Membro Participativo

    Why my button starts the imported funtion without pressing it, i think it's the arguments but they are necessary:

    def getFile(self):
    self.filename = filedialog.askopenfilename()
    if len(self.filename) > 25:
    layoutfilename = tk.Label(layoutframe, text=self.filename[25:])
    layoutfilename.grid(column=2, row=0, sticky=tk.EW, padx=5, pady=5)
    else:
    layoutfilename = tk.Label(layoutframe, text=self.filename)
    layoutfilename.grid(column=2, row=0, sticky=tk.EW, padx=5, pady=5)
    encryptbutton = tk.Button(layoutframe, text="Encrypt File", command=encryption(self.filename))
    encryptbutton.grid(column=3, row=0, padx=5, pady=5)

    Continue reading...

Compartilhe esta Página