How can I assign a variable to the askdirectory() command and get the full path of the selected directory?
Here's my code:
from tkinter import*
from tkinter import ttk
from tkinter.filedialog import askdirectory
root = Tk()
root.title("Add Mods")
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0,row=0,sticky=(N,W,E,S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0,weight=1)
ttk.Label(mainframe, text="Select your desired installation directory,
and then click install").grid(column=0,row=1)
ttk.Button(mainframe, text="Select Installation Directory",
command=askdirectory()).grid(column=2,row=2)
root.mainloop()
Note: When I run the script, the function runs even though it shouldn't run until the button is pushed.
def getDir():
dir = askdirectory()
return dir