Пример #1
0
 def _slot_clicked ( self, handler, connect ):
     from facets.extra.helper.debug import log_if
     log_if( 2, 'clicked!' )
     if connect:
         QObject.connect( self.control, SIGNAL( 'clicked()' ), handler )
     else:
         QObject.disconnect( self.control, SIGNAL( 'clicked()' ), handler )
Пример #2
0
 def testButton(self):
     #Connecting a lambda to a QPushButton.clicked()
     obj = QPushButton('label')
     ctr = Control()
     func = lambda: setattr(ctr, 'arg', True)
     QObject.connect(obj, SIGNAL('clicked()'), func)
     obj.click()
     self.assert_(ctr.arg)
     QObject.disconnect(obj, SIGNAL('clicked()'), func)
Пример #3
0
 def testButton(self):
     #Connecting a lambda to a QPushButton.clicked()
     obj = QPushButton('label')
     ctr = Control()
     func = lambda: setattr(ctr, 'arg', True)
     QObject.connect(obj, SIGNAL('clicked()'), func)
     obj.click()
     self.assert_(ctr.arg)
     QObject.disconnect(obj, SIGNAL('clicked()'), func)
Пример #4
0
 def _slot_choose ( self, handler, connect ):
     from facets.extra.helper.debug import log_if
     log_if( 2, 'choose!' )
     if connect:
         QObject.connect( self.control, SIGNAL( 'activated(QString)' ),
                          handler )
     else:
         QObject.disconnect( self.control, SIGNAL( 'activated(QString)' ),
                             handler )
Пример #5
0
 def testSpinButton(self):
     #Connecting a lambda to a QPushButton.clicked()
     obj = QSpinBox()
     ctr = Control()
     arg = 444
     func = lambda x: setattr(ctr, 'arg', 444)
     QObject.connect(obj, SIGNAL('valueChanged(int)'), func)
     obj.setValue(444)
     self.assertEqual(ctr.arg, arg)
     QObject.disconnect(obj, SIGNAL('valueChanged(int)'), func)
 def testObjectRefcount(self):
     """Emission of QObject.destroyed() to a python slot"""
     def callback():
         pass
     obj = QObject()
     refcount = getrefcount(obj)
     QObject.connect(obj, SIGNAL('destroyed()'), callback)
     self.assertEqual(refcount, getrefcount(obj))
     QObject.disconnect(obj, SIGNAL('destroyed()'), callback)
     self.assertEqual(refcount, getrefcount(obj))
Пример #7
0
 def testSpinButton(self):
     #Connecting a lambda to a QPushButton.clicked()
     obj = QSpinBox()
     ctr = Control()
     arg = 444
     func = lambda x: setattr(ctr, 'arg', 444)
     QObject.connect(obj, SIGNAL('valueChanged(int)'), func)
     obj.setValue(444)
     self.assertEqual(ctr.arg, arg)
     QObject.disconnect(obj, SIGNAL('valueChanged(int)'), func)
Пример #8
0
    def testDisconnect(self):
        obj1 = Dummy()

        QObject.connect(obj1, SIGNAL('foo(int)'), self.callback)
        QObject.disconnect(obj1, SIGNAL('foo(int)'), self.callback)

        self.args = (42, )
        obj1.emit(SIGNAL('foo(int)'), *self.args)

        self.assert_(not self.called)
 def testObjectRefcount(self):
     """Emission of QObject.destroyed() to a python slot"""
     def callback():
         pass
     obj = QObject()
     refcount = getrefcount(obj)
     QObject.connect(obj, SIGNAL('destroyed()'), callback)
     self.assertEqual(refcount, getrefcount(obj))
     QObject.disconnect(obj, SIGNAL('destroyed()'), callback)
     self.assertEqual(refcount, getrefcount(obj))
Пример #10
0
    def testRefCount(self):
        def cb(*args):
            pass

        self.assertEqual(getrefcount(cb), 2)

        QObject.connect(self.emitter, SIGNAL('destroyed()'), cb)
        self.assertEqual(getrefcount(cb), 3)

        QObject.disconnect(self.emitter, SIGNAL('destroyed()'), cb)
        self.assertEqual(getrefcount(cb), 2)
Пример #11
0
    def testRefCount(self):
        def cb(*args):
            pass

        self.assertEqual(getrefcount(cb), 2)

        QObject.connect(self.emitter, SIGNAL('destroyed()'), cb)
        self.assertEqual(getrefcount(cb), 3)

        QObject.disconnect(self.emitter, SIGNAL('destroyed()'), cb)
        self.assertEqual(getrefcount(cb), 2)
Пример #12
0
    def _slot_text_enter ( self, handler, connect ):
        from facets.extra.helper.debug import log_if
        log_if( 2, 'text enter!' )

        control = self.control
        if isinstance( control, QComboBox ):
            control = control.lineEdit()

        if connect:
            QObject.connect( control, SIGNAL( 'editingFinished()' ), handler )
        else:
            QObject.disconnect( control, SIGNAL( 'editingFinished()' ),
                                handler )
Пример #13
0
    def _slot_text_change ( self, handler, connect ):
        from facets.extra.helper.debug import log_if
        log_if( 2, 'text change!' )

        control = self.control
        if isinstance( control, QComboBox ):
            control = control.lineEdit()

        signal = 'textEdited(QString)'
        if isinstance( control, QTextEdit ):
            signal = 'textChanged()'

        if connect:
            QObject.connect( control, SIGNAL( signal ), handler )
        else:
            QObject.disconnect( control, SIGNAL( signal ), handler )
Пример #14
0
 def shutdown(self):
     QObject.disconnect(self, SIGNAL("activated(int)"), self.fn)
     self.setEnabled(False)
     self.fn = self.watcher = None
     self.deleteLater()
Пример #15
0
 def disconnect(self, instance):
     for widget, updateUi, updateData in self._reflections[instance]:
         instance.UnregisterReflection(updateUi)
         #TODO: disconnect the correct signal
         QObject.disconnect(widget)