Class GState

This class defines no attributes and no methods and exists solely to provide a convenient object for storing information that needs to be shared with callback functions. Its use is illustrated by the following program, which draws lines on the graphics window:

def draw_lines(): def mousedown_action(e): gs.line = GLine(e.get_x(), e.get_y(), e.get_x(), e.get_y()) gw.add(gs.line) def drag_action(e): gs.line.set_end_point(e.get_x(), e.get_y()) gw = GWindow(GWINDOW_WIDTH, GWINDOW_HEIGHT) gs = GState() gw.add_event_listener("mousedown", mousedown_action) gw.add_event_listener("drag", drag_action)

The variable line cannot be shared in the closure because the mousedown_action function assigns a value to that variable. In Python, such assignments automatically declare the variable as local, which breaks the sharing relationship.


Constructor Summary
GState()
Constructs a new GState object with no attributes.
 
Constructor Detail

GState()

Constructs a new GState object with no attributes.
Usage: gs = GState()