def __init__(self, table): if not hasattr(table.model, '__getitem__'): raise TypeError('Table model must support indexed access') self._table = table self._selectionListener = addListSelectionListener( table.selectionModel, self._tableSelectionChanged) addPropertyListener(self, None, self._propertyChanged)
def __init__(self, table): if not hasattr(table.model, '__getitem__'): raise TypeError('Table model must support indexed access') self._table = table self._selectionListener = addListSelectionListener( table.selectionModel, self._tableSelectionChanged) addPropertyListener(self, None, self._propertyChanged)
def setup(self): self.mirror = MirrorObject(DummyBean1()) self.propertyValue1 = None self.propertyValue2 = None self.changes = [] addPropertyListener(self.mirror, 'prop1', self.prop1listener) addPropertyListener(self.mirror, 'prop2', self.prop2listener) addPropertyListener(self.mirror, 'prop3', self.prop3listener) addPropertyListener(self.mirror, None, self.allListener)
def testAutoProperty(): class DummyBean(JavaBeanSupport, AutoChangeNotifier): prop = 'test1' def listener(event, listenerOk): listenerOk[0] = True assert event.oldValue == 'test1' assert event.newValue == 'test2' listenerOk = [False] bean = DummyBean() wrapper = addPropertyListener(bean, u'prop', listener, listenerOk) bean.prop = 'test2' assert listenerOk[0] is True listenerOk = [False] bean.removePropertyChangeListener(u'prop', wrapper) bean.prop = 'test3' assert listenerOk[0] is False
def testPropertyChange(): class DummyBean(JavaBeanSupport): def testFire(self): self.firePropertyChange(u'testProperty', None, u'newVal') def listener(event, listenerOk): listenerOk[0] = True assert event.oldValue is None assert event.newValue == 'newVal' listenerOk = [False] bean = DummyBean() wrapper = addPropertyListener(bean, u'testProperty', listener, listenerOk) bean.testFire() assert listenerOk[0] is True listenerOk = [False] bean.removePropertyChangeListener(u'testProperty', wrapper) bean.testFire() assert listenerOk[0] is False
def addDocumentPropertyListener(self, parent, callback, *args, **kwargs): self.listeners['documentProperty'] = addPropertyListener(parent, 'document', self.documentPropertyChanged, parent, callback, *args, **kwargs)
def addListeners(self, parent, callback, *args, **kwargs): self.listeners['property'] = addPropertyListener(parent, self.property, callback, *args, **kwargs)
def addColumnModelListener(self, parent, callback, *args, **kwargs): self.listeners['columnModel'] = addPropertyListener(parent, 'columnModel', self.columnModelChanged, parent, callback, *args, **kwargs)
def addSelectionModelListener(self, parent, callback, *args, **kwargs): self.listeners['selectionModel'] = addPropertyListener(parent, 'selectionModel', self.selectionModelChanged, parent, callback, *args, **kwargs)
def __init__(self, list_): super(ListSelectionMirror, self).__init__() self._list = list_ self._selectionListener = addListSelectionListener( list.selectionModel, self._selectionChanged) addPropertyListener(self, None, self._propertyChanged)
def __init__(self, list_): super(ListSelectionMirror, self).__init__() self._list = list_ self._selectionListener = addListSelectionListener( list.selectionModel, self._selectionChanged) addPropertyListener(self, None, self._propertyChanged)