def __init__(self, axis, comp, value_ctrl, pos_2_ctrl=None, ctrl_2_pos=None, events=None): """ axis (string): the name of the axis to connect with comp (Actuator): the component that contains the axis value_ctrl (wx.Window): a wx widget to connect to pos_2_ctrl (None or callable ((value) -> None)): a function to be called when the position is updated, to update the widget. If None, try to use the default SetValue(). ctrl_2_pos (None or callable ((None) -> value)): a function to be called when the widget is updated, to update the VA. If None, try to use the default GetValue(). Can raise ValueError, TypeError or IndexError if data is incorrect events (None or wx.EVT_* or tuple of wx.EVT_*): events to bind to update the value of the VA """ self.axis = axis self.comp = comp self.value_ctrl = value_ctrl pos_2_ctrl = pos_2_ctrl or value_ctrl.SetValue self.pos_2_ctrl = call_in_wx_main_wrapper(dead_object_wrapper(pos_2_ctrl)) self.ctrl_2_pos = ctrl_2_pos or value_ctrl.GetValue if events is None: self.change_events = () elif not isinstance(events, collections.Iterable): self.change_events = (events,) else: self.change_events = events if self.value_ctrl: self.value_ctrl.Bind(wx.EVT_WINDOW_DESTROY, self._on_ctrl_destroy, source=self.value_ctrl) # Subscribe to the position and initialize self._connect(init=True)
def __init__(self, va, value_ctrl, va_2_ctrl=None, ctrl_2_va=None, events=None): """ va (VigilantAttribute): the VA to connect with ctrl (wx.Window): a wx widget to connect to va_2_ctrl (None or callable ((value) -> None)): a function to be called when the VA is updated, to update the widget. If None, try to use the default SetValue(). It is always called in the main WX thread. It is called once at initialisation. ctrl_2_va (None or callable ((None) -> value)): a function to be called when the widget is updated, to update the VA. If None, try to use the default GetValue(). Can raise ValueError, TypeError or IndexError if data is incorrect events (None or wx.EVT_* or tuple of wx.EVT_*): events to bind to update the value of the VA """ self.vigilattr = va self.value_ctrl = value_ctrl self.paused = False va_2_ctrl = va_2_ctrl or value_ctrl.SetValue # Dead_object_wrapper might need/benefit from recognizing bound methods. # Or it can be tough to recognize wxPyDeadObjects being passed as 'self' self.va_2_ctrl = call_in_wx_main_wrapper(dead_object_wrapper(va_2_ctrl)) self.ctrl_2_va = ctrl_2_va or value_ctrl.GetValue if events is None: self.change_events = () elif not isinstance(events, collections.Iterable): self.change_events = (events,) else: self.change_events = events # Subscribe to the vigilant attribute and initialize self._connect(init=True)
def __init__(self, va, value_ctrl, va_2_ctrl=None, ctrl_2_va=None, events=None): """ va (VigilantAttribute): the VA to connect with ctrl (wx.Window): a wx widget to connect to va_2_ctrl (None or callable ((value) -> None)): a function to be called when the VA is updated, to update the widget. If None, try to use the default SetValue(). It is always called in the main WX thread. It is called once at initialisation. ctrl_2_va (None or callable ((None) -> value)): a function to be called when the widget is updated, to update the VA. If None, try to use the default GetValue(). Can raise ValueError, TypeError or IndexError if data is incorrect events (None or wx.EVT_* or tuple of wx.EVT_*): events to bind to update the value of the VA """ self.vigilattr = va self.value_ctrl = value_ctrl self.paused = False va_2_ctrl = va_2_ctrl or value_ctrl.SetValue # Dead_object_wrapper might need/benefit from recognizing bound methods. # Or it can be tough to recognize wxPyDeadObjects being passed as 'self' self.va_2_ctrl = call_in_wx_main_wrapper( dead_object_wrapper(va_2_ctrl)) self.ctrl_2_va = ctrl_2_va or value_ctrl.GetValue if events is None: self.change_events = () elif not isinstance(events, collections.Iterable): self.change_events = (events, ) else: self.change_events = events if self.value_ctrl: self.value_ctrl.Bind(wx.EVT_WINDOW_DESTROY, self._on_ctrl_destroy, source=self.value_ctrl) # Subscribe to the vigilant attribute and initialize self._connect(init=True)
def __init__(self, axis, comp, value_ctrl, pos_2_ctrl=None, ctrl_2_pos=None, events=None): """ axis (string): the name of the axis to connect with comp (Actuator): the component that contains the axis value_ctrl (wx.Window): a wx widget to connect to pos_2_ctrl (None or callable ((value) -> None)): a function to be called when the position is updated, to update the widget. If None, try to use the default SetValue(). ctrl_2_pos (None or callable ((None) -> value)): a function to be called when the widget is updated, to update the VA. If None, try to use the default GetValue(). Can raise ValueError, TypeError or IndexError if data is incorrect events (None or wx.EVT_* or tuple of wx.EVT_*): events to bind to update the value of the VA """ self.axis = axis self.comp = comp self.value_ctrl = value_ctrl self._prev_focus = None # the focused control before starting to move self._future = None # Future representing the current move pos_2_ctrl = pos_2_ctrl or value_ctrl.SetValue self.pos_2_ctrl = call_in_wx_main_wrapper( dead_object_wrapper(pos_2_ctrl)) self.ctrl_2_pos = ctrl_2_pos or value_ctrl.GetValue if events is None: self.change_events = () elif not isinstance(events, collections.Iterable): self.change_events = (events, ) else: self.change_events = events if self.value_ctrl: self.value_ctrl.Bind(wx.EVT_WINDOW_DESTROY, self._on_ctrl_destroy, source=self.value_ctrl) # Subscribe to the position and initialize self._connect(init=True)