On 10/17/2009 11:08 PM, Lars Wirzenius wrote:
> la, 2009-10-17 kello 17:16 -0700, Daniel B. Thurman kirjoitti:
>   
>> In my application, I am populating a treestore with
>> new children, I then use the following method:
>>
>> self.treeview.set_mode(treestore)
>>
>> Apparently the treeview does not show expanders
>> where there are new children.
>>
>> Is there something I need to do to show the expanders?
>>     
> You should only need to add children to the model. Perhaps there's some
> unrelated problem. Could you distill the program to be as small as
> possible while still showing the problem?
>   

Thanks for looking into this Lars!

If you wish to see the entire code, see the attachment below,
Otherwise pseudo code is listed below:

[...]
DEFAULT_PATH='~'
RECURSE=1
[...]

Class FileLister()

    def __init__(self, path=None):

        # Create a new window
        [...]

        # Create TreeStore & TreeView
        self.treestore = gtk.TreeStore(str, gtk.gdk.Pixbuf, int, bool, str)
        self.treeview = gtk.TreeView(self.treestore)

        # Set TreeView Options
        [...]

        # Set TreeView Columns
        [...]

        # Set TreeView Signals
         self.treeview.connect('row-activated', self.on_row_activated)
         self.treeview.connect('row-expanded', self.on_row_expanded)

        # Populate the TreeStore with initial data
        self.path = os.path.expanduser(DEFAULT_PATH)
        self.dir_walk(path=self.path, recurse=RECURSE)
        self.dump_treestore()

        # Add Scrolled window with TreeView Object
        [...]

        # Show Window
        [...]

    def dir_walk(self, path, parent=None, recurse=RECURSE):
        # Populate TreeStore with additional (unique) data
        [...]

    def on_row_expanded(self, treeview, iter, path):
        # PROBLEM:
        # (1) Adding in new children data does not enable expanders
        model = treeview.get_model()
        filename = model.get_value(iter, 4)
        self.debug("File     : row_expanded(): %s" % filename)
        ts = self.dir_walk(filename, parent=iter, recurse=RECURSE)
        treeview.set_model(ts)                 # <== Expanders do not
work for new children!
        treeview.expand_row(path, True) # <== Does not seem to work

        return
[...]

Kind regards,
Dan

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to