On Apr 5, 2007, at 1:20 PM, Ken McIvor wrote:

> On Apr 5, 2007, at 2:14 PM, belinda thom wrote:
>>
>> I do think its valuable to be able to write a blocking mouse
>> function. After your pointer to Timer (which led me to the threading
>> Python library) and idle handler (which I didn't find useful doc on,
>> so didn't persue), I came up with the code I'll append below. My
>> printing of time elapsed seems to imply the thing is working as I'd
>> expect (I see times that differ by about 1 second). Problem is, I
>> still get the twirling wheel of deadness on my Mac that led me to
>> post my original message.
>
> You will probably always have this problem when you do things that  
> prevent the GUI's event loop from running.

Hmmm. Makes sense. I'll include a tidbit from Chris that I received  
via personal email b/c it relates:

------
Thinking about your issue a bit -- the problem here is that MPL does  
not provide an event loop. In Matlab, the command line and figure   
windows share an event loop. In MPL, the event loop is provided by  
the hosting GUI toolkit, and is separate from command line event  
loop. For that reason, MPL itself is a bit divorced from the process.  
That why Ken and I have suggested that you'd be better off embedding  
MPL in a gui toolkit, if it's just the kind of plotting you need, or  
using another drawing widget in a GUI toolkit if you really need non- 
plotting type drawing.

If it hadn't been for the bugs, TK probably would have been a fine  
option for you.
---------

> Are you running your code from within iPython or as a script?
>
>> And then I got Chris's great reply, which makes me wonder if I'm
>> trying to do too much.
>
> I'd have to agree with Chris that you are trying to do too much  
> from within pylab.

Darn. I am writing this reply as a desperate attempt to make sure  
there's not some quick fix to make it work in my specific case; I'm  
about ready to give up or try something like Tk, but am running out  
of time. We might, alas, have to settle for a command-line based  
game :-(.

So, how do the above observations relate to John Hunter's  
recommendation that I use a timer or idler? It was the reply from him  
that led me to think I might be able to come up w/something that  
worked w/o too much dorking.

>> I've been using pyrorobotics, which relies heavily on Tk, but their
>> plotting facilities are not great. So I started using matplotlib and
>> really like it. And I ran into problems w/their Tk interface where
>> windows wouldn't update correctly on the mouse unless the mouse was
>> clicked in the window. Found some stuff via google implying this was
>> some nasty bug on Mac, didn't find an easy work around, so now try to
>> use matplotlib whenever possible, which explains my current path to
>> trying to use it to provide a simple graphic interface to a python
>> Connect 4 game that I wrote so my students can have fun writing
>> "smart" game players in my AI course.
>
> If that's what you're aiming for you'd probably be happier with the  
> result if you write something using Tkinter's Canvas or the  
> wxPython FloatCanvas.

Understood. If I could get something working really quickly, I might  
go that route. But it would have to take a few hours tops, and that  
would include me figuring out how to get in mouse clicks and draw  
graphics.

>> In Matlab, I'm used to building applications, so I was hoping it
>> would be possible to do something similar in matplotlib.
>
> Well, it's entirely possible to build applications that use  
> matplotlib.  The thing to remember is that matplotlib isn't its own  
> programming language or development environment -- it ties Python  
> and and bunch of libraries together to provide a Matlab-like  
> interface in the 'pylab' module.

Fair enough. Thanks for the valuable observation.

>
>> Perhaps matplotlib is not currently set up for such things (in  
>> which case I'd
>> like to ask if this is something you'd like to include in the  
>> future).
>
> Although I'm matplotlib is going to continue becoming more powerful  
> and flexible, I'd personally be surprised if that ever becomes one  
> of the project's goals.  I obviously can't speak for anyone else,  
> but it seems to me that people who want to build GUI applications  
> using matplotlib should be doing so by using matplotlib from within  
> Python.  I also suspect that the engineering effort involved in  
> making this functionality happen might be beyond the scope of the  
> project.

Ditto.

Thx,

--b

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to