Ejemplo n.º 1
0
    def __init__(self, datalist, comment="", parent=None):
        QWidget.__init__(self, parent)
        layout = QVBoxLayout()
        self.setLayout(layout)
        self.combobox = QComboBox()
        layout.addWidget(self.combobox)
        
        self.stackwidget = QStackedWidget(self)
        layout.addWidget(self.stackwidget)
        if SIGNAL is None:
            self.combobox.currentIndexChanged.connect(self.stackwidget.setCurrentIndex)
        else:
            self.connect(self.combobox, SIGNAL("currentIndexChanged(int)"),
                         self.stackwidget, SLOT("setCurrentIndex(int)"))

        self.result = parent.result 
        self.widget_color = parent.widget_color
        if self.widget_color:
            style = "background-color:" + self.widget_color + ";"
            self.combobox.setStyleSheet(style)
        self.type = parent.type
        self.widgetlist = []
        for data, title, comment in datalist:
            self.combobox.addItem(title)
            widget = FormWidget(data, comment=comment, parent=self)
            self.stackwidget.addWidget(widget)
            self.widgetlist.append((title, widget))
Ejemplo n.º 2
0
 def createEditor(self, parent, option, index):
     spinBox = QSpinBox(parent)
     spinBox.setMinimum(-100000)
     spinBox.setMaximum(100000)
     self.connect(spinBox, SIGNAL("valueChanged(int)"), self,
                  SLOT("valueChanged()"))
     return spinBox
Ejemplo n.º 3
0
def launch():
    """
    Instantiate a new QAplication and mainWindow classes and takes stdin input for savefile name

    :param app: (optional) If given, will not generate a new instance but use the one given, default is None
    :param win: (optional) if given, will not generate a new instance but use the one given, default is None
    :type app: PySide2.QtWidgets.QApplication
    :type app: PySide2.QtWidgets.QMainWindow
    """
    global app
    try:
        app = QApplication(sys.argv)
        app.setApplicationName("partyAlignmentChartTool")
        app.setApplicationDisplayName("Party Alignment Chart Tool")
        app.setApplicationVersion("1.0.2")
        app.setOrganizationName("Julien Alardot")
        win = MainWindow(input("Savefile Name: "))
        win.resize(0, 0)
        app.setWindowIcon(QIcon(os.path.join(PATH, "UI",
                                             "AlignmentTool.icon")))
        app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
        app.setActiveWindow(win)
        app.focusWindow()
        app.exec_()
        app.deleteLater()
        del app

    except Exception:
        tr.print_exc()
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
 def createEditor(self, parent, option, index):
     doubleSpinBox = QDoubleSpinBox(parent)
     doubleSpinBox.setDecimals(5)
     doubleSpinBox.setMinimum(-100000)
     doubleSpinBox.setMaximum(100000)
     self.connect(doubleSpinBox, SIGNAL("valueChanged(float)"), self,
                  SLOT("valueChanged()"))
     return doubleSpinBox
    def testButtonClickClose(self):
        button = QPushButton()
        button.connect(button, SIGNAL('clicked()'), SLOT('close()'))

        button.show()
        self.assertTrue(button.isVisible())
        button.click()
        self.assertTrue(not button.isVisible())
Ejemplo n.º 8
0
 def __init__(self, parent=None):
     QQuickPaintedItem.__init__(self, parent)
     self._circles = []
     self._timer = QTimer()
     QObject.connect(self._timer, SIGNAL('timeout()'), self,
                     SLOT('requestSpecialUpdate()'))
     self._speedRatio = 1.0
     self._timerInterval = 25 * self._speedRatio
     self._label = ''
Ejemplo n.º 9
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # slot button
        self.ui.buttonCompte.clicked.connect(self.on_click_button_compte)
        QObject.connect(self.ui.actionClose, SIGNAL("triggered()"), self,
                        SLOT('on_click_menu_button_close()'))
        QObject.connect(self.ui.actionOuvrir, SIGNAL("triggered()"), self,
                        SLOT('on_click_menu_button_open()'))

        # widget
        self.comptepage = ComptePage()
        self.ui.stack.addWidget(self.comptepage)

        #default page
        self.ui.stack.setCurrentWidget(self.comptepage)
Ejemplo n.º 10
0
 def testWithCppSlot(self):
     '''QMenuBar.addAction(id, object, slot)'''
     menubar = QMenuBar()
     widget = QPushButton()
     widget.setCheckable(True)
     widget.setChecked(False)
     action = menubar.addAction("Accounts", widget, SLOT("toggle()"))
     action.activate(QAction.Trigger)
     self.assertTrue(widget.isChecked())
    def testWindowButtonClickClose(self):
        button = QPushButton()
        window = QWidget()
        window.connect(button, SIGNAL('clicked()'), SLOT('close()'))

        window.show()
        self.assertTrue(window.isVisible())
        button.click()
        self.assertTrue(not window.isVisible())
Ejemplo n.º 12
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.assertTrue(not self.widget.isVisible())

            self.obj.emit(SIGNAL('dummy()'))
            self.assertTrue(self.widget.isVisible())
Ejemplo n.º 13
0
    def __init__(self, parent):
        super().__init__(QIcon("resources/translate-icon.svg"), )
        self.parent = parent
        self.show()

        self.clear_action = QAction("Clear", self)

        self.enable_action = QAction("Enable clipboard translation", self)
        self.enable_action.setCheckable(True)

        self.show_panel_action = QAction("Show panel", self)
        self.show_panel_action.setCheckable(True)

        self.on_top_action = QAction("Always on top", self)
        self.on_top_action.setCheckable(True)

        self.not_fix_action = QAction("Move to avoid mouse", self)
        self.not_fix_action.setCheckable(True)

        self.follow_cursor_action = QAction("Move to follow mouse", self)
        self.follow_cursor_action.setCheckable(True)

        close_action = QAction("Exit", self)

        QObject.connect(self.clear_action, SIGNAL("triggered()"),
                        self.parent.clear_button, SLOT("click()"))

        QObject.connect(self.on_top_action, SIGNAL("triggered(bool)"),
                        self.parent, SLOT("set_on_top(bool)"))

        QObject.connect(self.show_panel_action, SIGNAL("triggered(bool)"),
                        self.parent, SLOT("show_interface(bool)"))

        QObject.connect(self.not_fix_action, SIGNAL("triggered(bool)"),
                        self.parent, SLOT("set_not_fix(bool)"))

        QObject.connect(self.enable_action, SIGNAL("triggered(bool)"),
                        self.parent, SLOT("set_enable(bool)"))

        QObject.connect(self.follow_cursor_action, SIGNAL("triggered(bool)"),
                        self.parent, SLOT("set_follow_cursor(bool)"))

        QObject.connect(close_action, SIGNAL("triggered()"), self.parent,
                        SLOT("close()"))

        menu = QMenu()
        menu.addActions([
            self.clear_action, self.enable_action, self.show_panel_action,
            self.on_top_action, self.not_fix_action, self.show_panel_action,
            self.follow_cursor_action, close_action
        ])
        self.setContextMenu(menu)

        QObject.connect(menu, SIGNAL("aboutToShow()"), self, SLOT("refresh()"))
Ejemplo n.º 14
0
 def data_request(self, request, bparams):
     connection_loop = QEventLoop()
     QObject.connect(self.managerAccess,
                     SIGNAL("finished( QNetworkReply* )"), connection_loop,
                     SLOT("quit()"))
     reply = self.managerAccess.post(request, bparams)
     connection_loop.exec_()  #sleep
     #reply->bytesAvailable();
     #reply.deleteLater()
     return reply
Ejemplo n.º 15
0
def selfCloseInterface(
        message: str,
        time_to_close: int = 2,
        alert_level: int = 1,  # [0,1,2,3]
        title: str = 'Alert',
        info: str = ''
):
    alert = SelfCloseMsgBox(message, alert_level, title, info)
    QTimer.singleShot(time_to_close*1000, alert, SLOT('accept()'))
    return alert.exec_()
Ejemplo n.º 16
0
 def createEditor(self, parent, option, index):
     combo = QComboBox(parent)
     combo.addItems(self.items)
     self.connect(
         combo,
         SIGNAL("currentIndexChanged(int)"),
         self,
         SLOT("currentIndexChanged()"),
     )
     return combo
Ejemplo n.º 17
0
    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)
Ejemplo n.º 18
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
Ejemplo n.º 19
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
Ejemplo n.º 20
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)
Ejemplo n.º 21
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)
Ejemplo n.º 22
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.mainLayout = QGridLayout()
        self.toggleButton = QToolButton()
        self.toggleAnimation = QParallelAnimationGroup()
        self.contentArea = QScrollArea()
        self.headerLine = QFrame()
        self.animationDuration = 300
        self.checked = False

        self.toggleButton.setStyleSheet("QToolButton { border: none; }")
        self.toggleButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        self.toggleButton.setArrowType(Qt.ArrowType.RightArrow)
        self.toggleButton.setText("Title")
        self.toggleButton.setCheckable(True)
        self.toggleButton.setChecked(False)

        self.headerLine.setFrameShape(QFrame.HLine)
        self.headerLine.setFrameShadow(QFrame.Sunken)
        self.headerLine.setSizePolicy(QSizePolicy.Expanding,
                                      QSizePolicy.Maximum)

        self.contentArea.setStyleSheet(
            "QScrollArea { background-color: white; border: none; }")
        self.contentArea.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Fixed)

        self.contentArea.setMaximumHeight(0)
        self.contentArea.setMinimumHeight(0)

        # let the entire widget grow and shrink with its content
        self.toggleAnimation.addAnimation(QPropertyAnimation())
        self.toggleAnimation.addAnimation(QPropertyAnimation(self))
        self.toggleAnimation.addAnimation(
            QPropertyAnimation(self, b"minimumHeight"))
        self.toggleAnimation.addAnimation(
            QPropertyAnimation(self, b"maximumHeight"))
        self.toggleAnimation.addAnimation(
            QPropertyAnimation(self.contentArea, b"maximumHeight"))

        # don't waste space
        self.mainLayout.setVerticalSpacing(0)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        row = 0
        self.mainLayout.addWidget(self.toggleButton, 0, 0, 1, 1, Qt.AlignLeft)
        self.mainLayout.addWidget(self.headerLine, 0, 2, 1, 1)
        self.mainLayout.addWidget(self.contentArea, 1, 0, 1, 3)
        self.setLayout(self.mainLayout)

        self.toggleButton.clicked.connect(self, SLOT("onBtnClicked(c)"))
Ejemplo n.º 23
0
    def createSlider(self, changedSignal, setterSlot):
        slider = QSlider(Qt.Vertical)

        slider.setRange(0, 360 * 16)
        slider.setSingleStep(16)
        slider.setPageStep(15 * 16)
        slider.setTickInterval(15 * 16)
        slider.setTickPosition(QSlider.TicksRight)

        self.glWidget.connect(slider, SIGNAL("valueChanged(int)"), setterSlot)
        self.connect(self.glWidget, changedSignal, slider,
                     SLOT("setValue(int)"))

        return slider
Ejemplo n.º 24
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)
Ejemplo n.º 25
0
 def __init__(self):
     QMainWindow.__init__(self, MaxPlus.GetQMaxMainWindow())
     self.resize(800, 600)
     self.setWindowTitle("Max Tools Updater")
     self.mainWidget = QWidget(self)
     self.central_layout = QVBoxLayout()
     menu_bar = QMenuBar()
     settingAct = QAction("&Settings", self)
     settingAct.setStatusTip("Open setting window")
     settingAct.connect(SIGNAL("triggered()"), self, SLOT("open()"))
     menu_bar.addAction(settingAct)
     self.mainWidget.setLayout(self.central_layout)
     self.central_layout.addWidget(menu_bar)
     self.tabs = QTabWidget()
     self.setCentralWidget(self.mainWidget)
     self.activePackageWidgets = list()
Ejemplo n.º 26
0
 def __init__(self, parent=None):
     QQuickPaintedItem.__init__(self, parent)
     self._oroborusFlag = True
     self._cycleFlag = True
     self._radius = 100
     self._borderOffset = 15
     self._digitsList = []
     self._scale = 0
     self._posX = 0
     self._posY = 0
     self._speedRatio = 1.0
     self._timerInterval = 25 * self._speedRatio
     self._animationIndex = 0
     self._timer = QTimer()
     QObject.connect(self._timer, SIGNAL('timeout()'), self,
                     SLOT('requestSpecialUpdate()'))
     self._dotColor = QColor(Qt.green)
     self._lineWidth = 1
     self._lineColor = QColor(Qt.black)
Ejemplo n.º 27
0
    def testWithoutArgs(self):
        '''Connect QProcess.started() to QTimeLine.togglePaused()'''
        process = QProcess()
        timeline = QTimeLine()

        QObject.connect(process, SIGNAL('finished(int, QProcess::ExitStatus)'),
                        timeline, SLOT('toggleDirection()'))

        orig_dir = timeline.direction()

        process.start(sys.executable, ['-c', '"print 42"'])
        process.waitForFinished()

        new_dir = timeline.direction()

        if orig_dir == QTimeLine.Forward:
            self.assertEqual(new_dir, QTimeLine.Backward)
        else:
            self.assertEqual(new_dir, QTimeLine.Forward)
Ejemplo n.º 28
0
 def __init__(self):
     QWidget.__init__(self)
     self.amtLabel = QLabel('Loan Amount')
     self.roiLabel = QLabel('Rate of Interest')
     self.yrsLabel = QLabel('No. of Years')
     self.emiLabel = QLabel('EMI per month')
     self.emiValue = QLCDNumber()
     self.emiValue.setSegmentStyle(QLCDNumber.Flat)
     self.emiValue.setFixedSize(QSize(130, 30))
     self.emiValue.setDigitCount(8)
     self.amtText = QLineEdit('10000')
     self.roiSpin = QSpinBox()
     self.roiSpin.setMinimum(1)
     self.roiSpin.setMaximum(15)
     self.yrsSpin = QSpinBox()
     self.yrsSpin.setMinimum(1)
     self.yrsSpin.setMaximum(20)
     self.roiDial = QDial()
     self.roiDial.setNotchesVisible(True)
     self.roiDial.setMaximum(15)
     self.roiDial.setMinimum(1)
     self.roiDial.setValue(1)
     self.yrsSlide = QSlider(Qt.Horizontal)
     self.yrsSlide.setMaximum(20)
     self.yrsSlide.setMinimum(1)
     self.calculateButton = QPushButton('Calculate EMI')
     self.myGridLayout = QGridLayout()
     self.myGridLayout.addWidget(self.amtLabel, 0, 0)
     self.myGridLayout.addWidget(self.roiLabel, 1, 0)
     self.myGridLayout.addWidget(self.yrsLabel, 2, 0)
     self.myGridLayout.addWidget(self.amtText, 0, 1)
     self.myGridLayout.addWidget(self.roiSpin, 1, 1)
     self.myGridLayout.addWidget(self.yrsSpin, 2, 1)
     self.myGridLayout.addWidget(self.roiDial, 1, 2)
     self.myGridLayout.addWidget(self.yrsSlide, 2, 2)
     self.myGridLayout.addWidget(self.calculateButton, 3, 1)
     self.setLayout(self.myGridLayout)
     self.setWindowTitle("A simple EMI calculator")
     self.roiDial.valueChanged.connect(self.roiSpin.setValue)
     self.connect(self.roiSpin, SIGNAL("valueChanged(int)"), self.roiDial.setValue)
     self.yrsSlide.valueChanged.connect(self.yrsSpin.setValue)
     self.connect(self.yrsSpin, SIGNAL("valueChanged(int)"),self.yrsSlide, SLOT("setValue(int)"))
     self.connect(self.calculateButton, SIGNAL("clicked()"),self.showEMI)
Ejemplo n.º 29
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)
Ejemplo n.º 30
0
    def __init__(self, size):
        super().__init__()
        self.size = size
        self.grid = q.QGridLayout()
        self.buttons = [[q.QPushButton(" ") for i in range(size)] for j in range(size)]
        self.row = [q.QHBoxLayout() for i in range(size)]
        self.mapper = QSignalMapper()
        self.msw = minesweeper.Minesweeper(size)
        self.mswlog = minesweeperlog.MinesweeperLog()
        for i in range(size):
            for j in range(size):
                # self.buttons[i][j].setEnabled(False)
                self.buttons[i][j].setMaximumSize(30, 30)
                self.buttons[i][j].setMinimumSize(30, 30)
                self.buttons[i][j].setStyleSheet('background-color: blue; color: black')
                self.grid.addWidget(self.buttons[i][j], i, j)
                self.mapper.setMapping(self.buttons[i][j], i * size + j)
                QObject.connect(self.buttons[i][j], SIGNAL('clicked()'), self.mapper, SLOT('map()'))

        QObject.connect(self.mapper, SIGNAL('mapped(int)'), self, SLOT('on_click(int)'))
        self.setLayout(self.grid)
        self.setMaximumSize(35 * size, 35 * size)