How do I stop Pyzo from calling mainloop?

Question:

I used to use the Interactive Editor for Python, and then I “upgraded” to Pyzo (since IEP was merged into Pyzo). One of my programs uses tkinter to create a GUI. The code used to work just fine: I would run the file as a script, and then, in the interpreter, I would call main, which would launch the application.

The code skeleton looks like this.

def main():
    class Application(tk.Frame):
        def __init__(self, master=None):
            # a bunch of stuff
        # several more methods here

    front=Application()
    front.mainloop()
# then I can either call main in the interpreter, or I can add this:
# the name==main part is to handle some multiprocessing that occurs within the application class
if __name__=="__main__":
    main()

This worked like a charm in IEP. However, in Pyzo, main() never launches, or, rather, it launches, but the gui never appears and it doesn’t let me do anything. Instead, I get this message: Note: The GUI event loop is already running in the pyzo kernel. Be aware that the function to enter the main loop does not block.

This message occurs in Pyzo when I am using the CPython 3 or PyPy interpreter, but not when I’m using Anaconda 3 (I actually need to use PyPy because the work I’m doing is computationally expensive).

The other alternative is to not use Pyzo, but that’s no fun.

Asked By: Alpha Bravo

||

Answers:

I discovered the answer a while ago but I didn’t get back to posting the answer until now. Essentially, there is a setting in Pyzo itself which attempts to detect GUIs. Switching that setting from auto to none fixed the problem.

Answered By: Alpha Bravo

Just to add precision to Alpha Bravo’s answer : in the "Shells" pane, go to "Edit Shell Configurations…", next to "gui", select "None – no GUI support".

Answered By: Maelinho
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.