FAQ Index - Search - Recent Changes - Everything - Add entry

<< Previous Entry | FAQ Entry 3.8 | Next Entry >>

3.8. I want my callback to execute, but not the default callback (or, how to I stop GTK from doing the default action when doing X)?

Many times, you are customizing behaviour of a widget, or changing a policy in GTK, and the default action it does it not what you want. To get around this, we rely on a fundamental point in GTK: that GTK, as well as applications, mainly uses signals to get things done in the interface.

The process to disable a default action is:

An example of this usage was reported by Graham Ashton. He had customized a keypress handler for a window, but every time the user triggered the Alt-arrow combination he was handling, the focus moved around between the widgets in the interface (as is the default behaviour).

The solution was simply calling window.emit_stop_by_name("key_press_event") and returning True.

PyGTK FAQ Wizard | PyGTK Homepage | Feedback to faq at pygtk.org