1 year ago

#236146

test-img

Amy

Is there a way to disable the top directory menu in the FileDialog in tkinter?

I have file dialog, where I click "open" it will open the filedialog. However, I need to restrict user to only select the files in current folder. How do I disable the top folder navigation menu option for the askopenfilename function? so they can't change the current folder

import tkinter as tk
from tkinter import filedialog as fd 

def callback():
    name= fd.askopenfile() 
    print(name)
    
errmsg = 'Error!'
tk.Button(text='Click to Open File', 
       command=callback).pack(fill=tk.X)
tk.mainloop()

tkinter

filedialog

0 Answers

Your Answer

Accepted video resources