Wouter
Wouter

Reputation: 2653

python GtkComboBox.remove_all(): how to prevent changed signal to be triggered

I have designed a gtk3 layout with Glade, including some comboboxtext widgets.

The bookings_tour_selector ComboBoxText has the changed signal connected, so when user selects an option, this is detected. That part works fine.

Now the problem, when I make the call: bookings_tour_selector.remove_all() the changed signal is triggered once for every single item being removed. That's not the expected behaviour. I expect it to not trigger the signal at all.

How to prevent this signal to be triggered when removing items?

Upvotes: 0

Views: 218

Answers (1)

luciomrx
luciomrx

Reputation: 1195

Just add conditional in your callback, i.e:

def on_changed_combobox (self, widget):
    if self.bookings_tour_selector.get_active () != -1:
        #do whatever you want when combo box changed
        #if not, it simply, does nothing

Upvotes: 0

Related Questions