InterviewSolution
| 1. |
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)? |
|
Answer» 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. 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. |
|