Il giorno sab, 05/09/2009 alle 12.22 +0200, M.B. ha scritto: > hi all, > im trying write my first custom widget. > its cairo slider. on my first look im happy :) but i know that code is > ugly. if this code running, Xorg is on 50% and python thread is on 49% > CPU !!!. ( using 'top' in console ). > Kick me to the right way with this code snipet pls. > where is error ? Why too much cpu power ? > > PS: sry for my english.
Your mistake is that you continuously redraw, since "expose" calls "queue_redraw" which (almost immediately) calls (it's its job) "expose". This way, you have live animation, but you spend _all_ the time drawing. And indeed, notice you aren't using at all events for mouse, which however you did register (with self.area.add_events)! For this widget, you need _two_ handlers: - a handler for expose which _just draws_ - a handler for pointer click and/or movement which updates self.old_y, and then calls queue_redraw bye Pietro
signature.asc
Description: Questa รจ una parte del messaggio firmata digitalmente
_______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
