为什么我们应该在button_press_event.handler的末尾返回True?

scy*_*gon 1 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
Run Code Online (Sandbox Code Playgroud)

那么,对于什么是"返回真实"?

tin*_*man 8

您应该阅读与之链接的相同教程的介绍性章节.例如,第2.3章描述了事件并说明了返回值是什么.

从此函数返回的值指示事件是否应由GTK +事件处理机制进一步传播.返回True表示事件已被处理,并且不应该进一步传播.返回False继续正常的事件处理.有关此传播过程的更多详细信息,请参见第20章,高级事件和信号处理.