Skip to content

Weird problem when calling tkinter.filedialog.askdirectory() by VBtn.Click #457

Closed Answered by Brandon-Xu
Brandon-Xu asked this question in General
Discussion options

You must be logged in to vote

sorry, I didn't describe it clearly enough, I want this function to be called by clicking the button
but I solved the problem myself, In fact, the window was opened successfully,
but it was covered under other program windows, which made me think it was not successful.

This is my improved code

_root = tkinter.Tk()
_root.withdraw()

def ask_directory():
    _root.lift()
    _root.attributes("-topmost", True)
    directory = filedialog.askdirectory()
    if directory:
        return directory
    else:
        return None

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Brandon-Xu
Comment options

Answer selected by Brandon-Xu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants