On 10/30/06, Gael Varoquaux <[EMAIL PROTECTED]> wrote:
> On Mon, Oct 30, 2006 at 10:36:09AM -0800, Christopher Barker wrote:
> > However, perhaps you can take advantage of a similar feature (at least
> > in wx) -- can you make the Frame Modal temporarily? My understanding of
> > how model dialogs work is that they stop the main event loop, and then
> > have their own event loop, for just that frame -- then you could catch
> > the mouse event you want, and make it non-modal again.
>
> I far as I have seen in ipython the execution of a script blocks the
> eventloop. Now in another shell if the shell is not aware of the event
> loop, calling show() will block until the windows is closed (that might be
> a good blocking call for my purpose). This leaves us with the case where
> the shell is a wx shell and lives in the eventloop. A wx guru would
> probably give us the solution here.

Jut to clarify, Gael: in ipython (with -pylab or -{g,w,q}thread), what
happens is that IPython lets the GUI toolkit run in the main thread,
and then attaches its own routines for user code execution as the
toolkit's idle timer callback and runs in a secondary thread (each
toolkit has its own way of doing this, but the basic idea is the
same).

The only blocking that you see comes from blocking code which your
scripts may call (typically extension code, C, Fortran, etc), since at
that point the Python interpreter can't switch out of this secondary
thread.  But as long as your scripts do NOT call any extension
blocking code, the Python interpreter will switch out every 100
bytecodes between your user code and the main thread.

This two-thread arrangement has a big drawback: the inability to
interrupt long-running calculations (even non-blocking ones) with
Ctrl-C, because it is simply impossible in Python to toss asynchronous
signals accross threads.  And yes, I've tried even using the
undocumented Python C-API for cross-thread asynchronous signals via
this recipe:

http://sebulba.wikispaces.com/recipe+thread2

I spent some time on this, unsuccessfully.  I still don't understand
why it doesn't work, since what I'm trying to do seems to be exactly
what that recipe is for.  If anyone ever gets this to work, *please*
send it to me.  It would be a major usability improvement to get
interruptibility of long computations in the threaded Pylab
environments (GTK, QT and Wx).  In fact, this is part of the reason
why I'm resisting a switch to Wx: I really hate not being able to
cleanly stop a computation that is taking longer than I meant, or
which I accidentally started.

Cheers,

f

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to