Skip to content
Advertisement

Tkinter opens the Filedialog twice to take the File

I have two functions CheckOs and _get_keyfile as below:
1:CheckOs(without considering Mac)

JavaScript

2:_get_keyfile

JavaScript

the problem is when ever _get_keyfile Function is executed it opens the File Dialog to select the file but opens again after I select the file and the file is selected after the second time. The problem only persists on Windows on Linux its working fine.
I want to know if I am doing something wrong or is that a bug in Tk .Any help Appreciated

Advertisement

Answer

In the _get_keyfile function change the function to include a else after the if to avoid opening dialog box. If it’s not a Linux OS

JavaScript

As a result the dialog box will only pop-up one time
Happy Coding!

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement