Well, you are doing things in an expose event that are better handled
somewhere else.  Here's how I fixed your example (moved some code to a
"realize" event handler):

--- test-orig.py        2003-12-10 16:06:28.000000000 +0000
+++ test.py     2003-12-10 16:06:12.000000000 +0000
@@ -21,6 +21,7 @@ class DrawingArea:
 
         self.box1 = gtk.HBox(gtk.FALSE, 10)
         self.area = gtk.DrawingArea()
+       self.area.connect("realize", self.area_realize_cb)
 
         self.Xoffset=150
         self.Yoffset=150
@@ -44,9 +45,16 @@ class DrawingArea:
         self.boxV.show()
         window.show()
 
+    def area_realize_cb(self, area):
+        self.style = self.area.get_style()
+        self.gc = self.style.fg_gc[gtk.STATE_NORMAL]
+        font_desc=pango.FontDescription(self.lab_font)
+        self.area.modify_font(font_desc)
+        self.gc.foreground =self.area.get_colormap().alloc_color("black")
+        gc.collect()
+
     def area_expose_cb(self, area, event):
       """ Call update of the ld area on the screen """
-
       if self.__area_expose_cb_lock: return gtk.TRUE
       else:
         self.__area_expose_cb_lock = gtk.TRUE
@@ -62,12 +70,6 @@ class DrawingArea:
         Xlegend_size=self.Xleg
         Ylegend_size=Yarea_size
 
-        self.style = self.area.get_style()
-        self.gc = self.style.fg_gc[gtk.STATE_NORMAL]
-        font_desc=pango.FontDescription(self.lab_font)
-        self.area.modify_font(font_desc)
-        self.gc.foreground =self.area.get_colormap().alloc_color("black")
-        gc.collect()
       self.__area_expose_cb_lock = gtk.FALSE
       gc.collect()
       return gtk.TRUE



A Qua, 2003-12-10 �s 15:34, Jean-Baptiste Cazier escreveu:
> Hi again !
> 
> Despite the many e-mails and suggestions I received, nothing has solved my problem 
> so far.
> So, I stripped down my program to some essentials to show you the problem I am 
> running into:
> 
> The script below does nothing, but consumes 95% of my CPU !
> If I comment out the line 
> 
>         self.area.modify_font(font_desc)
> 
> Then the CPU usage drops to the expected 0.1%
> 
> Can anybody find the reason ?
> Once again the pygtk and python version I am using on my redhat 9.0 box are the 
> following

-- 
Gustavo Jo�o Alves Marques Carneiro
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]>


_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to