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)
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)
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 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
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)
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)
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)
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)
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
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)
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 )
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 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)
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 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)
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())
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)
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)
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)
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()
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)
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)
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())
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)
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 )
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))
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)
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)
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)
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 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)