I realized I had two buttons that both need to be unsensitive when
there's no selection, and having two connect lines each making their
own lambda seemed really inefficient, so I refactored it into this:

def selection_changed(self, selection, data=None):
        sensitivity = selection.count_selected_rows() > 0
        self.apply_button.set_sensitive(sensitivity)
        self.delete_button.set_sensitive(sensitivity)

...

self.treeview.get_selection().connect("changed", self.selection_changed)

Thanks!


On Tue, Aug 31, 2010 at 3:43 AM, Timo <[email protected]> wrote:
> I always do it like this:
>
> self.selection = self.treeview.get_selection()
> self.selection.connect('changed', self.selection_changed)
>
> def selection_changed(self, selection):
>    model, tree_iter = selection.get_selected()
>    if tree_iter is None:
>        self.apply_button.set_sensitive(False)
>    else:
>        self.apply_button.set_sensitive(True)


-- 
http://exolucere.ca
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to