How to get the path of a special folder with tkinter

Viewed 21

Im trying to get the path as a variable using Tkinter but filedialog.askdirectory not working in Mac i get this error on finder

enter image description here

root = Tk()
root.title("title")

def select_dir():
    
    filepath=filedialog.askdirectory(initialdir="/Users/userx/Documents")
    
   

mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)

v1 = StringVar()
v1_entry = ttk.Entry(mainframe, width=12, textvariable=rpu)
v1_entry.grid(column=2, row=1, sticky=(W, E))

v2 = StringVar()
v2_entry = ttk.Entry(mainframe, width=25, textvariable=razon_soc)
v2_entry.grid(column=2, row=2, sticky=(W, E))

ttk.Button(mainframe, text="Select folder", command=select_dir).grid(column=1, row=3, sticky=W)


ttk.Label(mainframe, text="name_v1").grid(column=1, row=1, sticky=E)
ttk.Label(mainframe, text="name_v2").grid(column=1, row=2, sticky=E)

for child in mainframe.winfo_children(): 
    child.grid_configure(padx=5, pady=5)

rpu_entry.focus()

root.bind("<Return>", select_dir)


root.mainloop()

also Im getting this warning

2022-09-10 00:57:28.395 python[1569:11380] Warning: Expected min height of view: (<NSButton: 0x7fb09add8d70>) to be less than or equal to 30 but got a height of 32.000000. This error will be logged once per view in violation.

Do you have any Idea why this is happening and how it can be solved??

0 Answers
Related