[IPython-dev] [Enthought-Dev] Ctypes based prototype of PyOS_InputHook for wx 2.8 and 2.9

Ondrej Certik ondrej at certik.cz
Fri Jul 17 01:27:51 EDT 2009


On Thu, Jul 16, 2009 at 11:11 PM, Ondrej Certik<ondrej at certik.cz> wrote:
> On Thu, Jul 16, 2009 at 4:42 PM, Robert Kern<rkern at enthought.com> wrote:
>> On Thu, Jul 16, 2009 at 17:26, Brian Granger<ellisonbg.net at gmail.com> wrote:
>>> Hi,
>>>
>>> I am attaching a working ctypes based prototype of a module that allows wx
>>> to be used interactively from *both* python and ipython.  It uses
>>> PyOS_InputHook and has been tested on wx 2.8 and 2.9 (trunk) on Mac OS X
>>> (python 2.5).
>>>
>>> It can be used with an existing wx install and all versions of ipython, but
>>> ***don't use the -pylab or -wthread flag***.  At this point, I need help
>>> testing the heck out of this (window and linux users esp).  I have run most
>>> matplotlib pylab_examples and they work fine.  I also need people to try out
>>> things like ETS/Mayavi.  The current plan is to replace the existing
>>> threaded shells in IPython with this (much simpler) code.
>>
>> Works for me with wx 2.8.8.1 on OS X 10.5 and Chaco. Pan and zoom
>> interactions are substantially chunky, though. I do not see such
>> chunkiness with -wthread. It would be worth exploring a Cython
>> alternative to see if it is just ctypes and general Python overhead to
>> blame.
>
> Works for me on Ubuntu 9.04 with default packages (wx 2.8.9.1), I
> tried this example:
>
> In [1]: import inputhook
>
> In [2]: inputhook.set_inputhook_wx()
>
> In [3]: app = wx.App(redirect=False, clearSigInt=False)
> ---------------------------------------------------------------------------
> NameError                                 Traceback (most recent call last)
>
> /home/ondrej/Desktop/<ipython console> in <module>()
>
> NameError: name 'wx' is not defined
>
> In [4]: import wx
>
> In [5]: app = wx.App(redirect=False, clearSigInt=False)
>
> In [6]: from matplotlib import pyplot as plt
>
> In [7]: plt.interactive(True)
>
> In [8]: plt.plot(range(10))
> Out[8]: [<matplotlib.lines.Line2D object at 0x3917090>]
>
>
> (maybe you want to add "import wx" into that example docstring)
>
>
> Pan is perfectly smooth, zoom is a bit chunky, but not much, it's
> definitely usable.

I also tested mayavi, this demo:

http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/mlab.html#a-demo

and I didn't notice any speed difference --- e.g. it's as slow as
regular mayavi with ipython -wthread. :)

Ondrej



More information about the IPython-dev mailing list