Пример #1
0
    def createLayout(self, layout: Any) -> None:
        """
        Create layout via recursion.
        :param layout: layout object to create
        :return: None
        """
        def addIf(operation: Callable, widget_dict: dict, widget_object,
                  position: Tuple[int]):
            if "position" in widget_dict:
                try:
                    operation(widget_object, *position)
                except:
                    operation(widget_object, position)
            else:
                operation(widget_object)

        # Python checks function argument, cannot pass undefined or unnecessary args ...
        for widget in layout["items"].values():
            if "items" in widget:
                self.createLayout(widget)
                addIf(layout["object"].addLayout, widget, widget["object"],
                      widget["position"])
            elif "reference" in widget:
                self.createLayout(widget["reference"])
                addIf(layout["object"].addLayout, widget,
                      widget["reference"]["object"], widget["position"])
            else:  # widget
                addIf(layout["object"].addWidget, widget, widget["object"],
                      widget["position"])
                if "signal" and "slot" in widget:
                    QObject.connect(widget["object"], SIGNAL(widget["signal"]),
                                    widget["slot"])
Пример #2
0
    def __init__(self):
        super().__init__()
        self.dbConnector = cPl.DBConnector("timePlanner.db", "Task",
                                           ormMapping)
        self.taskStorage = cPl.TaskStorage(self.dbConnector, ormMapping)
        self.currentView = "Work"
        self.checkBox = QCheckBox('Minimize to Tray')
        self.checkBox.setChecked(True)
        self.createModels()
        self.grid = QGridLayout()
        self.tray_icon = QSystemTrayIcon()
        self.tray_icon.setToolTip("Time Planner")
        self.tray_icon.setIcon(self.style().standardIcon(
            QStyle.SP_ComputerIcon))
        traySignal = "activated(QSystemTrayIcon::ActivationReason)"
        QObject.connect(self.tray_icon, SIGNAL(traySignal),
                        self.__icon_activated)
        #appendFunc = anonFuncString("Total time")
        appendDataFinished = [
            cPl.AppendDataView(self.finishedModel, 3,
                               self.taskStorage.getTotalWorkTime,
                               workTimeFormat),
            cPl.AppendDataView(self.finishedModel, 2, anonFuncString)
        ]
        self.finishedModel.setAppendData(appendDataFinished)

        self.initUI()
Пример #3
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
Пример #4
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)
Пример #5
0
    def __init__(self, action: 'Action', parent=None) -> 'ActionGraphics':
        """
		Constructs a Action Graphics object for the given action.
		
		:param action: The action for which this graphics item represents.
		:type action: Action
		:param parent: None
		:type parent: NoneType
		:return: The graphics of an action.
		:rtype: ActionGraphics
		"""
        QGraphicsItem.__init__(self, parent)
        self.setFlag(QGraphicsItem.ItemIsSelectable)
        self.setCursor(Qt.ArrowCursor)
        self._action = action
        QObject.connect(action, SIGNAL('updated()'), self.updateGraphics)

        self.color = ActionGraphics.COLOR

        self._inputPortGraphics = []
        self._outputPortGraphics = []
        self._wireGraphics = []
        self._actionGraphics = []

        self._inputPortMapping = {}
        self._outputPortMapping = {}

        self._interactivePorts = True
        ActionGraphics.updateGraphics(self)

        self._width = 0
        self._height = 0
Пример #6
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)
Пример #7
0
    def __init__(self, parent):
        super().__init__(parent)
        self._scene = QGraphicsScene(self)
        self._graphics_view = QGraphicsView(self._scene, self)

        layout = QVBoxLayout(self)
        layout.addWidget(self._graphics_view)

        self._pixmap_item = SpriteGraphicsItem(self)
        self._scene.addItem(self._pixmap_item)

        self._image = QImage(SPRITE_SIZE, SPRITE_SIZE, QImage.Format_ARGB32)
        self.sprite = [[0] * SPRITE_SIZE] * SPRITE_SIZE

        button_layout = QHBoxLayout(self)
        layout.addLayout(button_layout)
        self._color_button_group = QButtonGroup(self)
        for color in COLORS:
            button = QPushButton(self)
            button.setCheckable(True)
            button.setText(f"{color}")
            self._color_button_group.addButton(button, color)
            button_layout.addWidget(button)

        self._selected_color = 0
        self._color_button_group.button(self._selected_color).setChecked(True)
        QObject.connect(self._color_button_group, SIGNAL("buttonClicked(int)"),
                        self._color_selected)

        self._update_scaling()
Пример #8
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
Пример #9
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)
Пример #10
0
 def GenerateFunction(self) :
   ##checking directory path validation
   if(os.path.isdir(self.FileLocation.text()) == False):
     ErrorBox = QtWidgets.QErrorMessage()
     ErrorBox.showMessage("This Directory doesn't exist")
     ErrorBox.exec_()
   else:
     #cmd ="Hello.c"
     ##To get MCU 
     Index = self.MCU.currentIndex()
     ##To get ComN
     COMNum=self.COMEdit.text()
     ##To get the ELF_File
     ##TODO:Change elffile_name automatically
     ElfPath = self.FileLocation.text() + "Main_APP.elf"
     ##starting the ComReceiver Thread
     self.file=Import(Index,COMNum,ElfPath)
     self.file.start()
     ##checking directory path validation
     if(os.path.isfile(r'./progress.txt') == False):
       self.Status.setText("Error")
       ErrorBox = QtWidgets.QErrorMessage()
       ErrorBox.showMessage("The progress file doesn't exist")
       ErrorBox.exec_()
     else:
       ##initalization values og progress.txt
       f = open('./progress.txt','w') 
       f.write("0 0")
       f.close()
       ##starting The progressBar Thread
       QObject.connect (self.progressView , QtCore.SIGNAL("__updateProgressBar(int)"),self.__updateProgressBar)
       self.start()
       
       print("correct")
Пример #11
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.assertTrue(self.called)
Пример #12
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 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)
Пример #14
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.assertTrue(obj.called)
 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)
Пример #16
0
    def __init__(self):
        QWidget.__init__(self)

        self.layout = QHBoxLayout()

        self.inputLayout = QVBoxLayout()
        self.formLayout = QFormLayout()

        self.nForm = QLineEdit("9")
        self.temp_start_Form = QLineEdit('30')
        self.temp_stop_Form = QLineEdit('0.5')
        self.alphaForm = QLineEdit('0.98')
        self.stepsForm = QLineEdit('1000')
        self.runButton = QPushButton("Запустить")
        self.boardLabel = QLabel("")
        chessFont = QFont("Consolas", 12)
        self.boardLabel.setFont(chessFont)

        self.visualLayout = QVBoxLayout()
        self.visualLayout.addWidget(self.boardLabel)

        self.formLayout.addRow("N:", self.nForm)
        self.formLayout.addRow("Tmax:", self.temp_start_Form)
        self.formLayout.addRow("Tmin:", self.temp_stop_Form)
        self.formLayout.addRow("alpha:", self.alphaForm)
        self.formLayout.addRow("Кол-во шагов:", self.stepsForm)

        self.inputLayout.addLayout(self.formLayout)
        self.inputLayout.addWidget(self.runButton)

        self.layout.addLayout(self.inputLayout)
        self.layout.addLayout(self.visualLayout)
        self.setLayout(self.layout)

        QObject.connect(self.runButton, SIGNAL('pressed()'), self.run_solve)
Пример #17
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
Пример #18
0
    def setupUi(self):

        self.__dataMapper = QDataWidgetMapper(self)

        self.__dataMapper.setModel(self.__titleModel)

        propertyText = QByteArray(b'text')
        self.__dataMapper.addMapping(self.ui.tituloLineEdit, 0, propertyText)
        self.__dataMapper.addMapping(self.ui.grupoLineEdit, 1, propertyText)
        self.__dataMapper.addMapping(self.ui.yearLineEdit, 2, propertyText)

        QObject.connect(self.ui.titlesListView.selectionModel(),
                        SIGNAL('currentRowChanged(QModelIndex,QModelIndex)'),
                        self,
                        SLOT('changeSelectedTitle(QModelIndex,QModelIndex)'))

        #Dialogo de configuracion

        self.dialogoConfiguracion = ConfigDialog(self)

        self.ui.actionConfiguracion.triggered.connect(
            self.dialogoConfiguracion.open)

        self.dialogoConfiguracion.finished.connect(self.reloadModelos)

        self.ui.playButton.clicked.connect(self.launchCurrentVideo)
        self.ui.stopButton.clicked.connect(self.__ytPlayer.stopVideo)
        self.ui.pauseButton.clicked.connect(self.__ytPlayer.pauseVideo)
Пример #19
0
 def configure_all(self):
     for table in self.table_names:
         self.configure(table)
     for action in self.actions:
         QObject.connect(action[self.ACTION_SRC],
                         SIGNAL(action[self.ACTION_SIGNAL]),
                         action[self.ACTION_SLOT])
Пример #20
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)
Пример #21
0
    def __init__(self):
        QObject.__init__(self, None)
        self._mainthread = QThread.currentThread()

        self._signalthread = SignalThread()
        QObject.connect(self._signalthread, SIGNAL("triggerSignal()"),
                        self.sensorQueueChanged)

        self._idletimer = QTimer()
        self._delaytimer = QTimer()
        self._timerqueuetimer = QTimer()

        self._idletimer.setSingleShot(True)
        self._delaytimer.setSingleShot(True)
        self._timerqueuetimer.setSingleShot(True)

        self.connect(self._idletimer, SIGNAL("timeout()"), self.idleTimeout)
        self.connect(self._delaytimer, SIGNAL("timeout()"), self.delayTimeout)
        self.connect(self._timerqueuetimer, SIGNAL("timeout()"),
                     self.timerQueueTimeout)

        SoDB.getSensorManager().setChangedCallback(self.sensorQueueChangedCB,
                                                   self)
        SoDB.setRealTimeInterval(1.0 / 25.0)
        SoRenderManager.enableRealTimeUpdate(False)
Пример #22
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)
Пример #23
0
    def __init__(self, main, action):
        super(FortuneWidget, self).__init__(main, action)
        self.setObjectName("FancyDockWidgetFromCoolPlugin")
        self.setWindowTitle("Sample Python Plugin")

        content = QWidget()
        self.setWidget(content)

        # Create layout and label
        layout = QVBoxLayout(content)
        content.setLayout(layout)
        self.text = QLabel(content)
        self.text.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.text.setFont(CutterBindings.Configuration.instance().getFont())
        layout.addWidget(self.text)

        button = QPushButton(content)
        button.setText("Want a fortune?")
        button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        button.setMaximumHeight(50)
        button.setMaximumWidth(200)
        layout.addWidget(button)
        layout.setAlignment(button, Qt.AlignHCenter)

        QObject.connect(cutter.core(), SIGNAL("seekChanged(RVA)"),
                        self.generate_fortune)
        QObject.connect(button, SIGNAL("clicked()"), self.generate_fortune)

        self.show()
Пример #24
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_()
Пример #25
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.assertTrue(self.called)
Пример #26
0
    def __init__(self, ui_file, parent=None):
        self.remaining_time = 10

        super(Form, self).__init__(parent)
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly)

        loader = QUiLoader()
        self.window = loader.load(ui_file)
        ui_file.close()

        self.btn_clear = self.window.findChild(QPushButton, "btn_clear")
        self.btn_skip = self.window.findChild(QPushButton, "btn_skip")
        self.btn_undo = self.window.findChild(QPushButton, "btn_undo")

        self.label_timer = self.window.findChild(QLabel, "label_timer")
        self.log = self.window.findChild(QPlainTextEdit, "log")
        self.picture_holder = self.window.findChild(QLabel, "picture_holder")
        self.gen_line = QLine()

        self.timer = QTimer(self)
        #self.timer.timeout.connect(self.stop_game)
        self.timer.start(1000)
        #QTimer.singleShot(1000, self.redraw_label_timer)
        QObject.connect(self.timer, SIGNAL('timeout()'),
                        self.redraw_label_timer)

        self.window.show()
Пример #27
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.assertTrue(self.called)
Пример #28
0
    def __init__(self,
                 get_state_cb: typing.Callable,
                 dispatch_cb: typing.Callable,
                 parent: QWidget = None):
        super().__init__(parent)
        self.setMouseTracking(True)

        self._get_state_cb = get_state_cb
        self._dispatch_cb = dispatch_cb
        self._menu_bar = QMenuBar(self)

        self.create_node_action = QAction('Create node', self)
        QObject.connect(
            self.create_node_action, SIGNAL("triggered()"),
            lambda: self._dispatch_cb({
                'Type': 'CreateNode',
                'NodeModel': 'DummyNode',
                'NodeId': 1,
                'Metadata': {
                    'Name': 'New dummy node',
                    'PositionX': 200,
                    'PositionY': 120
                }
            }))

        self.node_menu = QMenu('Node')
        self.node_menu.addAction(self.create_node_action)

        self._menu_bar.addMenu(self.node_menu)

        self._focused_node_id = None
        self._clicked_node_id = None
        self._selected_node_id = None
        self._last_click_pos = None
Пример #29
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
Пример #30
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_()
Пример #31
0
 def __init__(self, mainWindow):
     QListWidget.__init__(self)
     self.spots = []
     self.setFixedWidth(300)
     self.mainWindow = mainWindow
     self.count = 0
     QObject.connect(self, SIGNAL("itemClicked(QListWidgetItem *)"), self.test)
    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)
Пример #33
0
    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 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)
Пример #35
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)
Пример #36
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__);
Пример #37
0
    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 testThread(self):
        t = MyThread()
        QObject.connect(t, SIGNAL("test(const QString&)"), self._callback)
        t.start()

        self.app.exec_()
        t.wait()
        self.assertTrue(self.__called__)
Пример #39
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)
Пример #40
0
 def __init__(self, icon, parent=None):
     QSystemTrayIcon.__init__(self, icon, parent)
     self.menu = QMenu(parent)
     restoreAction = self.menu.addAction("Restaurar Janela")
     exitAction = self.menu.addAction("Exit")
     self.setContextMenu(self.menu)
     QObject.connect(restoreAction, SIGNAL("triggered()"), self.restore)
     QObject.connect(exitAction, SIGNAL("triggered()"), self.exit)
Пример #41
0
    def testDefaultArgs(self):
        #QUdpSocket.readDatagram pythonic return
        # @bug 124
        QObject.connect(self.server, SIGNAL('readyRead()'), self.callback)
        self.sendPackage()
        self.app.exec_()

        self.assertTrue(self.called)
Пример #42
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)
Пример #43
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)
Пример #44
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)
    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)
Пример #46
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)
Пример #47
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)
Пример #48
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())
Пример #49
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())
Пример #50
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)
Пример #51
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())
Пример #52
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)
Пример #53
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)
Пример #54
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)
Пример #55
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))
 def testConnectOldStyleEmitBoolSignal(self):
     def callbackVoid():
         self.void_called = True
     def callbackBool(value):
         self.bool_called = True
     QObject.connect(self.obj, SIGNAL('signalWithDefaultValue()'), callbackVoid)
     QObject.connect(self.obj, SIGNAL('signalWithDefaultValue(bool)'), callbackBool)
     self.obj.emitSignalWithDefaultValue_bool()
     self.assert_(self.void_called)
     self.assert_(self.bool_called)
Пример #58
0
    def testShortCircuitSignals(self):
        #Blocking of Python short-circuit signals
        QObject.connect(self.obj, SIGNAL('mysignal'), self.callback)

        self.obj.emit(SIGNAL('mysignal'))
        self.assert_(self.called)

        self.called = False
        self.obj.blockSignals(True)
        self.obj.emit(SIGNAL('mysignal'))
        self.assert_(not self.called)
    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)
Пример #60
0
    def testTimeoutSignal(self):
        #Test the QTimer timeout() signal
        refCount = sys.getrefcount(self.timer)
        QObject.connect(self.timer, SIGNAL('timeout()'), self.callback)
        self.timer.start(4)
        self.watchdog.startTimer(10)

        self.app.exec_()

        self.assert_(self.called)
        self.assertEqual(sys.getrefcount(self.timer), refCount)