'TKinter, pygubu - opening filedialog.askdirectory() hangs program

I'm building an application using tkinter (and pygubu, this is relevant). In my application I need to browse a directory. This is the code of a button click callback (it's just inserting the path of the directory in a textbox object.

def chose_folder(self):
    folder = fd.askdirectory()
    txt = self.builder.get_object('folder_txt')
    txt.delete(0, tk.END)
    txt.insert(0, folder)

I've tried this code on Linux Mint 20.2, and it works fine, but on Windows 10, when I click the button, the program hangs and need to be forcibly terminated. However, if I change fd.askdirectory() with fd.askopenfilename(), or literally any other type of dialog, it works fine. The main difference I can see is that on linux, tkinter uses a custom dialog, while on Windows is uses the native Windows Explorer dialog.

Weirdly enough, I tried this minimal code

from tkinter import *
from tkinter.messagebox import *
from tkinter import filedialog as fd

file_name = fd.askdirectory()
print (file_name)

and it works perfectly, so I'm guessing the problem must be that I'm using pygubu to design the ui, but I can't figure out where the problem precisely is. I've found some old issues about this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source