Re: [pygtk] Question about idle_add() and refreshing some widget..
On Sun, Sep 28, 2003 at 01:56:38PM -0300, alejandro david weil wrote: > I have a bitmap that is the background, and something like-sprites to draw. > I think that is better to draw sprites, in this way: draw them on a new frresh > bitmap than, remember what them have overwritten, draw that back and backup > the area that will be overwritten, and then, draw the sprite. I'm not sure this is the most efficient way to do animation in GTK+. Have the gtk-app-devel people given you any good ideas? > But now, It keeps being cpu consumer, I think that it's because is called > from idle callback, all the time (althought it's not drawing every time). May > be i must switch back to simple timeout callback instead of the idlebased. I think the timeout callback is the correct way to go -- your idle hack hasn't bought you anything, has it? > Here's the 'callback' code.. i'll promise to send complete code when it > be on a more.. decent state. ( do you understand spanish ? ) No, I understand the code and your approach perfectly. However, I think the real problem we're having is unrelated to the actual timeout process -- your draw/redraw seems to be too expensive. For instance: >>> import gtk >>> def foo(*args): ... print "CALLED" ... return gtk.TRUE ... >>> gtk.timeout_add(30, foo) >>> gtk.mainloop() Prints out a ton of CALLED messages, and yet the CPU usage never goes up. So it's not a matter of the frequency of calls, but rather your drawing that's too expensive. And I'm not the best person to advise you on drawing, since I've only played with GtkDrawingArea once, and it wasn't a pretty sight :-) Take care, -- Christian Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331 ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Question about idle_add() and refreshing some widget..
On Sat, Sep 27, 2003 at 07:36:29AM -0300, alejandro david weil wrote: > And also I'm not sure if using that is the right way to do the things. > Maybe this question is more gtk-related than pygtk. > > Well, anyway, I think that with idle&timeout implementation that > I did, the cpu wasting I have is constant when I draw more objects > on the DrawableArea.. You're right that this is more of a GTK+ question -- if you don't get an answer here, do try [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list If you raise the timeout interval, does the CPU usage go down significantly? Have you tried profiling your application to see what's costly? Take care, -- Christian Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331 ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] Question about idle_add() and refreshing some widget..
Hi! I'm making a program that has only a widget that's a GtkDrawingArea. In that widget I draw my own objects. Well, I want it to be refreshed as fast to produce some smooth efect in the objects that are moving inside. For drawing the objects inside i've put a expose callback function. And, until yesterday, I was using a timeout callback to queue a draw event. Timeout set to 30 ms. It was very cpu consuming. So I changed it, to queue draw events on a idle callback, if an update flag is set, and I set that flag from a timeout callback. Why? Because the idle loop was executed too many times, so I have this restricted to a timeout.. Well, at this point, the problem is that it keeps using too much cpu! :-) so, i don't know what should I do. I've seen that there are some gtk's idle_add_priority function, but I don't have that one in python-gtk2 2.0.0-1, debian's module. And also I'm not sure if using that is the right way to do the things. Maybe this question is more gtk-related than pygtk. Well, anyway, I think that with idle&timeout implementation that I did, the cpu wasting I have is constant when I draw more objects on the DrawableArea.. Well, that's all, thanks in advance! alejandro -- + There is no dark side of the moon really. Matter of fact it's all dark. ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/