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

[lws25] ~/devel/ldraw $ rpm -qi pygtk2
Name        : pygtk2                       Relocations: (not relocateable)
Version     : 1.99.14                           Vendor: Red Hat, Inc.
Release     : 4                             Build Date: Thu Feb  6 17:02:08 2003
Install Date: Mon Sep  8 15:58:27 2003      Build Host: daffy.perf.redhat.com
Group       : Development/Languages         Source RPM: pygtk2-1.99.14-4.src.rpm
Size        : 1554008                          License: LGPL
Signature   : DSA/SHA1, Mon Feb 24 05:45:28 2003, Key ID 219180cddb42a60e
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Summary     : Python bindings for the GTK+ widget set.
Description :
PyGTK is an extension module for python that gives you access to the GTK+
widget set.  Just about anything you can write in C with GTK+ you can write
in python with PyGTK (within reason), but with all the benefits of python.

[lws25] ~/devel/ldraw $ rpm -qi python
Name        : python                       Relocations: (not relocateable)
Version     : 2.2.2                             Vendor: Red Hat, Inc.
Release     : 26                            Build Date: Tue Feb 25 00:25:21 2003
Install Date: Mon Sep  8 15:54:09 2003      Build Host: stripples.devel.redhat.com
Group       : Development/Languages         Source RPM: python-2.2.2-26.src.rpm
Size        : 16762750                         License: PSF - see LICENSE
Signature   : DSA/SHA1, Tue Feb 25 04:30:55 2003, Key ID 219180cddb42a60e
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL         : http://www.python.org/
Summary     : An interpreted, interactive, object-oriented programming language.
Description :
...




Thanks

Jean-Baptiste






#!/usr/bin/python 

import sys

import pygtk
pygtk.require('2.0')
import gtk
import gc
import pango



class DrawingArea:
    """ Class containing the Drawing area """

    def __init__(self):
        self.lab_font='Sans 10'
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
#        window.set_title("Linkage Disequilibrium Drawing")
        window.connect("delete_event",destroy)

        self.box1 = gtk.HBox(gtk.FALSE, 10)
        self.area = gtk.DrawingArea()

        self.Xoffset=150
        self.Yoffset=150
        self.Xright=20
        self.Yup=50
        self.Xbetween=50
        self.Xleg=150
        startsize=400
        self.winY=startsize+self.Yup+self.Yoffset
        self.winX=startsize+self.Xbetween+self.Xleg+self.Xoffset+self.Xright
        self.area.set_size_request(self.winX,self.winY)
        self.box1.pack_start(self.area, gtk.TRUE, gtk.TRUE, 0)
        self.__area_expose_cb_lock = gtk.FALSE
        self.signal_id=self.area.connect("expose-event", self.area_expose_cb)
        self.area.show()
        self.boxV = gtk.VBox(gtk.FALSE, 10)
        self.boxV.pack_start(self.box1,gtk.TRUE,gtk.TRUE,0)
        window.add(self.boxV)

        self.box1.show()
        self.boxV.show()
        window.show()

    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
        win=self.area.window
        X=self.winX 
        Y=self.winY
        Xarea_offset=self.Xoffset
        Yarea_offset=Y-self.Yoffset
        Xarea_size=X-self.Xoffset-self.Xright-self.Xbetween-self.Xleg
        Yarea_size=Y-self.Yoffset-self.Yup
        Xlegend_offset=Xarea_offset+Xarea_size+self.Xbetween
        Ylegend_offset=Yarea_offset
        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

def main(args=sys.argv[1:]):
    """ main routine to be called """

    DA=DrawingArea()
    gtk.main()
    return 0

  
def destroy(self, widget, data=None):
  print "Good Bye"
  gtk.mainquit()

if __name__ =="__main__":

    main()
-- 
-----------------------------
[EMAIL PROTECTED]

Department of Statistics
deCODE genetics     Sturlugata,8
570 2993          101 Reykjav�k

_______________________________________________
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