[SciPy-dev] gui_thread and chaco under Linux

Pearu Peterson pearu at scipy.org
Thu Oct 9 04:10:31 CDT 2003


Those who have not followed this thread or are not interested
in details, can skip until the end of this message where
instructions for how to use chaco.wxplt from Python prompt
under Linux (also Win32 should work but I haven't tested)
are given.

On Wed, 8 Oct 2003, Prabhu Ramachandran wrote:

> >>>>> "PP" == Pearu Peterson <pearu at scipy.org> writes:

>     PP> I took this challenge and here are intermediate results:
>     >>>> from parallel_exec import ParallelExec pexec=ParallelExec() #
> [snip]
>     >>>> app.shutdown()
>     PP> that is, I can already use chaco from my Linux prompt! And I
>     PP> have made no changes to chaco for that. The next step is to
>     PP> make
> Nice.  This looks to be similar to the code written for Gtk by
> someone.  IIRC it was available on ASPN.

You probably mean


that indeed has very similar basic idea.
The main difference with ParallelExec is that ParallelExec 
implementation is more generic and can be used also in non-GUI

>     >>>> from chaco.wxplt import * plot([1,2])
>     PP> safe...
> I'd think you'd need to modify or wrap around wxPython itself to get
> this to work that transparently or you'd need to do something similar
> to gui_thread.  

I have tried both ways, well, more or less. And they have different pros 
and cons, but the main difficulty in both cases is that both are too 
complex to be absolutely robust. IMHO, if the gui_thread module is not 
robust then we'll struggle with
  Xlib: unexpected async reply
type of crashes forever...

> Actually it looks like this could be easy to hack into wxPython.  Most
> of wxPython's work is done inside of a call to apply.  So if we
> quietly replace apply inside wxPython's namespace with a massaged
> apply that calls the real apply in the right thread, I think we should
> be all set.  This is a hack but if its this easy I guess Robin could
> be convinced to add cleaner support for it.
>   orig_apply = apply
>   def apply(o, *args, **kwargs):
>       pexec('orig_apply(o, *args, **kwargs)')
> I don't know if this will work with pexec the way its implemented
> currently but I think you get what I'm trying to say here.

Yes, I think it is a very good idea to try out. If there are not calls to 
wxPython functions during wxPython import then this should work just fine.
And using ParallelExec here should give no problems.
I'll check it..

In the mean time, scipy Linux users can already use chaco.wxplt functions
from Python prompt (just update scipy from CVS) as follows:

>>> import gui_thread
>>> execfile(gui_thread.__path__[0]+'/chaco_wxplt.py')
>>> f1=figure()
>>> p1=plot([1,2])
>>> f2=figure()
>>> p2=plot([3,4])


More information about the Scipy-dev mailing list