On Mon, Feb 24, 2003 at 06:10:26PM -0500, Rob Landley wrote: > I'm getting an attribute error trying to call anything on the Event object > passed to me. I tried dumping a __dict__ and that isn't there either. > > The wrapper doesn't make SENSE, in any case. The logic of get_coords would be > that a python method call was modifying its (integer) arguments, which is > remarkably un-pythonic. (Pass it a mutable list, sure. But that's not what > it claims should be happening.) Maybe the C bindings can do this, but ouch.
How do you know the wrapper doesn't make sense if you couldn't get it to work? Most of the C idioms used in GTK are mapped to their Python equivalent idiom. Overall, PyGTK has a pretty good setup. > > Here's some sample code showing things I've tried, which didn't work. In the future, if you have a short code snippet just append it to the body of your message. Attachments are a pain and not easily quotable. You must create a mainloop, by calling gtk.mainloop(). Your iteration loop has two major problems. The first one is that you haven't properly initialized the GTK+ mainloop which is causing you all kinds of grief. GTK+ will complain about this only when you call certain functions, notably gtk.mainquit() (which usually exists somewhere in every program). The second problem is that your while loop never sleeps and imposes 100% CPU load. This is unacceptable because it will suck the life very quickly out of any battery powered device (laptop users will hate you). It also is unnecessarily unfair to lower priority processes. In otherwords, your example has no need for gtk.mainiteration(). gtk.mainiteration() is generally used when you are performing some long process and want to periodically flush the gtk event queue. You can use something like this: while gtk.events_pending(): gtk.mainiteration() Rarely does one use gtk.mainiteration by itself in a loop, and never in an unconditional loop. Getting that taken care of you should find that the GdkEvent object (that you name b in your signal handler) has a get_coords function. The get_coords function returns the coordinates as a tuple, which seems to be as Pythonic as one could ask for. --jkl _______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
