python - PyGtk3,切换按钮, "toggled-or-untoggled"事件

标签 python pygtk

我知道“切换或未切换”事件不存在,但我需要使用这样的事件。当按钮“切换”和“未切换”时是否有执行任务的事件。我不想使用“clicked”事件,因为 ToggleButton 可以在不单击的情况下切换或取消切换 谢谢

示例

def foo(obj):
    if obj.get_active():
        print("toggled")
    else:
        print("untoggled")

mybtn = gtk.ToggleButton()
mybtn.connect("toggled-or-untoggled", foo)

最佳答案

根据the docs -

When the state of the button is changed, the “toggled” signal is emitted.

因此,理想情况下,mybtn.connect("toggled", foo) 应该可以工作。

关于python - PyGtk3,切换按钮, "toggled-or-untoggled"事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43436021/

相关文章:

python - "Manually"在 gtk.DrawingArea 上调用暴露事件

python - 使用 ElementTree 读取 .xml 等电子表格

python - 在 Ubuntu 14.04 上设置 Spyder 以使用 Anaconda python

python - 禁用 gtkbutton 的发光效果

widget - 使用 GTK3 编写自定义小部件

Python、线程和 gobject

python - 如何更改 GTK 中的字体大小?

python - pandas 在 DatetimeIndex 转换时引发 ValueError

python - 匹配 uuid.uuid4().hex 生成的值的正确正则表达式是什么?

python - 新线程阻塞主线程