Baby Language Lab Scripts
A collection of data processing tools.
 All Classes Namespaces Files Functions Variables Pages
utils.handler_manager.HandlerManager Class Reference

This class is a data structure that stores information about handler methods for UI widgets. More...

Inheritance diagram for utils.handler_manager.HandlerManager:

Public Member Functions

def __init__
 Constructor. More...
 
def add_handler
 Adds a handler (for a particular widget) to this instance. More...
 
def get_handler_id
 Retrieves a handler id (number used by GTK+ to identify a handler) for a given UI object and signal. More...
 
def block_handler
 Temporarily prevents a specified signal from invoking handlers, for a given UI widget. More...
 
def unblock_handler
 Unblocks a signal that has been blocked with block_handler(). More...
 
def remove_handlers
 Disconnects handler methods from a widget, and removes all record of the handler from this instance. More...
 

Public Attributes

 conn_dict
 

Private Member Functions

def _have_handler
 Internal method to check if a particular handler (for a particular widget) is already stored in this instance. More...
 

Detailed Description

This class is a data structure that stores information about handler methods for UI widgets.

Handler methods are called when a UI widget generates an event, such as a button click. The main benefit of using this class is that it provides a lookup mechansim. You can lookup handlers for a particular widget based on a specified type of signal (event). Plain PyGTK does not provide a straightforward way to do this. Another benefit is that if we have a centralized data structure for all handlers in a form, we don't have to pass around lots of handler ids or function pointers when we want to do things like temporarily block a handler for a particular widget. Instead, you can just call the block_handler() / unblock_handler() methods for a particular widget and signal.

Definition at line 11 of file handler_manager.py.

Constructor & Destructor Documentation

def utils.handler_manager.HandlerManager.__init__ (   self)

Constructor.

Parameters
self

Definition at line 14 of file handler_manager.py.

Member Function Documentation

def utils.handler_manager.HandlerManager._have_handler (   self,
  obj,
  sig 
)
private

Internal method to check if a particular handler (for a particular widget) is already stored in this instance.

Parameters
self
obj(UI object) a UI widget object
sig(string) a GTK+ event string (like 'clicked' or 'destroy' - see PyGTK docs for a list for your desired widget)
Returns
(boolean) True if the obj has a handler for sig that is stored in this instance, False otherwise

Definition at line 22 of file handler_manager.py.

def utils.handler_manager.HandlerManager.add_handler (   self,
  obj,
  sig,
  fcn,
  data = None 
)

Adds a handler (for a particular widget) to this instance.

Parameters
self
obj(UI object) the UI widget object for which we are adding a handler
sig(string) a GTK+ event string (like 'clicked' or 'destroy' - see PyGTK docs for a list for your desired widget)
fcn(function pointer) the function that the signal will invoke
data(object=None) optional extra data to pass to the function when it is invoked (see pyGTK signal tutorials to learn more about this)

Definition at line 31 of file handler_manager.py.

def utils.handler_manager.HandlerManager.block_handler (   self,
  obj,
  sig 
)

Temporarily prevents a specified signal from invoking handlers, for a given UI widget.

This does not remove the handler from this instance, nor does it disconnect the handler from the widget object. The signal will be blocked for this widget until unblock_handler() is called (see below).

Parameters
self
obj(UI object) the UI widget on which to block a handler
sig(string) a GTK+ event string (eg. 'clicked') indicating the signal to block

Definition at line 58 of file handler_manager.py.

def utils.handler_manager.HandlerManager.get_handler_id (   self,
  obj,
  sig 
)

Retrieves a handler id (number used by GTK+ to identify a handler) for a given UI object and signal.

Parameters
self
obj(UI object) the UI widget object to lookup
sig(string) a GTK+ event string (eg. 'clicked') indicating the signal to look for handlers for
Returns
(int) a GTK+ handler id (see GTK+ docs for more info), or None if the (obj, sig) is not stored in this instance

Definition at line 45 of file handler_manager.py.

def utils.handler_manager.HandlerManager.remove_handlers (   self,
  obj,
  sigs = None 
)

Disconnects handler methods from a widget, and removes all record of the handler from this instance.

Parameters
self
obj(UI object) the UI object whose handler we are disconnecting
sigs(list=None) list of GTK+ event strings (eg. ['clicked']) indicating the signals to remove handlers for. Pass None to remove all handlers for all signals for the widget.

Definition at line 74 of file handler_manager.py.

def utils.handler_manager.HandlerManager.unblock_handler (   self,
  obj,
  sig 
)

Unblocks a signal that has been blocked with block_handler().

Parameters
self
obj(UI object) the UI widget on which to unblock signal handlers.
sig(string) a GTK+ event string (eg. 'clicked') indicating the signal to unblock.

Definition at line 66 of file handler_manager.py.

Member Data Documentation

utils.handler_manager.HandlerManager.conn_dict

Definition at line 15 of file handler_manager.py.


The documentation for this class was generated from the following file: