python - 为什么我们要在 button_press_event.handler 的最后返回 True?

标签 python gtk gdk

查看本页底部的示例: http://www.pygtk.org/pygtk2tutorial/sec-EventHandling.html 它说:

   57   def button_press_event(widget, event):
   58       if event.button == 1 and pixmap != None:
   59           draw_brush(widget, event.x, event.y)
   60       return True

那么,为什么会有“return True”呢?

最佳答案

您应该阅读您链接到的同一教程的介绍性章节。例如,chapter 2.3描述事件并说明返回值是什么。

The value returned from this function indicates whether the event should be propagated further by the GTK+ event handling mechanism. Returning True indicates that the event has been handled, and that it should not propagate further. Returning False continues the normal event handling. See Chapter 20, Advanced Event and Signal Handling for more details on this propagation process.

关于python - 为什么我们要在 button_press_event.handler 的最后返回 True?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11576130/

相关文章:

window - 如何获得 Gdk.Window 任务图标或标题?

c++ - 通过 GdkPixbuf 绘图绘制在错误的像素坐标

c - 体系结构 x86_64 : "_g_object_unref" 的 undefined symbol

python - 如何获得 dummies 和 groupby

python - 使用 pycrypto (RSA) 签名和验证数据

python - 尝试在下载的 Cython 目录中安装 Cython : no setup. py

windows - Windows 上的 Python + webkit + gtk

python - 有没有办法在 Windows 中不加载 Python 来查看 cPickle 或 Pickle 文件内容?

c - 如何在 C 中获取应用程序路径?

python - 如何在 Python/Gdk 中编辑 pixbuf 的像素