I ran into some strange behavior that I believe couldnt be right.

I start with a few items in a ListStore and a TreeView showing them.
I pack the view in a frame and pack that in my main vbox.
Display everything.
Two buttons - one removes the frame from the vbox and the other attempts to
look at the model associated with the view. The model seems to disappear
after removing the frame containing the view from the vbox. There is no
reason for this to happen. The view still exists and is accessible; dont
know why the model went away. Here's my test code for this issue:


-- import gtk, gobject

class Test(object):
    def __init__ (self):
        w = gtk.Window ()
        w.connect ("delete_event", gtk.main_quit)

        vbox = gtk.VBox ()
        w.add (vbox)

        model = gtk.ListStore (gobject.TYPE_STRING)
        model.insert (0, ('bar',))
        model.insert (0, ('baz',))

        self.model = model

        view = gtk.TreeView (model)
        column = gtk.TreeViewColumn ()
        view.append_column (column)
        cell = gtk.CellRendererText ()
        column.pack_start (cell, True)
        column.add_attribute (cell, 'text', 0)

        frame = gtk.Frame ('foo!')
        frame.add (view)
        vbox.add (frame)

        remove_btn = gtk.Button ('Remove')
        remove_btn.connect ('clicked', self.remove)
        vbox.pack_end (remove_btn)

        test_btn = gtk.Button ('Test')
        test_btn.connect ('clicked', self.test)
        vbox.pack_end (test_btn)

        self.view = view
        self.vbox = vbox
        self.w = w

    def main (self):
        self.w.show_all ()
        gtk.main ()

    def remove (self, *args):
            child1 = self.vbox.get_children () [0]
            self.vbox.remove (child1)

            print 'REMOVING'
            print self.view.get_model ()
            print 'END REMOVING'

    def test (self, *args):
        print "TESTING"
        print self.view.get_model ()
        print "END TESTING"

t = Test ()
t.main ()

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

Reply via email to