import tkinter as tk from tkinter import filedialog # from tkinter import * class Application(tk.Frame): def __init__(self, master=None): super().__init__(master) self.master = master self.pack() self.create_widgets() def create_widgets(self): self.copy_from = tk.Button(self) self.copy_from["text"] = "Copy from..." # self.copy_from["command"] = self.get_dir(self.copy_from) self.copy_from.pack(side="top") self.copy_to = tk.Button(self) self.copy_to["text"] = "Copy to..." # self.copy_to.bind('', self.get_dir(self.copy_to)) self.copy_to.pack(side="top") self.quit = tk.Button(self, text="QUIT", fg="red", command=self.master.destroy) self.quit.pack(side="bottom") def get_dir(self, the_widget): folder_selected = filedialog.askdirectory() if len(folder_selected) > 6: the_widget.config(text=folder_selected) root = tk.Tk() app = Application(master=root) app.copy_from.configure(command=app.get_dir(app.copy_from)) app.mainloop()