All My Brain Where stuff from my brain lands

June 27, 2009

Launching wxPython apps with an iPython shell

Filed under: Programming — Tags: , , , , — Dennis @ 12:52 pm

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.


> ipython -wthread
> # application runs here
> # no shell yet
> # you exit the application
"Welcome to iPython"

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

> ipython -wthread
"Welcome to iPython"
>>> import myapp
# application loads
# you instantly have a prompt


Tell iPython to launch your app after it starts:

> ipython -wthread -c "import myapp" -i
# app loads
"Welcome to iPython"
# you've got a shell

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.

September 6, 2008

Custom Derived Classes for wxPython XRC resources

Filed under: Programming — Tags: , , , , , , , — Dennis @ 4:18 pm

First of all, this isn’t a topic that is bran new or which requires new documentation. I have learned a few quirks about the process for creating custom controls, panels, frames, and other elements with XRC files in wxPython and I thought I’d write up a little post.

Let me point you to the two most important resources. The wxPython wiki has pretty much all you need to now to get started. First is the TwoStageCreation process that the XRC implementation uses to create classes. The second is the UsingXmlResources page.
There is also the XRCTutorial. But you should be past that if you’re trying to create custom controls.

Here is a summary of the basic process. (more…)

Powered by WordPress

%d bloggers like this: