I have made small application, which has list on left side of the window
and right side of the window has content, which reflects the choice that
user has made from list.
(http://jylitalo.homeip.net/~jylitalo/phojo-photo.png)

When user gets this view, one of the items from list should be shown as
selected. I've manage to get everything look proper, when list is shown
to user. Things go wrong, when user makes his first selection from list,
something goes wrong, because selectFromTree (which is associated to
'changed') is first called on first item of the list and once that event
has been handled, then selectFromTree is called second time and this
time it gets proper information in select attribute. When user does 2nd,
3rd, ... selection in that list, all works beatifully, but still that
funny behaviour on first selection is something that I'd like to get
fixed in my code.

If someone has any ideas, where things are going wrong, I'd like to hear
about it. I guess the actual selection should somehow be done in
ListStore, but I haven't been able to figure out, how that could be
done. My current solution is something like this:

model = gtk.ListStore(gobject.TYPE_STRING)
select = None
number = 123
for element in self.factory.elements():
    iter = model.append()
    num = self.__getPhotoNumber(element.getNumber())
    model.set_value(iter, 0, num)
    if number == element.getNumber(): 
        select = model.get_path(iter)

tree = self.wtree.get_widget(widget)
tree.set_model(model)
cell = gtk.CellRendererText()
treecol = tree.get_column(0)
if treecol: tree.remove_column(treecol)
column = gtk.TreeViewColumn(colname, cell, text=0)
tree.append_column(column)
selection = tree.get_selection()
selection.set_mode('single')
if select: selection.select_path(select)
selection.connect('changed', self.selectionFromTree)
[end of quote]

-- 
Juha Ylitalo                 [EMAIL PROTECTED]                    <e-mail>
+358 40 562 6152 <mobile>    http://www.iki.fi/jylitalo         <www>
"Some tools are used, because its policy, others because they are good."
_______________________________________________
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