Re: Need help to set a cursor/focus on treeview row!



On 10/30/2009 05:48 PM, Daniel B. Thurman wrote:
I am learning, so please bear with me!

I have the following code:

    def expandHome(self, model, iter=None, defaultHome=None):
        ''' expand user's home directory '''
        if not defaultHome:
            return
        ran = model.iter_n_children(iter)
        for i in range(ran):
            iter_n_child = model.iter_nth_child(iter, i)
            path = model.get_path(iter_n_child)
            pn = model[path][1]
            idx = defaultHome.find(pn)
            if idx > -1:
                Dbg.dPrint(" + File=%s" % pn)
                StoreTools.append_path(model, iter=iter_n_child)
                Display.tv.expand_row(path, False)
                self.expandHome(model, iter_n_child, defaultHome)
        # Set cursor selection to the homepath here
        Display.tv.set_cursor(path, focus_column=None, start_editing=False)

The treestore is saved into a treeview, and the
treeview is saved into a scrolledwindow.

The above code expands the treeview on the user's
home directory and it works, and the last step is to
set the cursor or focus on the user's home directory
of which I am not able to do.  The code:

Display.tv.set_cursor(path, focus_column=None, start_editing=False)

is a feeble attempt to do that and it is not working for
me.

Please advise?
  
I wanted to add a bit of clarification.  The goal is that once
the user's home directory is expanded, I wanted to bring the
expanded tree of "/home/some-user" into view in the scrolled
window, centered, so I may have the wrong method entirely.

Thanks!
Dan




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]