Function to fin out if code is currently running in dedicated or in Spyder's interactive console

23 views
Skip to first unread message

Markus Hofinger

unread,
Jul 7, 2015, 2:29:50 PM7/7/15
to spyd...@googlegroups.com
Hi!

I wanted to ask if it is possible to determine within a written code if this code was started in the current Python/IPython console of Spyder or if it was run in a dedicated console.
This makes a difference for Qt-GUI development.


For example, during GUI development phase, I like the interactive shell, as it allows me to directly interact with my GUI and its elements.
This however only works if I do NOT start the PyQt event loop at the end (sys.exit(app.exec_())   )
I guess the only reason this works at all, is because Spyders Console is written in Qt as well ;-)
However it is extremely useful during developement as it allows code completion, immediate try outs etc.

But if I run the same code in a dedicated shell, the GUI only shows up shortly and immediately vanishes, as the eventloop is not running.

So what I am looking for is something like:
  if  not <SpyderfunctionThatTellsMeIRunInSpydersInteractiveConsole>:
    sys.exit(app.exec_())


Dos this exist, or is it possible?
Regards, and thank you :)
Max
Reply all
Reply to author
Forward
0 new messages