Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why we should return True in the end of button_press_event.handler?

Tags:

python

gtk

gdk

Look at the example in the bottom of this page: http://www.pygtk.org/pygtk2tutorial/sec-EventHandling.html it says:

   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

So, for what there are "return True"?

like image 819
scythargon Avatar asked Nov 29 '25 09:11

scythargon


1 Answers

You should read the introductory chapters of the same tutorial you linked to. For example, chapter 2.3 describes events and says what the return value is.

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.

like image 188
tinman Avatar answered Dec 01 '25 23:12

tinman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!