Launching wxPython apps with an iPython shell

Suppose you want to run your fancy wxPython application but have a shell in the background to peek and poke at certains settings, help debug, and possibly even use an API that your program provides to automate tasks. iPython has built in wx support (as well as support for other GUIs and frontends). So anyway, I've been playing around with this lately and have noticed an inconsistency that needs addressed.

Launching other GUIs with iPython does not block. You instantly get a shell and your application loads. The "-wthread" option for wx applications executes any passed in script before dropping to the shell though.

Problem:

  1.  
  2. > ipython -wthread myapp.py
  3. > # application runs here
  4. > # no shell yet
  5. > # you exit the application
  6. "Welcome to iPython"
  7. >>>
  8.  

If you happened to do things like this, you'd get the expected response:

  1.  
  2. > ipython -wthread
  3. "Welcome to iPython"
  4. >>> import myapp
  5. # application loads
  6. # you instantly have a prompt
  7. >>>
  8.  

Solution:

Tell iPython to launch your app after it starts:

  1.  
  2. > ipython -wthread -c "import myapp" -i
  3. # app loads
  4. "Welcome to iPython"
  5. # you've got a shell
  6. >>>
  7.  

Anyway, for other threading backends in iPython, the shell doesn't block while the application loads. Perhaps there is a way to get the wx backend to behave the same. In the mean time, I'm using this workaround without any serious issue. Perhaps I'll find a better solution or submit a patch to iPython one of these days.

  1. No Comments



css.php