【问题标题】:python GtkComboBox.remove_all(): how to prevent changed signal to be triggeredpython GtkComboBox.remove_all():如何防止改变的信号被触发
【发布时间】:2014-07-12 16:47:53
【问题描述】:

我用 Glade 设计了一个 gtk3 布局,包括一些组合框文本小部件。

bookings_tour_selector ComboBoxText 连接了changed 信号,因此当用户选择一个选项时,会检测到这一点。这部分工作正常。

现在的问题是,当我拨打电话时:bookings_tour_selector.remove_all()changed 信号会为每个被删除的项目触发一次。这不是预期的行为。我希望它根本不会触发信号。

如何防止移除物品时触发此信号?

【问题讨论】:

    标签: python gtk3


    【解决方案1】:

    只需在回调中添加条件,即:

    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
    

    【讨论】:

    • 简单有效:) 谢谢
    猜你喜欢
    • 2011-04-03
    • 2017-07-05
    • 2021-03-02
    • 2015-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-23
    相关资源
    最近更新 更多