Пример #1
0
    def __init__(self,parent=None):
        super(TriangularNumberWindow, self).__init__(parent)
        self.setupUi(self)

        self.checkBox_triangularNumber.clicked.connect(self._set_GTNListcheckBox)
        self.checkBox_triangular.clicked.connect(self._set_GTNcheckBox)
        QObject.connect(self.buttonBox, SIGNAL("accepted()"), self._Proccessor)
Пример #2
0
 def testSimplePythonSignalNoArgs(self):
     #Connecting a lambda to a simple python signal without arguments
     obj = Dummy()
     QObject.connect(obj, SIGNAL('foo()'),
                     lambda: setattr(obj, 'called', True))
     obj.emit(SIGNAL('foo()'))
     self.assert_(obj.called)
Пример #3
0
 def testSimplePythonSignalNoArgs(self):
     #Connecting a lambda to a simple python signal without arguments
     obj = Dummy()
     QObject.connect(obj, SIGNAL('foo()'),
                     lambda: setattr(obj, 'called', True))
     obj.emit(SIGNAL('foo()'))
     self.assert_(obj.called)
Пример #4
0
 def testMetaData(self):
     self.view = QWebView()
     QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
                     self.load_finished)
     url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__))
     self.view.setUrl(url)
     self.app.exec_()
Пример #5
0
 def setUp(self):
     #Acquire resources
     TimedQApplication.setUp(self, timeout=1000)
     self.view = QWebView()
     QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
                     self.load_finished)
     self.called = False
Пример #6
0
 def testButtonClick(self):
     """Indirect qt signal emission using the QPushButton.click() method """
     button = QPushButton('label')
     QObject.connect(button, SIGNAL('clicked()'), self.cb)
     self.args = tuple()
     button.click()
     self.assert_(self.called)
Пример #7
0
 def testMetaData(self):
     self.view = QWebView()
     QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
                     self.load_finished)
     url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__))
     self.view.setUrl(url)
     self.app.exec_()
    def testQThreadReceiversExtern(self):
        #QThread.receivers() - Inherited protected method

        obj = QThread()
        self.assertEqual(obj.receivers(SIGNAL('destroyed()')), 0)
        QObject.connect(obj, SIGNAL("destroyed()"), self.cb)
        self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 1)
Пример #9
0
 def setUp(self):
     #Acquire resources
     TimedQApplication.setUp(self, timeout=1000)
     self.view = QWebView()
     QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
                     self.load_finished)
     self.called = False
Пример #10
0
 def testButtonClicked(self):
     """Connection of a python slot to QPushButton.clicked()"""
     button = QPushButton('Mylabel')
     QObject.connect(button, SIGNAL('clicked()'), self.cb)
     self.args = tuple()
     button.emit(SIGNAL('clicked(bool)'), False)
     self.assert_(self.called)
Пример #11
0
 def testButtonClicked(self):
     """Connection of a python slot to QPushButton.clicked()"""
     button = QPushButton('Mylabel')
     QObject.connect(button, SIGNAL('clicked()'), self.cb)
     self.args = tuple()
     button.emit(SIGNAL('clicked(bool)'), False)
     self.assert_(self.called)
Пример #12
0
 def testButtonClick(self):
     """Indirect qt signal emission using the QPushButton.click() method """
     button = QPushButton('label')
     QObject.connect(button, SIGNAL('clicked()'), self.cb)
     self.args = tuple()
     button.click()
     self.assert_(self.called)
    def testQThreadReceiversExtern(self):
        #QThread.receivers() - Inherited protected method

        obj = QThread()
        self.assertEqual(obj.receivers(SIGNAL('destroyed()')), 0)
        QObject.connect(obj, SIGNAL("destroyed()"), self.cb)
        self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 1)
Пример #14
0
 def testIt(self):
     global called
     called = False
     o = QObject()
     o.connect(o, SIGNAL("ASignal"), functools.partial(someSlot, "partial .."))
     o.emit(SIGNAL("ASignal"))
     self.assertTrue(called)
Пример #15
0
        def testValueChanged(self):
            """Emission of a python signal to QSpinBox setValue(int)"""
            QObject.connect(self.obj, SIGNAL('dummy(int)'), self.spin, SLOT('setValue(int)'))
            self.assertEqual(self.spin.value(), 0)

            self.obj.emit(SIGNAL('dummy(int)'), 4)
            self.assertEqual(self.spin.value(), 4)
Пример #16
0
 def testIt(self):
     global called
     called = False
     o = QObject()
     o.connect(o, SIGNAL("ASignal"), functools.partial(someSlot, "partial .."))
     o.emit(SIGNAL("ASignal"))
     self.assertTrue(called)
Пример #17
0
 def atestSpinBoxValueChangedFewArgs(self):
     """Emission of signals with fewer arguments than needed"""
     # XXX: PyQt4 crashes on the assertRaises
     QObject.connect(self.spin, SIGNAL('valueChanged(int)'), self.cb)
     self.args = (554, )
     self.assertRaises(TypeError, self.spin.emit,
                       SIGNAL('valueChanged(int)'))
    def run(self):
        global thread_run
        thread_run = True
        QObject.connect(self.source, SIGNAL('source()'), self.target.myslot)

        while not self.target.called:
            pass
Пример #19
0
 def setupContextMenu(self, vobj, menu):  # pylint: disable=no-self-use
     """Setup the context menu associated to the object in tree view
     (callback)"""
     icon = QIcon(os.path.join(WBDIR, "icons", "Render.svg"))
     action1 = QAction(icon, "Render", menu)
     QObject.connect(action1, SIGNAL("triggered()"), self.render)
     menu.addAction(action1)
Пример #20
0
    def run(self):
        global thread_run
        thread_run = True
        QObject.connect(self.source, SIGNAL('source()'), self.target.myslot)

        while not self.target.called:
            pass
Пример #21
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 )
Пример #22
0
    def testThread(self):
        t = MyThread()
        QObject.connect(t, SIGNAL("test(const QString&)"), self._callback);
        t.start()

        self.app.exec_()
        t.wait()
        self.assert_(self.__called__);
Пример #23
0
    def testDefaultArgs(self):
        #QUdpSocket.readDatagram pythonic return
        # @bug 124
        QObject.connect(self.server, SIGNAL('readyRead()'), self.callback)
        self.sendPackage()
        self.app.exec_()

        self.assert_(self.called)
Пример #24
0
    def testThread(self):
        t = MyThread()
        QObject.connect(t, SIGNAL("test(const QString&)"), self._callback)
        t.start()

        self.app.exec_()
        t.wait()
        self.assert_(self.__called__)
    def testQObjectReceiversExtern(self):
        #QObject.receivers() - Protected method external access

        obj = Dummy()
        self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 0)

        QObject.connect(obj, SIGNAL("destroyed()"), self.cb)
        self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 1)
    def testQObjectReceiversExtern(self):
        #QObject.receivers() - Protected method external access

        obj = Dummy()
        self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 0)

        QObject.connect(obj, SIGNAL("destroyed()"), self.cb)
        self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 1)
Пример #27
0
 def testSimplePythonSignal(self):
     #Connecting a lambda to a simple python signal witharguments
     obj = Dummy()
     arg = 42
     QObject.connect(obj, SIGNAL('foo(int)'),
                     lambda x: setattr(obj, 'arg', 42))
     obj.emit(SIGNAL('foo(int)'), arg)
     self.assertEqual(obj.arg, arg)
Пример #28
0
    def testDefaultArgs(self):
        #QUdpSocket.readDatagram pythonic return
        # @bug 124
        QObject.connect(self.server, SIGNAL('readyRead()'), self.callback)
        self.sendPackage()
        self.app.exec_()

        self.assert_(self.called)
Пример #29
0
 def testSimplePythonSignal(self):
     #Connecting a lambda to a simple python signal witharguments
     obj = Dummy()
     arg = 42
     QObject.connect(obj, SIGNAL('foo(int)'),
                     lambda x: setattr(obj, 'arg', 42))
     obj.emit(SIGNAL('foo(int)'), arg)
     self.assertEqual(obj.arg, arg)
Пример #30
0
 def testWithArgs(self):
     '''Connecting a lambda to a signal with arguments'''
     proc = QProcess()
     dummy = Dummy()
     QObject.connect(proc, SIGNAL('finished(int)'),
                     lambda x: setattr(dummy, 'called', x))
     proc.start(sys.executable, ['-c', '""'])
     proc.waitForFinished()
     self.assertEqual(dummy.called, proc.exitCode())
Пример #31
0
 def testNoArgs(self):
     '''Connecting a lambda to a signal without arguments'''
     proc = QProcess()
     dummy = Dummy()
     QObject.connect(proc, SIGNAL('started()'),
                     lambda: setattr(dummy, 'called', True))
     proc.start(sys.executable, ['-c', '""'])
     proc.waitForFinished()
     self.assert_(dummy.called)
Пример #32
0
    def testMultipleArgs(self):
        """Short circuit signal with multiple arguments"""
        obj1 = Dummy()

        QObject.connect(obj1, SIGNAL('foo'), self.callback)
        self.args = (42,33,'char')
        obj1.emit(SIGNAL('foo'), *self.args)

        self.assert_(self.called)
Пример #33
0
 def testWithArgs(self):
     '''Connecting a lambda to a signal with arguments'''
     proc = QProcess()
     dummy = Dummy()
     QObject.connect(proc, SIGNAL('finished(int)'),
                     lambda x: setattr(dummy, 'called', x))
     proc.start(sys.executable, ['-c', '""'])
     proc.waitForFinished()
     self.assertEqual(dummy.called, proc.exitCode())
Пример #34
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)
Пример #35
0
    def init ( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        self.control = control = QLabel( parent() )
        QObject.connect( control, SIGNAL( 'linkActivated(QString)' ),
                         self._link_activated )

        self.set_tooltip()
Пример #36
0
    def testComplexArgs(self):
        """Short circuit signal with complex arguments"""
        obj1 = Dummy()

        QObject.connect(obj1, SIGNAL('foo'), self.callback)
        self.args = (42, obj1)
        obj1.emit(SIGNAL('foo'), *self.args)

        self.assert_(self.called)
    def testNoArgs(self):
        """Connect signal using a Qt.ConnectionType as argument"""
        obj1 = Dummy()

        QObject.connect(obj1, SIGNAL("foo"), self.callback, Qt.DirectConnection)
        self.args = tuple()
        obj1.emit(SIGNAL("foo"), *self.args)

        self.assert_(self.called)
Пример #38
0
    def testNoArgs(self):
        """Python signal and slots without arguments"""
        obj1 = Dummy()

        QObject.connect(obj1, SIGNAL('foo()'), self.callback)
        self.args = tuple()
        obj1.emit(SIGNAL('foo()'), *self.args)

        self.assert_(self.called)
Пример #39
0
        def testShow(self):
            """Emission of a python signal to QWidget slot show()"""
            self.widget.hide()

            QObject.connect(self.obj, SIGNAL('dummy()'), self.widget, SLOT('show()'))
            self.assert_(not self.widget.isVisible())

            self.obj.emit(SIGNAL('dummy()'))
            self.assert_(self.widget.isVisible())
Пример #40
0
    def testNoArgs(self):
        """Short circuit signal without arguments"""
        obj1 = Dummy()

        QObject.connect(obj1, SIGNAL('foo'), self.callback)
        self.args = tuple()
        obj1.emit(SIGNAL('foo'), *self.args)

        self.assert_(self.called)
Пример #41
0
 def testNoArgs(self):
     '''Connecting a lambda to a signal without arguments'''
     proc = QProcess()
     dummy = Dummy()
     QObject.connect(proc, SIGNAL('started()'),
                     lambda: setattr(dummy, 'called', True))
     proc.start(sys.executable, ['-c', '""'])
     proc.waitForFinished()
     self.assert_(dummy.called)
Пример #42
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)
Пример #43
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 )
Пример #44
0
    def testWithArgs(self):
        """Python signal and slots with integer arguments"""
        obj1 = Dummy()

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

        self.assert_(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))
Пример #46
0
 def __init__(self, editor, config, category, setting, info):
     super(SpinBox, self).__init__()
     self.editor = editor
     self.config = config
     self.category = category
     self.setting = setting
     self.info = info
     self.setMaximum(1000000)
     self.setValue(info['value'])
     QObject.connect(self, SIGNAL('valueChanged(int)'), self.stateChangeHandler)
    def testNoArgs(self):
        """Connect signal using a Qt.ConnectionType as argument"""
        obj1 = Dummy()

        QObject.connect(obj1, SIGNAL('foo'), self.callback,
                        Qt.DirectConnection)
        self.args = tuple()
        obj1.emit(SIGNAL('foo'), *self.args)

        self.assert_(self.called)
Пример #48
0
    def __init__(self, color=QColor(127, 127, 127)):
        """Initialize ColorPicker.

        Args:
            color -- The default color of the picker
        """
        super().__init__()
        self.color = QColor(color)
        self._set_icon(self.color)
        QObject.connect(self, SIGNAL("clicked()"), self.on_button_clicked)
Пример #49
0
 def __init__(self, reactor, watcher, type):
     QSocketNotifier.__init__(self, watcher.fileno(), type)
     self.reactor = reactor
     self.watcher = watcher
     self.fn = None
     if type == QSocketNotifier.Read:
         self.fn = self.read
     elif type == QSocketNotifier.Write:
         self.fn = self.write
     QObject.connect(self, SIGNAL("activated(int)"), self.fn)
Пример #50
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)
Пример #51
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)
Пример #52
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)