-1

I'm using easygui in a Python app and then generate an .exe with PyInstaller.

Everything works fine in my computer, but my colleague get this weird error when they try to run the app :

Traceback (most recent call last):
File "easygui\boxes\button_box.py", line 95, in buttonbox
File "easygui\boxes\button_box.py", line 147, in __init__
File "easygui\boxes\button_box.py", line 268, in __init__
File "tkinter\font.py", line 23, in nametofont
File "tkinter\font.py", line 86, in __init__
RuntimeError: main thread is not in main loop

The line where easygui is called is simply

choice = easygui.buttonbox(
"msg", "title", choices=["choice1", "choice2"],
default_choice="choice1", cancel_choice="choice2"
)

so the problem seems to be with the font but I'm not using anything particular in easygui ? I've searched for issues on the easygui's Git but couldn't find anything

Also, there was another easygui.buttonbox earlier in the process but this one did show up properly so I'm just really confused.

Thanks!

  • 1
    That can't be the entire traceback. It doesn't even show the error. Please show the entire traceback. – Tim Roberts Dec 14 '22 at 18:26
  • @TheLizzard that's what I understand too, but why does it occurs ? I have no problem with this on my computer, another collegue has no problem but then this one has the problem. And the application is packaged with PyInstaller so it's not like we have different Python environement – Geneviève Le Houx Dec 14 '22 at 18:39
  • What's the order of operations? The message text is fairly clear. It believes that the Tkinter main loop is not running, or has exited. – Tim Roberts Dec 14 '22 at 18:40
  • @TimRoberts the easygui.buttonbox is indeed called from a thread in QRunnable, but it's not the only place I call something from easygui in a separate thread. But only this one instance fails – Geneviève Le Houx Dec 14 '22 at 18:43
  • 1
    You CANNOT do GUI stuff from a separate thread. That is a golden, rock solid, universal rule for ALL of the major GUI frameworks. You must use something like `root.after` to have your function called in the main thread. Remember that message queues are associated with a thread. If you send a message from a second thread, there is no one who is looking for messages to dispatch them. – Tim Roberts Dec 14 '22 at 19:03
  • @TimRoberts thanks, I fixed this and it seems to have solved my problem. I still don't understand why it crashed only on one computer and not the other but you're right – Geneviève Le Houx Dec 20 '22 at 16:33

1 Answers1

2

The solution was to show the msgbox in the main thread. It crashed because the msgbx was in a different thread than the main one