Пример #1
0
    def setObjectList(self, objects):
        #        int oldCount = m_objects.count();
        #        beginResetModel();
        #        m_objects = objects;
        #        endResetModel();
        #        emit dataChanged(index(0), index(m_objects.count()));
        #        if (m_objects.count() != oldCount)
        #            emit countChanged();

        oldCount = len(self.m_objects)
        self.beginResetModel()
        self.m_objects = objects
        self.endResetModel()
        QObject.emit(
            self,
            SIGNAL("dataChanged(const QModelIndex&, const QModelIndex &)"),
            self.index(0), self.index(len(self.m_objects)))
        if (len(self.m_objects) != oldCount):
            QObject.emit(self, SIGNAL("countChanged()"))
Пример #2
0
 def append(self, mobject):
     #         beginInsertRows(QModelIndex(), m_objects.count(), m_objects.count());
     #         m_objects.append(object);
     #         endInsertRows();
     #         emit countChanged();
     self.beginInsertRows(QModelIndex(), len(self.m_objects),
                          len(self.m_objects))
     self.m_objects.append(mobject)
     self.endInsertRows()
     QObject.emit(self, SIGNAL("countChanged()"))
Пример #3
0
 def __init__(self, parent, target=defaults.DEFAULT_INPUT):
     super(Microphone, self).__init__(parent)
     self.target = target
     settings = QtMultimedia.QAudioEncoderSettings()
     settings.setCodec('audio/x-raw')
     settings.setChannelCount(1)
     settings.setSampleRate(16000)
     settings.setEncodingOption('pcm-format', 's16le')
     self.setEncodingSettings(settings)
     self.connect(self, SIGNAL('availableAudioInputsChanged()'),
                  self.on_inputs_changed)
Пример #4
0
    def takeAt(self,i):
#        beginRemoveRows(QModelIndex(), i, i);
#        QObject *obj = m_objects.takeAt(i);
#        endRemoveRows();
#        emit countChanged();
#        return obj;
        self.beginRemoveRows(QModelIndex(), i, i)
        obj = self.m_objects.pop(i)
        self.endRemoveRows()
        QObject.emit(self, SIGNAL("countChanged()"))
        return obj
Пример #5
0
    def filter(self, keyword):
        if not keyword or self._raw_func_list is None:
            # remove the filtering
            self._func_list = None
        else:
            self._func_list = [
                func for func in self._raw_func_list
                if self._func_match_keyword(func, keyword)
            ]

        self.emit(SIGNAL("layoutChanged()"))
    def __init__(self, scene, parent):
        super(actionQuitApp, self).__init__(parent)

        self.p_scene = scene
        self.w_parent = parent

        self.setText("Quit")
        self.setShortcut("Ctrl+Q")
        self.setToolTip("Close application")

        self.connect(SIGNAL("triggered()"), self.quitApp)
    def __init__(self, scene, parent):
        super(actionPrintFile, self).__init__(parent)

        self.p_scene = scene
        self.w_parent = parent

        self.setText("Print file")
        self.setShortcut("Ctrl+Shift+P")
        self.setToolTip("Print current file / export to PDF format")

        self.connect(SIGNAL("triggered()"), self.printFile)
Пример #8
0
    def removeAt(self,i, count):
#        beginRemoveRows(QModelIndex(), i, i + count - 1);
#        for (int j = 0; j < count; ++j)
#            m_objects.removeAt(i);
#        endRemoveRows();
#        emit countChanged();
        self.beginRemoveRows(QModelIndex(), i, i + count - 1)
        for j in range(count):
            self.m_objects.pop(i)
        self.endRemoveRows()
        QObject.emit(self, SIGNAL("countChanged()"))
Пример #9
0
    def __init__(self, title, class_pages, parent=None):
        QWizard.__init__(self, parent)
        self.setWindowTitle(title)
        self.resize(800, 600)

        # associate current text to comboboxes fields instead of current index
        self.setDefaultProperty("QComboBox", "currentText",
                                SIGNAL("currentIndexChanged(QString)"))

        for klass in class_pages:
            self.addPage(klass())
Пример #10
0
 def __init__(self, media, parent_widget):
     super(MediaVideo, self).__init__(media, parent_widget)
     self.widget = QWidget(parent_widget)
     self.process = QProcess(self.widget)
     self.process.setObjectName('%s-process' % self.objectName())
     self.std_out = []
     self.errors = []
     self.stopping = False
     self.mute = False
     self.widget.setGeometry(media['geometry'])
     self.connect(self.process, SIGNAL('error()'), self.process_error)
     self.connect(self.process, SIGNAL('finished()'), self.process_finished)
     self.connect(self.process, SIGNAL('started()'), self.process_started)
     self.set_default_widget_prop()
     self.stop_timer = QTimer(self)
     self.stop_timer.setSingleShot(True)
     self.stop_timer.setInterval(1000)
     self.stop_timer.timeout.connect(self.process_timeout)
     #---- kong ---- for RPi
     self.rect = media['geometry']
Пример #11
0
 def createZoomSlider(self, changedSignal, setterSlot):
     slider = QSlider(Qt.Horizontal)
     slider.setRange(10, 400)
     slider.setSingleStep(1)
     slider.setPageStep(10)
     slider.setTickInterval(10)
     slider.setTickPosition(QSlider.TicksBelow)
     self.glWidget.connect(slider, SIGNAL("valueChanged(int)"), setterSlot)
     self.connect(self.glWidget, changedSignal, slider,
                  SLOT("setValue(int)"))
     return slider
Пример #12
0
    def set_layout(self):

        title = QLabel('Festival Ticket Program')
        company_logo = QLabel(self)

        username_label = QLabel('Username: '******'Password: '******'resources/festivity_logo.png')
        company_logo.setPixmap(pixmap)

        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(self.logIn_button)
        hbox.addWidget(self.register_button)

        vbox = QVBoxLayout()
        vbox.addStretch(1)
        vbox.addLayout(hbox)

        grid = QGridLayout()
        grid.setSpacing(10)

        grid.addWidget(title, 1, 1)

        grid.addWidget(company_logo, 2, 1)

        grid.addWidget(username_label, 3, 0)
        grid.addWidget(self.username_edit, 3, 1)

        grid.addWidget(password_label, 4, 0)
        grid.addWidget(self.password_edit, 4, 1)

        grid.addLayout(vbox, 5, 1)

        self.setLayout(grid)
        self.window.show()
    def __init__(self, scene, parent):
        super(actionSaveFile, self).__init__(parent)

        self.p_scene = scene
        self.w_parent = parent

        self.setText("Save file")
        self.setShortcut("Ctrl+S")
        self.setToolTip("Save current file")

        self.connect(SIGNAL("triggered()"), self.saveFile)
Пример #14
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.assertTrue(self.called)
        self.assertEqual(sys.getrefcount(self.timer), refCount)
Пример #15
0
 def limit_handled(self, cursor):
     while True:
         try:
             yield cursor.next()
         except tweepy.RateLimitError:
             print("sleeping on rate limit")
             self.emit(SIGNAL('post_follow(QString)'), "bad")
             self.sleep(15 * 60)
         except StopIteration:
             print("stopiteration")
             return
Пример #16
0
 def testBlockingSignal(self):
     app = QCoreApplication.instance() or QCoreApplication([])
     eventloop = QEventLoop()
     emitter = Emitter()
     receiver = Receiver(eventloop)
     emitter.connect(emitter, SIGNAL("signal(int)"), receiver.receive,
                     Qt.BlockingQueuedConnection)
     emitter.start()
     retval = eventloop.exec_()
     emitter.wait(2000)
     self.assertEqual(retval, 0)
Пример #17
0
    def __init__(self, title):
        QMainWindow.__init__(self)
        self.setWindowTitle(title)

        self.canvas = Canvas()
        self.sideBar = SideBar()

        self.canvas.connect(self.sideBar, SIGNAL("getAllColors(list())"), self.canvas.getAllColors)
        self.canvas.connect(self.sideBar, SIGNAL("setHighlightColor(QColor)"), self.canvas.setHighlightColor)
        self.canvas.connect(self.sideBar, SIGNAL("setTran(float)"), self.canvas.setTran)
        self.canvas.connect(self.sideBar, SIGNAL("onUndo()"), self.canvas.onUndo)

        openFileAct = QAction("Abrir Foto", self)
        openFileAct.triggered.connect(self.canvas.onFileOpen)

        saveFileAct = QAction("Salvar foto", self)
        saveFileAct.triggered.connect(self.canvas.onSaveFile)

        exportBinaryAct = QAction("Salvar máscara", self)
        exportBinaryAct.triggered.connect(self.canvas.exportBinary)

        removeBackgroudAct = QAction("Remover backgroud", self)
        removeBackgroudAct.triggered.connect(self.canvas.onRemoveBackgroud)

        toolbar = self.addToolBar("")
        toolbar.addAction(openFileAct)
        toolbar.addAction(saveFileAct)
        toolbar.addAction(exportBinaryAct)
        toolbar.addAction(removeBackgroudAct)

        toolbar.setMovable(False)

        self.mainlayout = QHBoxLayout(self)
        self.mainlayout.addWidget(self.canvas)
        self.mainlayout.addWidget(self.sideBar)


        mainWidget = QWidget()
        mainWidget.setLayout(self.mainlayout)

        self.setCentralWidget(mainWidget)
Пример #18
0
    def checkColor(self, colorWidget):
        new_idx = 0
        for idx, color in enumerate(self.colorList):
            if colorWidget == color:
                new_idx = idx
                break
        if new_idx != self.currColor:
            if len(self.colorList) > 1:
                self.colorList[self.currColor].QRadioButton.setChecked(False)
            self.currColor = new_idx

        self.emit(SIGNAL("setHighlightColor(QColor)"), colorWidget.QColor)
Пример #19
0
    def test100DynamicSignals(self):

        self.count = 0
        def onSignal():
            self.count += 1

        #create 100 dynamic signals
        o = MyObject()
        for i in range(self.SIGNAL_MAX):
            o.connect(SIGNAL('sig%d()'%i), onSignal)

        #chek if the signals are valid
        m = o.metaObject()
        for i in range(self.SIGNAL_MAX):
            self.assertTrue(m.indexOfSignal('sig%d()'%i) > 0)

        #emit all 100 signals
        for i in range(self.SIGNAL_MAX):
            o.emit(SIGNAL('sig%d()'%i))

        self.assertEqual(self.count, self.SIGNAL_MAX)
    def __init__(self, scene, parent):
        super(actionDelete, self).__init__(parent)

        self.p_scene = scene
        self.w_parent = parent

        #self.setIcon(QtGui.QIcon(os.path.join(APP_PATH, "stylesheets/toolbar/delete.svg")))
        self.setIcon(QtGui.QIcon(":/icons/toolbar/delete.svg"))
        self.setShortcut("Ctrl+D")
        self.setToolTip("Delete selected objects")

        self.connect(SIGNAL("triggered()"), self.delete)
Пример #21
0
 def __init__(self, buttons, parent=None):
     QHBoxLayout.__init__(self)
     self.result = parent.result
     self.dialog = parent.get_dialog()
     for button in buttons:
         label, callback = button
         self.btn = QPushButton(label)
         if SIGNAL is None:
             self.btn.clicked.connect(self.call(callback))
         else:
             self.connect(self.btn, SIGNAL("clicked()"), self.call(callback))
         self.addWidget(self.btn)
Пример #22
0
    def create_actions(self) -> tuple:
        new_act = QAction('New', self)
        new_act.setShortcut(QKeySequence.New)
        new_act.setStatusTip('Create a new sudoku')
        QObject.connect(new_act, SIGNAL('triggered()'), self.new_file)

        open_act = QAction('Open', self)
        open_act.setShortcut(QKeySequence.Open)
        open_act.setStatusTip('Create a sudoku from disc')
        QObject.connect(open_act, SIGNAL('triggered()'), self.open_file)

        save_act = QAction('Save', self)
        save_act.setShortcut(QKeySequence.Save)
        save_act.setStatusTip('Save the current sudoku on disc')
        QObject.connect(save_act, SIGNAL('triggered()'), self.save_file)

        save_as_act = QAction('Save As...', self)
        save_as_act.setStatusTip('Save the current sudoku on disc')
        QObject.connect(save_as_act, SIGNAL('triggered()'), self.save_file_as)

        return new_act, open_act, save_act, save_as_act
Пример #23
0
 def createEditor(self, parent, option, index):
     combo = QTableWidget(1, 3, parent)
     combo.verticalHeader().setVisible(False)
     combo.horizontalHeader().setVisible(False)
     combo.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
     self.connect(
         combo,
         SIGNAL("currentIndexChanged(int)"),
         self,
         SLOT("currentIndexChanged()"),
     )
     return combo
Пример #24
0
    def testSignalStarted(self):
        #QThread.started() (signal)
        obj = Dummy()
        QObject.connect(obj, SIGNAL('started()'), self.cb)
        obj.start()

        self._thread = obj
        QTimer.singleShot(1000, self.abort_application)
        self.app.exec_()

        self.assertEqual(obj.qobj.thread(), obj) # test QObject.thread() method
        self.assertTrue(self.called)
    def __init__(self, scene, pos, parent, snap=None):
        super(actionCreateText, self).__init__(parent)

        self.p_scene = scene
        self.w_parent = parent
        self.a_pos = pos
        self.a_snap = snap

        self.setText("Add text")
        self.setToolTip("Create text item")

        self.connect(SIGNAL("triggered()"), self.addText)
Пример #26
0
        def testSetValue(self):
            """Direct signal emission: QSpinBox using valueChanged(int)/setValue(int)"""
            spinSend = QSpinBox()
            spinRec = QSpinBox()

            spinRec.setValue(5)
            spinSend.setValue(42)

            QObject.connect(spinSend, SIGNAL('valueChanged(int)'), spinRec,
                            SLOT('setValue(int)'))
            self.assertEqual(spinRec.value(), 5)
            self.assertEqual(spinSend.value(), 42)
            spinSend.emit(SIGNAL('valueChanged(int)'), 3)

            self.assertEqual(spinRec.value(), 3)
            #Direct emission shouldn't change the value of the emitter
            self.assertEqual(spinSend.value(), 42)

            spinSend.emit(SIGNAL('valueChanged(int)'), 66)
            self.assertEqual(spinRec.value(), 66)
            self.assertEqual(spinSend.value(), 42)
Пример #27
0
    def __init__(self):
        QMainWindow.__init__(self)

        self.ser.port = sys.argv[1]
        self.ser.baudrate = 115200
        self.ser.timeout = 0.5
        self.ser.write_timeout = 0.5
        self.ser.open()
        if not self.ser.is_open:
            sys.exit(-1)

        self.setWindowTitle("Interface Technology")
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.ui.curve.installEventFilter(self)

        self.timer.start(1000)
        self.connect(self.timer, SIGNAL("timeout()"), self.refresh)
        self.connect(self.timer, SIGNAL("timeout()"), self.update)

        self.ui.setTemp.valueChanged.connect(self.onSetTempChanged)
        self.ui.setWind.valueChanged.connect(self.onSetWindChanged)

        self.ui.checkBox_1.clicked.connect(self.onCheckBoxClicked)
        self.ui.checkBox_2.clicked.connect(self.onCheckBoxClicked)
        self.ui.checkBox_3.clicked.connect(self.onCheckBoxClicked)
        self.ui.checkBox_4.clicked.connect(self.onCheckBoxClicked)
        self.ui.checkBox_5.clicked.connect(self.onCheckBoxClicked)
        self.ui.checkBox_6.clicked.connect(self.onCheckBoxClicked)

        self.tempList = [0 for n in range(0, 61)]

        self.ui.power.setText('%.2f W' % self.curPower)
        self.ui.gear.setText('%d D' % self.curGear)
        #self.send(b'P%d\n' % self.curPower)
        #self.send(b'L%d\n' % self.curGear)

        thread = threading.Thread(target=self.recv, args=[])
        thread.start()
Пример #28
0
    def createEditor(self, parent, option, index):

        item_model = self.model
        index_name = item_model.item(index.row(), 0).text()

        if index_name == DOCUMENT_TYPE:
            self.document_type_row = index.row()
            combo = QComboBox(parent)
            li = list()
            li.append(TYPE_ANY)
            li.append(TYPE_ASSET)
            li.append(TYPE_FOLDER)
            combo.addItems(li)
            self.connect(combo, SIGNAL("currentIndexChanged(int)"), self,
                         SLOT("currentIndexChanged()"))
            return combo
        elif index_name == FORMAT_VALID_DISPLAY:
            self.display_valid_row = index.row()
            combo = QComboBox(parent)
            li = list()
            li.append(VALID_ANY)
            li.append(VALID_TRUE)
            li.append(VALID_FALSE)
            combo.addItems(li)
            self.connect(combo, SIGNAL("currentIndexChanged(int)"), self,
                         SLOT("currentIndexChanged()"))
            return combo
        elif index_name == FORMAT_VALID_PRESERVATION:
            self.preservation_valid_row = index.row()
            combo = QComboBox(parent)
            li = list()
            li.append(VALID_ANY)
            li.append(VALID_TRUE)
            li.append(VALID_FALSE)
            combo.addItems(li)
            self.connect(combo, SIGNAL("currentIndexChanged(int)"), self,
                         SLOT("currentIndexChanged()"))
            return combo
        else:
            return QLineEdit(parent)
    def testSignalFinished(self):
        #QThread.finished() (signal)
        obj = Dummy()
        QObject.connect(obj, SIGNAL('finished()'), self.cb)
        mutex.lock()
        obj.start()
        mutex.unlock()

        self._thread = obj
        QTimer.singleShot(1000, self.abort_application)
        self.app.exec_()

        self.assertTrue(self.called)
Пример #30
0
        def testSetValueIndirect(self):
            """Indirect signal emission: QSpinBox using valueChanged(int)/setValue(int)"""
            spinSend = QSpinBox()
            spinRec = QSpinBox()

            spinRec.setValue(5)

            QObject.connect(spinSend, SIGNAL('valueChanged(int)'), spinRec,
                            SLOT('setValue(int)'))
            self.assertEqual(spinRec.value(), 5)
            spinSend.setValue(3)
            self.assertEqual(spinRec.value(), 3)
            self.assertEqual(spinSend.value(), 3)