查看本页底部的示例: 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/