def __init__(self, do_action, undo_action, description='Action'): """ |do_action|: method to call to do the action. |undo_action|: method to call to undo the action. |description|: a description of this action (for debugging). """ assert is_callable(do_action), 'do_action must be callable' assert is_callable(undo_action), 'undo_action must be callable' self.do_action = do_action self.undo_action = undo_action self.description = description
def __init__(self, on_signal_file_changed, width=RESISTOR_HORIZONTAL_WIDTH, height=RESISTOR_HORIZONTAL_HEIGHT, direction=DIRECTION_UP, signal_file=None): """ |on_signal_file_changed|: function to be called when pot signal file is changed. |direction|: the direction of this pot, one of DIRECTION_DOWN, DIRECTION_LEFT, DIRECTION_RIGHT, or DIRECTION_UP. |signal_file|: the signal file (containing alpha) associated with this pot. """ assert is_callable(on_signal_file_changed), ('on_signal_file_changed must ' 'be callable') Drawable.__init__(self, width, height) self.on_signal_file_changed = on_signal_file_changed self.direction = direction self.signal_file = signal_file
def __init__(self, color, group_id, on_signal_file_changed, direction=DIRECTION_RIGHT, signal_file=None): """ |group_id|: indicator for the head this Photosensors_Drawable is a part of. |on_signal_file_changed|: function to be called when photosensor signal file is changed. |signal_file|: the signal file containing lamp angle and distance. """ assert is_callable(on_signal_file_changed), ('on_signal_file_changed must ' 'be callable') Pin_Drawable.__init__(self, 'Head\nEyes', color, PHOTOSENSORS_SIZE, PHOTOSENSORS_SIZE) self.color = color self.group_id = group_id self.on_signal_file_changed = on_signal_file_changed self.direction = direction self.signal_file = signal_file
def __init__(self, f): """ |f|: function used to produce samples. """ assert is_callable(f), 'f must be callable' self.f = f