On Sun, 5 Dec 2004 17:13:17 -0500 Thomas Mills Hinkle
<[EMAIL PROTECTED]> wrote:

> John -- I'd meant to cc this to the list initially. I still haven't
> succeeded in replicating the behavior in a smaller example, but I have
> confirmed that this is unique to pygtk 2.5 (I have another box with
> pygtk 2.4 where the problem does not occur). I'll post some decent
> example code as soon as I can replicate the behavior.

And here it is -- I finally tracked it down. The slowdown in appending
to a list store only occurs when the liststore is attached to a ComboBox
with set_wrap_width() set to something other than one. And it only
occurs with pygtk 2.5.  Here's a bit of code to demonstrate the bug.

Tom
import gtk, time

def debug (msg):
    print "DEBUG: ",msg," (",time.time(),")"

class SampleApp (gtk.Dialog):
    def __init__ (self):
        gtk.Dialog.__init__(self)
        self.key_model = gtk.ListStore(str)
        self.connect('destroy',lambda *args: gtk.mainquit())
        self.setup_boxes()
        self.button = gtk.Button('Add 1000 items')
        self.button.connect('clicked', self.add_1000_to_model)
        self.showbug = gtk.Button('set_wrap_width (showoff bugginess)')
        self.showbug.connect('clicked',self.set_wrap_width)
        self.action_area.add(self.showbug)
        self.action_area.add(self.button)        
        self.show_all()
        self.n = 0

    def set_wrap_width (self,*args):
        self.e.set_wrap_width(3)
    
    def setup_boxes (self):
        self.e = gtk.ComboBoxEntry()
        self.e.set_model(self.key_model)
        self.e.set_text_column(0)        
        comp = gtk.EntryCompletion()
        comp.set_model(self.key_model.filter_new())
        comp.set_text_column(0)
        entry = self.e.get_children()[0]
        entry.set_completion(comp)
        hb = gtk.HBox()
        hb.add(gtk.Label('Key'))
        hb.add(self.e)
        self.vbox.add(hb)

    def add_1000_to_model (self,*args):
        for n in range(self.n, self.n+1000):
            self.add_to_model("key%s"%n)
        self.n += 1000

    def add_to_model (self, str1):
        debug('looking in key_model')
        if not [str1] in self.key_model:
            debug('adding key')
            self.key_model.append([str1])
            debug('done with key!')


    

if __name__ == '__main__':
    sa = SampleApp()
    sa.run()
    gtk.main()
    
_______________________________________________
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