On Fri, Jul 11, 2008 at 03:22:30PM +0200, David M. Kaplan wrote:
> The way I have implemented it is by adding an additional class
> BlockingKeyMouseInput, which is quite similar to BlockingMouseInput, but
> waits for both key and mouse events.  A smarter person than I could
> probably combine these two classes and make something that would serve
> both functions.  But I am basically new to python and don't feel
> comfortable.  Perhaps someone else could take a look and make
> improvements/simplifications?

The only significantly different lines are the two lines where an
mplconnect is done to register the callback. You could abstract this in a
method and then have a base class and two sub classes for each call: the
blocking from mouse and the blocking from button.

> The other thing that I have noticed with both ginput and
> waitforbuttonpress is that if you use ctrl-c to break out of either,
> then the callback functions remain attached to their respective events
> (e.g., try ginput(n=-1,timeout=-1,verbose=True) and hit ctrl-c).  This
> probably isn't a huge problem, but it would be nice if there was a way
> to say "if ctrl-c is pressed, cleanup nicely".  Does someone know if
> that is possible?

I think this is a good usecase for a try: ... finally: ... .

I don't have time to do these changes right now, as I am very busy both
with IPython and Mayavi, and will be travelling next two weeks, but you
can have a good at them, and someone else will probably commit your
patch, if you removed the code duplication.

Cheers,

Gaƫl


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to