Python : Get gtk.treeview selection from another widget -


it looks way selected item of gtk.treeview() click on :

    tree_selection = self.treeview.get_selection()     tree_selection.connect('changed', self.my_callback)     self.treeview.connect('row-activated', self.my_other_callback) 

but if i'm listing files in treeview, , need "file properties" menu item? or play button, needs access selected file pass filename player class / method ?

bonus question : how call my_other_callback tree_selection.connect('changed', ...) (that not seem return row data..?) or in other words, how pass treeview , path callback?

to selection of tree view, call the get_selected_rows method of gtk.treeselection object. can call @ place can access tree view.

it unclear why want pass tree view my_other_callback since it, being method on class, can access self.treeview. if want anyway, can add tree view (or other python object) additional argument connect:

tree_selection.connect('changed', self.my_other_callback, self.treeview) 

for finer-grained control of how callback invoked, use lambda:

tree_selection.connect('changed', lambda *args: self.my_other_callback(self.treeview)) 

this allows use same handler multiple signals without having declare handler accepting *args.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -