def __init__(self, browser_list, notifier=None, *a, **k): super(BrowserListWrapper, self).__init__(*a, **k) self._browser_list = browser_list self._notifier = notifier slot = Slot(browser_list, self.notify, u'items') slot.connect() self.register_slot(slot)
def __init__(self, property_host=None, source_property=None, from_property_value=None, to_property_value=None, display_value_conversion=nop, value_items=[], *a, **k): assert source_property is not None super(WrappingParameter, self).__init__(display_value_conversion=display_value_conversion, *a, **k) self._property_host = property_host assert self._property_host == None or hasattr( self._property_host, source_property) or source_property in dir( self._property_host) self._source_property = source_property self._value_items = value_items self.set_scaling_functions(to_property_value, from_property_value) self._property_slot = self.register_slot( Slot(listener=self.notify_value, event_name=source_property, subject=self._property_host)) return
def set_property_host(self, property_host): self._property_host = property_host def notify_index_and_default_label(): self.notify_active_index() self.notify_default_label() self._property_slot = self.register_slot(Slot(subject=property_host, event_name=self._value_property_name, listener=notify_index_and_default_label))
def __init__(self, name = None, property_host = None, property_name = '', *a, **k): super(DeviceOnOffOption, self).__init__(callback=self.cycle_index, name=name, *a, **k) self._property_host = property_host self._property_name = property_name def notify_index_and_default_label(): self.notify_active_index() self.notify_default_label() self._property_slot = self.register_slot(Slot(subject=property_host, event_name=property_name, listener=notify_index_and_default_label))
def __init__(self, source_property=None, from_property_value=None, to_property_value=None, display_value_conversion=nop, value_items=[], *a, **k): raise source_property is not None or AssertionError super(WrappingParameter, self).__init__(display_value_conversion=display_value_conversion, *a, **k) raise hasattr(self._parent, source_property) or source_property in dir( self._parent) or AssertionError self._source_property = source_property self._value_items = value_items self.set_scaling_functions(to_property_value, from_property_value) self._property_slot = self.register_slot( Slot(listener=self.notify_value, event=source_property)) self.connect()
def _alias_observable_property(self, prop_name, alias_name, getter=None): default_getter = lambda self_: getattr(self_._adaptee, prop_name) aliased_prop = property(getter or default_getter) setattr(self.__class__, alias_name, aliased_prop) notifier = getattr(self, u'notify_' + alias_name) self.register_slot(Slot(self._adaptee, notifier, prop_name))
def _setup_alias(self, getter): aliased_prop = property(getter or self._get_property) setattr(self._alias_host.__class__, self._alias_name, aliased_prop) notifier = getattr(self._alias_host, 'notify_' + self._alias_name) self._property_slot = self.register_slot( Slot(self.property_host, notifier, self._property_name))
def _register_listener(self, callback, obj, prop): """ Attaches a callback that takes no arguments to a property (e.g., 'is_playing') of an object in Live (e.g., self.song). """ self.register_slot(Slot(obj, callback, prop))