def testWithArgs(self):
        '''Connect python signals to QTimeLine.setCurrentTime(int)'''
        timeline = QTimeLine()
        dummy = Dummy()

        QObject.connect(dummy, SIGNAL('dummy(int)'), timeline,
                        SLOT('setCurrentTime(int)'))

        current = timeline.currentTime()
        dummy.emit(SIGNAL('dummy(int)'), current + 42)
        self.assertEqual(timeline.currentTime(), current + 42)
Пример #2
0
    def testSharedSignalEmission(self):
        o = QObject()
        m = MyObject()

        o.connect(SIGNAL("foo2()"), m.mySlot)
        m.connect(SIGNAL("foo2()"), m.mySlot)
        o.emit(SIGNAL("foo2()"))
        self.assertEqual(m._slotCalledCount, 1)
        del o
        m.emit(SIGNAL("foo2()"))
        self.assertEqual(m._slotCalledCount, 2)
    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 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)
Пример #5
0
        def testValueChangedMultiple(self):
            """Multiple emissions 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)

            self.obj.emit(SIGNAL('dummy(int)'), 77)
            self.assertEqual(self.spin.value(), 77)
Пример #6
0
    def testPythonSignals(self):
        #Blocking of Python typed signals
        QObject.connect(self.obj, SIGNAL('mysignal(int,int)'), self.callback)
        self.args = (1, 3)

        self.obj.emit(SIGNAL('mysignal(int,int)'), *self.args)
        self.assert_(self.called)

        self.called = False
        self.obj.blockSignals(True)
        self.obj.emit(SIGNAL('mysignal(int,int)'), *self.args)
        self.assert_(not self.called)
Пример #7
0
    def testBasic(self):
        '''Interrupt and resume evaluation with QScriptEngineDebugger'''

        self.debugger.attachTo(self.engine)
        self.debugger.setAutoShowStandardWindow(False)
        self.debugger.connect(SIGNAL('evaluationSuspended()'), self.suspended)
        self.debugger.connect(SIGNAL('evaluationResumed()'), self.resumed)

        self.debugger.action(QScriptEngineDebugger.InterruptAction).trigger()
        self.engine.evaluate("3+4\n2+1\n5+1")
        self.assert_(self.has_resumed >= 1)
        self.assert_(self.has_suspended >= 1)
Пример #8
0
    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)
Пример #9
0
 def run(self):
     try:
         self.emit(SIGNAL("updateStatusBar(QString)"),
                   "Copying to minecraft directory")
         shutil.copyfile(self.source, self.destination)
         self.emit(SIGNAL("updateStatusBar(QString)"),
                   "Copied successfully")
         time.sleep(5)
     except IOError:
         self.emit(SIGNAL("updateStatusBar(QString)"),
                   "Error occurred, please check the file paths used")
         time.sleep(5)
     self.emit(SIGNAL("defaultStatusBar()"))
     self.quit()
Пример #10
0
    def testSegfault(self):
        """Regression: Segfault for qobjects in the same memory position."""
        obj = Dummy()
        QObject.connect(obj, SIGNAL('bar(int)'), self.callback)
        self.args = (33, )
        obj.emit(SIGNAL('bar(int)'), self.args[0])
        self.assert_(self.called)
        del obj

        obj = Joe()
        QObject.connect(obj, SIGNAL('bar(int)'), self.callback)
        self.args = (33, )
        obj.emit(SIGNAL('bar(int)'), self.args[0])
        self.assert_(self.called)
Пример #11
0
    def testDisconnectCleanup(self):
        for c in range(MAX_LOOPS):
            self._count = 0
            self._senders = []
            for i in range(MAX_OBJECTS):
                o = QObject()
                QObject.connect(o, SIGNAL("fire()"), lambda: self.myCB())
                self._senders.append(o)
                o.emit(SIGNAL("fire()"))

            self.assertEqual(self._count, MAX_OBJECTS)

            #delete all senders will disconnect the signals
            self._senders = []
Пример #12
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(0,0,0,0)
        self._iconView = QdThumbnailView(self)
        self._progress = QtGui.QProgressBar(self)
        self._progress.setFormat("Generating thumbnails: %v of %m")
        self._progress.hide()

        layout.addWidget(self._iconView)
        layout.addWidget(self._progress)

        self.connect(self._iconView, SIGNAL('doubleClicked(QString)'), self._itemDoubleClicked)
        self.connect(self._iconView, SIGNAL('loading(int)'), self.updateProgress)
def createTextToolbar(self):
    """
    TOWRITE
    """
    toolbarText = self.toolbarText
    actionHash = self.actionHash
    prompt = self.prompt
    textSizeSelector = self.textSizeSelector
    textFontSelector = self.textFontSelector
    qDebug("MainWindow createTextToolbar()")

    toolbarText.setObjectName("toolbarText")

    toolbarText.addWidget(textFontSelector)
    textFontSelector.setCurrentFont(QFont(self.getSettingsTextFont()))
    self.connect(textFontSelector, SIGNAL("currentFontChanged(QFont)"), self, SLOT("textFontSelectorCurrentFontChanged(QFont)"))

    toolbarText.addAction(actionHash["ACTION_textbold"])
    ## print('DEBUG', self.getSettingsTextStyleBold())
    #TODO/PORT TypeError# actionHash["ACTION_textbold"].setChecked(self.getSettingsTextStyleBold())
    toolbarText.addAction(actionHash["ACTION_textitalic"])
    #TODO/PORT TypeError# actionHash["ACTION_textitalic"].setChecked(self.getSettingsTextStyleItalic())
    toolbarText.addAction(actionHash["ACTION_textunderline"])
    #TODO/PORT TypeError# actionHash["ACTION_textunderline"].setChecked(self.getSettingsTextStyleUnderline())
    toolbarText.addAction(actionHash["ACTION_textstrikeout"])
    #TODO/PORT TypeError# actionHash["ACTION_textstrikeout"].setChecked(self.getSettingsTextStyleStrikeOut())
    toolbarText.addAction(actionHash["ACTION_textoverline"])
    #TODO/PORT TypeError# actionHash["ACTION_textoverline"].setChecked(self.getSettingsTextStyleOverline())

    textSizeSelector.setFocusProxy(prompt)
    textSizeSelector.addItem("6 pt",   6)
    textSizeSelector.addItem("8 pt",   8)
    textSizeSelector.addItem("9 pt",   9)
    textSizeSelector.addItem("10 pt", 10)
    textSizeSelector.addItem("11 pt", 11)
    textSizeSelector.addItem("12 pt", 12)
    textSizeSelector.addItem("14 pt", 14)
    textSizeSelector.addItem("18 pt", 18)
    textSizeSelector.addItem("24 pt", 24)
    textSizeSelector.addItem("30 pt", 30)
    textSizeSelector.addItem("36 pt", 36)
    textSizeSelector.addItem("48 pt", 48)
    textSizeSelector.addItem("60 pt", 60)
    textSizeSelector.addItem("72 pt", 72)
    self.setTextSize(self.getSettingsTextSize())
    toolbarText.addWidget(textSizeSelector)
    self.connect(textSizeSelector, SIGNAL("currentIndexChanged(int)"), self, SLOT("textSizeSelectorIndexChanged(int)"))

    self.connect(toolbarText, SIGNAL("topLevelChanged(bool)"), self, SLOT("floatingChangedToolBar(bool)"))
Пример #14
0
    def run(self):
        if self.ui.cb_batch.isChecked():
            self.last_log_file = None
        else:
            f_next, _ = os.path.splitext(str(self.ui.edit_file.text()))        
            f_params = f_next + '.params'
            if not os.path.exists(f_params):
                self.create_params_file(f_params)
                self.ui.btn_param.setEnabled(True)
                return
            self.last_log_file = f_next + '.log'
        
        if self.ui.tabWidget.currentIndex() == 0:
            args = self.command_line_args()
        elif self.ui.tabWidget.currentIndex() == 1:
            args = self.gui_command_line_args()
        
        self.update_result_tab()

        # # Start process
        self.ui.edit_stdout.clear()
        format = self.ui.edit_stdout.currentCharFormat()
        format.setFontWeight(QFont.Normal)
        format.setForeground(QtCore.Qt.blue)
        self.ui.edit_stdout.setCurrentCharFormat(format)
        time_str = datetime.datetime.now().ctime()
        start_msg = '''\
                       Starting spyking circus at {time_str}.

                       Command line call:
                       {call}
                    '''.format(time_str=time_str, call=' '.join(args))
        self.ui.edit_stdout.appendPlainText(textwrap.dedent(start_msg))
        format.setForeground(QtCore.Qt.black)
        self.ui.edit_stdout.setCurrentCharFormat(format)
        self.ui.edit_stdout.appendPlainText('\n')

        self.process = QProcess(self)
        self.connect(self.process, SIGNAL('readyReadStandardOutput()'), self.append_output)
        self.connect(self.process, SIGNAL('readyReadStandardError()'),
                     self.append_error)
        self.connect(self.process, SIGNAL('started()'),
                     self.process_started)
        self.connect(self.process, SIGNAL('finished(int)'),
                     self.process_finished)
        self.connect(self.process, SIGNAL('error()'),
                     self.process_errored)
        self._interrupted = False
        self.process.start(args[0], args[1:])
Пример #15
0
    def testWithoutArgs(self):
        '''Connect python signal to QTimeLine.toggleDirection()'''
        timeline = QTimeLine()
        dummy = Dummy()
        QObject.connect(dummy, SIGNAL('dummy()'),
                        timeline, SLOT('toggleDirection()'))

        orig_dir = timeline.direction()
        dummy.emit(SIGNAL('dummy()'))
        new_dir = timeline.direction()

        if orig_dir == QTimeLine.Forward:
            self.assertEqual(new_dir, QTimeLine.Backward)
        else:
            self.assertEqual(new_dir, QTimeLine.Forward)
Пример #16
0
 def run(self):
     #initial
     self.tool.fetchServerChat()
     time.sleep(0.5)
     self.emit(SIGNAL('update(QString)'), "done")
     while not self.stopped:
         try:
             self.tool.fetchPlayers()
             self.tool.fetchChat()
             self.tool.fetchInfo()
             self.tool.runTasks()
             self.emit(SIGNAL('update(QString)'), "done")
             time.sleep(2)
         except:  #retry a connection
             self.tool.reconnect()
Пример #17
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        layout = QVBoxLayout(self)
        horiz_layout = QHBoxLayout()
        self.conditional_legend_widget = EdgeWidget(self, True)
        self.conditional_legend_widget.setMinimumHeight(15)
        horiz_layout.addWidget(self.conditional_legend_widget)

        self.conditional_legend_label = QLabel("Conditional transition", self)
        horiz_layout.addWidget(self.conditional_legend_label)

        self.unconditional_legend_widget = EdgeWidget(self, False)
        self.unconditional_legend_widget.setMinimumHeight(15)
        horiz_layout.addWidget(self.unconditional_legend_widget)
        self.unconditional_legend_label = QLabel("Non-conditional transition",
                                                 self)
        horiz_layout.addWidget(self.unconditional_legend_label)

        layout.addLayout(horiz_layout)

        self.splitter = QSplitter(self)

        layout.addWidget(self.splitter)

        self.view = ClassyView(self.splitter)
        # layout.addWidget(self.view)
        self.scene = ClassyScene(self)
        self.view.setScene(self.scene)

        self._menu_bar = QMenuBar(self)
        self._menu = QMenu("&File")
        self._menu_bar.addMenu(self._menu)
        layout.setMenuBar(self._menu_bar)

        self.open_action = QAction("O&pen", self)
        self.exit_action = QAction("E&xit", self)
        self._menu.addAction(self.open_action)
        self._menu.addAction(self.exit_action)

        self.connect(self.open_action, SIGNAL("triggered()"), self.open_file)
        self.connect(self.exit_action, SIGNAL("triggered()"), self.close)

        self.settings = QSettings("CD Projekt RED", "TweakDB")

        self.log_window = QPlainTextEdit(self.splitter)
        self.splitter.setOrientation(Qt.Vertical)

        self.setWindowTitle("Classy nodes")
Пример #18
0
def main(argv=None):
    if argv is None:
        argv = sys.argv

    app = QApplication(argv)
    engine = QScriptEngine()

    if HAS_DEBUGGER:
        debugger = QScriptEngineDebugger()
        debugger.attachTo(engine)
        debugWindow = debugger.standardWindow()
        debugWindow.resize(1024, 640)

    scriptFileName = './calculator.js'
    scriptFile = QFile(scriptFileName)
    scriptFile.open(QIODevice.ReadOnly)
    engine.evaluate(unicode(scriptFile.readAll()), scriptFileName)
    scriptFile.close()

    loader = QUiLoader()
    ui = loader.load(':/calculator.ui')

    ctor = engine.evaluate('Calculator')
    scriptUi = engine.newQObject(ui, QScriptEngine.ScriptOwnership)
    calc = ctor.construct([scriptUi])

    if HAS_DEBUGGER:
        display = ui.findChild(QLineEdit, 'display')
        display.connect(display, SIGNAL('returnPressed()'), debugWindow,
                        SLOT('show()'))

    ui.show()
    return app.exec_()
Пример #19
0
    def __init__(self, worldviewer, parent=None):
        global client
        super(WorldViewerDebug, self).__init__(parent)

        self.setWindowTitle("World Viewer Debug")
        pos = QApplication.instance().desktop().availableGeometry()
        self.move(pos.width() / 2, 0)

        self.worldviewer = worldviewer

        self.objects_tree = QTreeWidget()
        self.objects_tree.setColumnCount(2)
        self.objects_tree.setHeaderLabels([
            "ID", "Name", "Location", "Resource", "Last Modified",
            "Dist to Player"
        ])
        self.objects_tree.setSortingEnabled(True)

        layout = QVBoxLayout()
        for w in (self.objects_tree, ):
            layout.addWidget(w)
        self.setLayout(layout)

        self.obj_update_timer = QTimer(self)
        self.connect(self.obj_update_timer, SIGNAL("timeout()"), self.update)
        self.obj_update_timer.start(CLIENT_UPDATE_FREQ)
Пример #20
0
    def __init__(self, imageOptions=None, parent=None):
        QtCore.QObject.__init__(self, parent)
        self._imageOptions = imageOptions

        self._threads = []
        for i in range(QtCore.QThread.idealThreadCount()):
            thread = QdImageLoaderThread(self)
            self._threads.append(thread)
            self.connect(thread, SIGNAL('loaded(QString, QImage)'), self.loaded)
            self.connect(thread, SIGNAL('finished()'), self.threadFinished)
        self._stopped = True

        self._paths = []
        self._index = 0

        self.connect( QtGui.QApplication.instance(), SIGNAL('lastWindowClosed()'), self.stopLoading )
Пример #21
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_()
Пример #22
0
    def __init__(self, parent=None):
        super(LoginForm, self).__init__(parent)
        self.setWindowTitle("Login")

        self.status_icon = QIcon.fromTheme("user-offline")
        self.setWindowIcon(self.status_icon)

        self.server_status = QLabel()
        self.server_status.setAlignment(Qt.AlignCenter)
        self.server_status.setPixmap(self.status_icon.pixmap(64))

        self.username = QLineEdit("Username")

        self.password = QLineEdit("Password")
        self.password.setEchoMode(QLineEdit.Password)

        self.login_button = QPushButton("Getting server status...")
        self.login_button.setEnabled(False)
        self.login_button.clicked.connect(self.login)
        self.login_button.setIcon(self.status_icon)

        self.ping_timer = QTimer(self)
        self.connect(self.ping_timer, SIGNAL("timeout()"), self.is_server_up)
        self.ping_timer.start(1000)

        layout = QVBoxLayout()
        for w in (self.server_status, self.username, self.password,
                  self.login_button):
            layout.addWidget(w)
        self.setLayout(layout)

        self.logged_in.connect(qtclient.login)
Пример #23
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)
    def setData(self, index, value, role=Qt.EditRole):
        if index.isValid() and 0 <= index.row() < len(self.compartments):
            compartment = self.compartments[index.row()].Item
            column = index.column()
            if column == COLUMN.NAME:
                compartment.setName(str(value))
            elif column == COLUMN.ID:
                compartment.setId(str(value))
            elif column == COLUMN.COMPARTMENTTYPE:
                compartment.setCompartmentType(str(value))
            elif column == COLUMN.SPATIALDIMENSIONS:
                compartment.setSpatialDimensions(
                    int(value))  # TODO: Does not work. Why?
            elif column == COLUMN.SIZE:
                compartment.setSize(float(value))
            elif column == COLUMN.UNITS:
                compartment.setUnits(str(value))
            elif column == COLUMN.OUTSIDE:
                compartment.setOutside(str(value))
            elif column == COLUMN.CONSTANT:
                compartment.setConstant(bool(value))

            self.Dirty = True
            self.emit(SIGNAL("dataChanged(QModelIndex, QModelIndex)"), index,
                      index)
            return True
        return False
Пример #25
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
Пример #26
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)
Пример #27
0
    def invertSelection(self):

        self.emit(SIGNAL("layoutAboutToBeChanged()"))

        for column in xrange(1, self.columnCount()):
            for row in xrange(self.rowCount()):
                if self.dataMatrix[column][row] == STATE.NODATA:
                    continue

                if self.dataMatrix[column][row] == STATE.CHECKED:
                    self.dataMatrix[column][row] = STATE.UNCHECKED
                else:
                    self.dataMatrix[column][row] = STATE.CHECKED

        self.emit(SIGNAL("layoutChanged()"))
        self.dataChanged.emit(QModelIndex(), QModelIndex())
Пример #28
0
	def UpdateWidgetFromRenderWidget(self):
		"""
		Update the parameter widget with a widget from the render widget.
		"""
		# Add the scroll area for the parameter widget if it is not there yet
		layout = self.layout()
		if layout.indexOf(self.scrollArea) == -1:
			layout.addWidget(self.scrollArea, 1, 0, 1, 2)
			self.setLayout(layout)

		# Clear the previous parameter widget
		if self.paramWidget is not None:
			self.paramWidget.setParent(None)
			if self.renderController.visualization is not None:
				self.renderController.visualization.disconnect(SIGNAL("updatedTransferFunction"), self.transferFunctionChanged)

		# Get a new parameter widget from the render widget
		self.paramWidget = self.renderController.getParameterWidget()
		Style.styleWidgetForTab(self.paramWidget)
		self.scrollArea.setWidget(self.paramWidget)

		if self.renderController.visualization is not None:
			self.renderController.visualization.updatedTransferFunction.connect(self.transferFunctionChanged)

		self.visTypeComboBox.setCurrentIndex(self.visTypeComboBox.findText(self.renderController.visualizationType))
    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 testConnectOldStyleEmitBoolSignal(self):
        def callbackOne():
            self.one_called += 1
            self.obj2.signalWithDefaultValue[bool].emit(True)

        def callbackTwo():
            self.two_called += 1

        QObject.connect(self.obj1, SIGNAL('signalWithDefaultValue()'),
                        callbackOne)
        QObject.connect(self.obj2, SIGNAL('signalWithDefaultValue()'),
                        callbackTwo)
        self.obj1.emitSignalWithDefaultValue_void()
        self.obj2.emitSignalWithDefaultValue_void()
        self.assertEqual(self.one_called, 1)
        self.assertEqual(self.two_called, 2)