Пример #1
0
    def createState(self):
        # state defintion
        mainState = QState(self.fsm)
        finalState = QFinalState(self.fsm)
        self.fsm.setInitialState(mainState)

        initState = QState(mainState)
        standbyState = QState(mainState)

        #transition defition
        mainState.setInitialState(initState)
        mainState.addTransition(self.sigStateStop, finalState)

        initState.addTransition(self.sigInitOk, standbyState)
        standbyState.addTransition(self.sigError, initState)

        # #state entered slot connect
        mainState.entered.connect(self.mainStateEntered)
        initState.entered.connect(self.initStateEntered)
        standbyState.entered.connect(self.standbyStateEntered)
        finalState.entered.connect(self.finalStateEntered)

        #fsm start
        self.fsm.start()

        pass
Пример #2
0
    def makeState(self, parentState, animationFileName):
        topLevel = QState(parentState)

        animation = Animation()

        file = QFile(animationFileName)
        if file.open(QIODevice.ReadOnly):
            animation.load(file)

        frameCount = animation.totalFrames()
        previousState = None
        for i in range(frameCount):
            animation.setCurrentFrame(i)

            frameState = QState(topLevel)
            nodeCount = animation.nodeCount()
            for j in range(nodeCount):
                frameState.assignProperty(self.m_stickMan.node(j), 'pos',
                                          animation.nodePos(j))

            frameState.setObjectName('frame %d' % i)

            if previousState is None:
                topLevel.setInitialState(frameState)
            else:
                previousState.addTransition(previousState.propertiesAssigned,
                                            frameState)

            previousState = frameState

        previousState.addTransition(previousState.propertiesAssigned,
                                    topLevel.initialState())

        return topLevel
Пример #3
0
 def createState(self):
     mainState = QState(self.fsm)
     connectedState = QState(QtCore.QState.ParallelStates, mainState)
     processBuyState = QState(connectedState)
     determineBuyProcessBuyState = QState(processBuyState)
     waitingTRlimitProcessBuyState = QState(processBuyState)
     print(determineBuyProcessBuyState)
     determineBuyProcessBuyState.addTransition(self.sigNoBuy, waitingTRlimitProcessBuyState)
     determineBuyProcessBuyState.addTransition(self.sigBuy, waitingTRlimitProcessBuyState)
     self.test_buy()
     determineBuyProcessBuyState.entered.connect(self.determineBuyProcessBuyStateEntered)
Пример #4
0
    def __init__(self, stickMan, keyReceiver):
        self.m_stickMan = stickMan
        self.m_keyReceiver = keyReceiver

        # Create animation group to be used for all transitions.
        self.m_animationGroup = QParallelAnimationGroup()
        stickManNodeCount = self.m_stickMan.nodeCount()
        self._pas = []
        for i in range(stickManNodeCount):
            pa = QPropertyAnimation(self.m_stickMan.node(i), 'pos')
            self._pas.append(pa)
            self.m_animationGroup.addAnimation(pa)

        # Set up intial state graph.
        self.m_machine = QStateMachine()
        self.m_machine.addDefaultAnimation(self.m_animationGroup)

        self.m_alive = QState(self.m_machine)
        self.m_alive.setObjectName('alive')

        # Make it blink when lightning strikes before entering dead animation.
        lightningBlink = QState(self.m_machine)
        lightningBlink.assignProperty(self.m_stickMan.scene(),
                                      'backgroundBrush', Qt.white)
        lightningBlink.assignProperty(self.m_stickMan, 'penColor', Qt.black)
        lightningBlink.assignProperty(self.m_stickMan, 'fillColor', Qt.white)
        lightningBlink.assignProperty(self.m_stickMan, 'isDead', True)

        timer = QTimer(lightningBlink)
        timer.setSingleShot(True)
        timer.setInterval(100)
        lightningBlink.entered.connect(timer.start)
        lightningBlink.exited.connect(timer.stop)

        self.m_dead = QState(self.m_machine)
        self.m_dead.assignProperty(self.m_stickMan.scene(), 'backgroundBrush',
                                   Qt.black)
        self.m_dead.assignProperty(self.m_stickMan, 'penColor', Qt.white)
        self.m_dead.assignProperty(self.m_stickMan, 'fillColor', Qt.black)
        self.m_dead.setObjectName('dead')

        # Idle state (sets no properties).
        self.m_idle = QState(self.m_alive)
        self.m_idle.setObjectName('idle')

        self.m_alive.setInitialState(self.m_idle)

        # Lightning strikes at random.
        self.m_alive.addTransition(LightningStrikesTransition(lightningBlink))
        lightningBlink.addTransition(timer.timeout, self.m_dead)

        self.m_machine.setInitialState(self.m_alive)
Пример #5
0
 def _make_initial_state(self, form) -> QState:
     s = QState()
     s.assignProperty(form.editBtn, "enabled", False)
     s.assignProperty(form.saveBtn, "enabled", False)
     s.assignProperty(form.deviceList, "enabled", False)
     s.assignProperty(form.addressEdit, "enabled", True)
     return s
Пример #6
0
    def my_ui(self):
        v_box = QVBoxLayout()
        config_box = QGroupBox('配置')
        grid = QGridLayout()
        label_one = QLabel('当前状态')
        self.choose_button = QPushButton()
        self.machine = QStateMachine()
        zoom_state = QState(self.machine)
        shrink_state = QState(self.machine)
        self.machine.setInitialState(zoom_state)
        zoom_state.assignProperty(self.choose_button, 'text', '放大')
        shrink_state.assignProperty(self.choose_button, 'text', '缩小')
        shrink_state.addTransition(self.choose_button.clicked, zoom_state)
        zoom_state.addTransition(self.choose_button.clicked, shrink_state)
        self.machine.start()
        grid.addWidget(label_one, 0, 0)
        grid.addWidget(self.choose_button, 0, 1)

        grid.addWidget(QLabel('倍数'), 1, 0)
        slider = QSlider(Qt.Horizontal)
        slider.setMaximum(5)
        slider.setMinimum(1)
        slider.setTickInterval(1)
        slider.setTickPosition(QSlider.TicksBothSides)
        slider.setSingleStep(1)
        slider.valueChanged.connect(self.value_deal)
        grid.addWidget(slider, 1, 1)

        kind = QComboBox()
        for v in self.kinds:
            kind.addItem(v)
        kind.activated.connect(self.choosed)
        grid.addWidget(QLabel('类别:'), 2, 0)
        grid.addWidget(kind, 2, 1)

        button_show = QPushButton('显示')
        button_show.clicked.connect(self.show_image)

        config_box.setLayout(grid)
        v_box.addWidget(config_box)
        v_box.addWidget(button_show)
        self.setLayout(v_box)
        self.resize(10, 300)
        self.show()
Пример #7
0
    def init_ui(self):
        vbox = QVBoxLayout()

        button1 = QPushButton('fuck1')

        vbox.addWidget(button1)

        button1.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        vbox.setContentsMargins(80, 80, 80, 80)

        self.setLayout(vbox)

        machine = QStateMachine(self)
        s1 = QState()
        s1.assignProperty(button1, "text", "Outside")
        s2 = QState()
        s2.assignProperty(button1, "text", "Inside")

        enter_transition = QEventTransition(button1, QEvent.Enter)
        enter_transition.setTargetState(s2)
        s1.addTransition(enter_transition)

        leave_transition = QEventTransition(button1, QEvent.Leave)
        leave_transition.setTargetState(s1)
        s2.addTransition(leave_transition)

        s3 = QState()
        s3.assignProperty(button1, 'text', 'Pressing...')

        press_transition = QEventTransition(button1, QEvent.MouseButtonPress)
        press_transition.setTargetState(s3)
        s2.addTransition(press_transition)

        release_transition = QEventTransition(button1,
                                              QEvent.MouseButtonRelease)
        release_transition.setTargetState(s2)
        s3.addTransition(release_transition)

        machine.addState(s1)
        machine.addState(s2)
        machine.addState(s3)

        machine.setInitialState(s1)
        machine.start()
Пример #8
0
def createGeometryState(w1, rect1, w2, rect2, w3, rect3, w4, rect4, parent):
    result = QState(parent)

    result.assignProperty(w1, 'geometry', rect1)
    result.assignProperty(w1, 'geometry', rect1)
    result.assignProperty(w2, 'geometry', rect2)
    result.assignProperty(w3, 'geometry', rect3)
    result.assignProperty(w4, 'geometry', rect4)

    return result
Пример #9
0
    def Home(self):
        self.items = []
        for i in range(len(self.names['home'])):
            item = QPushButton(self)
            item.setText(self.names['home'][i])
            item.setGeometry(395, 350, 120, 80)
            item.setStyleSheet(
                "QPushButton:hover{background-color:rgb(241, 90, 36);border:5px solid rgb(0, 97, 157);}\n"
                "QPushButton{color:white;background-color: rgb(50, 50, 50);border:5px solid rgb(255, 255, 255);}QPushButton:pressed{color:white;background-color: rgb(50, 50, 50);border:5px solid rgb(255, 255, 255);}\n"
                "")
            self.font.setPointSize(15)
            item.setFont(self.font)
            self.items.append(item)
            exec("""item.clicked.connect(partial(self.IND,i=%i))""" % (i))

        self.rootState = QState()
        self.tiledState = QState(self.rootState)
        self.centeredState = QState(self.rootState)
        for i, item in enumerate(self.items):
            self.tiledState.assignProperty(
                item, 'pos',
                QPointF(((i % 6) * 5.3) * 30, ((i // 6) * 5.3) * 30))

            self.centeredState.assignProperty(item, 'pos', QPointF())

        self.states = QStateMachine()
        self.states.addState(self.rootState)
        self.states.setInitialState(self.rootState)
        self.rootState.setInitialState(self.centeredState)
        self.group = QParallelAnimationGroup()
        for i, item in enumerate(self.items):
            anim = QPropertyAnimation(item, b'pos')
            anim.setStartValue(QPoint(400, 300))
            anim.setDuration(750 + i * 25)
            anim.setEasingCurve(QEasingCurve.InOutBack)
            self.group.addAnimation(anim)

        for u in self.items:
            trans = self.rootState.addTransition(u.clicked, self.tiledState)
            trans.addAnimation(self.group)
            self.states.start()
Пример #10
0
 def init_log_sm(self):
     self.log_state = QStateMachine()
     pre_system = QState()
     pre_event = QState()
     post_event = QState()
     self.log_state.addState(pre_system)
     self.log_state.addState(pre_event)
     self.log_state.addState(post_event)
     self.log_state.setInitialState(pre_system)
     pre_system.assignProperty(self.events, "enabled", False)
     pre_system.assignProperty(self.compass, "enabled", False)
     pre_system.assignProperty(self.exact_angle, "enabled", False)
     pre_event.assignProperty(self.events, "enabled", True)
     pre_event.assignProperty(self.compass, "enabled", False)
     pre_event.assignProperty(self.exact_angle, "enabled", False)
     post_event.assignProperty(self.compass, "enabled", True)
     post_event.assignProperty(self.exact_angle, "enabled", True)
     pre_system.addTransition(
         self.systems.acted, pre_event
     )
     pre_system.addTransition(self.timeout_timer.timeout, pre_system)
     pre_event.addTransition(self.timeout_timer.timeout, pre_system)
     post_event.addTransition(self.timeout_timer.timeout, pre_system)
     pre_event.addTransition(
         self.systems.acted, pre_event
     )
     post_event.addTransition(
         self.systems.acted, pre_event
     )
     post_event.addTransition(
         self.events.acted, post_event
     )
     pre_event.addTransition(
         self.events.acted, post_event
     )
     pre_system.entered.connect(self.events.switch_active)
     pre_system.entered.connect(self.systems.switch_active)
     pre_event.entered.connect(self.events.switch_active)
     post_event.exited.connect(self.compass.clear_state)
     post_event.exited.connect(lambda: self.exact_angle.log_angle(False))
     self.log_state.setRunning(True)
Пример #11
0
    def _make_dev_fetched_state(self, form) -> QState:
        s = QState()
        s.assignProperty(form.editBtn, "enabled", True)
        s.assignProperty(form.deviceList, "enabled", True)
        s.assignProperty(form.saveBtn, "enabled", False)
        s.assignProperty(form.portEdit, "enabled", False)
        s.assignProperty(form.addressEdit, "enabled", False)
        s.assignProperty(form.usernameEdit, "enabled", False)
        s.assignProperty(form.sshKeyEdit, "enabled", False)
        s.assignProperty(form.autostartCheckBox, "enabled", False)

        s.assignProperty(form.typeList, "enabled", False)
        return s
Пример #12
0
def twoStateButton(name,stateMachine,action,*states):
    st = QStateMachine()

    a1,a2 = states
    s1,s2 = QState(),QState()
    icon1 = QIcon(Icons + a1[1])
    icon2 = QIcon(Icons + a2[1])
    s1.setObjectName(a1[0])
    s2.setObjectName(a2[0])
    s1.assignProperty(action, "icon", icon1)
    s2.assignProperty(action, "icon", icon2)
    s1.assignProperty(action, "text", a1[0])
    s2.assignProperty(action, "text", a2[0])

    s1.addTransition(action.triggered, s2)
    s2.addTransition(action.triggered, s1)
    st.addState(s1)
    st.addState(s2)
    st.setInitialState(s1)

    stateMachine[name] = st
    st.start()
    def gen_output_widget(self):

        if self._name != "__none__":

            # Each output is a tuple [QPushButton, QStateMachine]
            self.output_widget = (QPushButton(), QStateMachine())
            self.output_widget[0].setStyleSheet(
                "background-color: #dddddd; border-style: solid; border-width: 1px; border-color: #aaaaaa; padding: 7px;"
            )

            # Create output states
            output_off = QState()
            output_on = QState()

            # Attach states to output button and define state transitions
            output_off.assignProperty(self.output_widget[0], 'text',
                                      "%s Output On" % self._name.split()[1])
            output_off.addTransition(self.output_widget[0].clicked, output_on)
            output_off.entered.connect(self.exec_output_off)

            output_on.assignProperty(self.output_widget[0], 'text',
                                     '%s Output Off' % self._name.split()[1])
            output_on.addTransition(self.output_widget[0].clicked, output_off)
            output_on.entered.connect(self.exec_output_on)

            # Add states, set initial state, and start machine
            self.output_widget[1].addState(output_off)
            self.output_widget[1].addState(output_on)
            self.output_widget[1].setInitialState(output_off)
            self.output_widget[1].start()

        else:

            self.output_widget = (QPushButton(), False)
            self.output_widget[0].setStyleSheet(
                "background-color: #dddddd; border-style: solid; border-width: 1px; border-color: #aaaaaa; padding: 7px;"
            )
            self.output_widget[0].setEnabled(False)
            self.output_widget[0].setText("Keithley not Initialized")
Пример #14
0
    def __init__(self):
        QWidget.__init__(self)

        style1 = "background-color: red"
        style2 = "background-color: black"

        animation = QPropertyAnimation(self, b'styleSheet')
        animation.setDuration(5)

        state1 = QState()
        state2 = QState()
        state1.assignProperty(self, 'styleSheet', style1)
        state2.assignProperty(self, 'styleSheet', style2)

        state1.addTransition(state1.propertiesAssigned, state2)
        state2.addTransition(state2.propertiesAssigned, state1)

        self.machine = QStateMachine()
        self.machine.addDefaultAnimation(animation)
        self.machine.addState(state1)
        self.machine.addState(state2)
        self.machine.setInitialState(state1)
        self.machine.start()
Пример #15
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.setAttribute(Qt.WA_QuitOnClose)
        self.setAttribute(Qt.WA_DeleteOnClose)

        # create instance variables
        self._ui = uic.loadUi('mainwindow.ui', self)

        # create models
        self.measureModels = {
            1: MeasureModel(self),
            2: MeasureModel(self),
        }
        self._instrumentManager = InstrumentManager(self, self.measureModels)

        self.machine = QStateMachine()
        self.stateInitial = QState()
        self.stateReadyToCheck = QState()
        self.stateReadyToMeasure = QState()
        self.stateAfterMeasure = QState()

        self.initDialog()
Пример #16
0
    def __init__(self, blaster, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.offState = QState()
        self.revState = QState()
        self.onState = QState()

        for s in [self.offState, self.revState, self.onState]:
            self.addState(s)
        self.setInitialState(self.offState)

        self.offState.entered.connect(lambda: blaster.triggerStateChange(3))
        self.offState.exited.connect(lambda: blaster.triggerStateChange(0))
        self.onState.entered.connect(lambda: blaster.triggerStateChange(1))
        self.onState.exited.connect(lambda: blaster.triggerStateChange(2))

        self.spinUp = QSignalTransition(self.touched)
        self.spinUp.setTargetState(self.revState)
        self.spinDown = QSignalTransition(self.letGo)
        self.spinDown.setTargetState(self.offState)
        self.revState.addTransition(self.pressed, self.onState)
        self.onState.addTransition(self.released, self.revState)

        self.start()
Пример #17
0
    def __init__(self, lcd, targetVal, serial=None, template=None):
        super().__init__()

        self.defaultState = DisplayState(lcd, Color.BLACK, 0.0)
        self.upState = DisplayState(lcd, Color.GREEN)
        self.downState = DisplayState(lcd, Color.RED)
        self.waitState = QState()

        self.setTimer = QTimer()
        self.setTimer.setInterval(DELAY_BEFORE_SET)
        self.setTimer.setSingleShot(True)
        self.waitState.entered.connect(self.setTimer.start)
        self.waitState.exited.connect(self.setTimer.stop)

        for s in [
                self.defaultState, self.upState, self.downState, self.waitState
        ]:
            self.addState(s)
            s.addTransition(self.raiseTarget, self.upState)
            s.addTransition(self.lowerTarget, self.downState)
        for s in [self.upState, self.downState]:
            s.addTransition(s.done, self.waitState)
        self.waitState.addTransition(self.setTimer.timeout, self.defaultState)

        self.setInitialState(self.defaultState)

        self.target = float(targetVal)

        if serial is not None:
            #self.serial = serial
            self.template = template

            serial.newDataAvailable.connect(self.defaultState.updateDisplay)

            self.waitState.exited.connect(self.sendTarget)
            self.sendToSerial.connect(serial.broadcast)

            self.requestTimer = QTimer()
            self.requestTimer.setInterval(REFRESH_PERIOD)
            self.requestTimer.timeout.connect(self.sendRequest)
            self.defaultState.entered.connect(self.requestTimer.start)
            self.defaultState.exited.connect(self.requestTimer.stop)

        self.start()
Пример #18
0
    tiledButton = Button(QPixmap(':/images/tile.png'), buttonParent)
    centeredButton = Button(QPixmap(':/images/centered.png'), buttonParent)

    ellipseButton.setPos(-100, -100)
    figure8Button.setPos(100, -100)
    randomButton.setPos(0, 0)
    tiledButton.setPos(-100, 100)
    centeredButton.setPos(100, 100)

    scene.addItem(buttonParent)
    buttonParent.setScale(0.75)
    buttonParent.setPos(200, 200)
    buttonParent.setZValue(65)

    # States.
    rootState = QState()
    ellipseState = QState(rootState)
    figure8State = QState(rootState)
    randomState = QState(rootState)
    tiledState = QState(rootState)
    centeredState = QState(rootState)

    # Values.
    for i, item in enumerate(items):
        # Ellipse.
        ellipseState.assignProperty(
            item, 'pos',
            QPointF(
                math.cos((i / 63.0) * 6.28) * 250,
                math.sin((i / 63.0) * 6.28) * 250))
Пример #19
0
    def gen_iv_ctrl(self):

        # Sweep control layout
        self.iv_ctrl = QWidget()
        self.iv_ctrl_layout = QVBoxLayout()

        # Sweep measurement Button. This will be a state machine which
        # alternates between 'measure' and 'abort' states
        self.iv_meas_state = QStateMachine()
        self.iv_meas_button = QPushButton()
        self.iv_meas_button.setStyleSheet(
            "background-color: #dddddd; border-style: solid; border-width: 1px; border-color: #aaaaaa; padding: 7px;"
        )

        # Create measurement states
        self.iv_meas_run = QState()
        self.iv_meas_stop = QState()

        # Assign state properties and transitions
        self.iv_meas_run.assignProperty(self.iv_meas_button, 'text',
                                        'Abort Sweep')
        self.iv_meas_run.addTransition(self.iv_meas_button.clicked,
                                       self.iv_meas_stop)
        self.iv_meas_run.entered.connect(self.exec_iv_run)

        self.iv_meas_stop.assignProperty(self.iv_meas_button, 'text',
                                         'Measure Sweep')
        self.iv_meas_stop.addTransition(self.iv_meas_button.clicked,
                                        self.iv_meas_run)
        self.iv_meas_stop.entered.connect(self.exec_iv_stop)

        # Add states, set initial state, and state machine
        self.iv_meas_state.addState(self.iv_meas_run)
        self.iv_meas_state.addState(self.iv_meas_stop)
        self.iv_meas_state.setInitialState(self.iv_meas_stop)
        self.iv_meas_state.start()

        # Sweep start
        self.iv_start_config = {
            "unit": "V",
            "min": "m",
            "max": "",
            "label": "Sweep Start (V)",
            "limit": 2.0,
            "signed": True,
            "default": [-0.5, ""]
        }
        self.iv_start = QVisaUnitSelector.QVisaUnitSelector(
            self.iv_start_config)

        # Sweep stop
        self.iv_stop_config = {
            "unit": "V",
            "min": "m",
            "max": "",
            "label": "Sweep Stop (V)",
            "limit": 2.0,
            "signed": True,
            "default": [0.5, ""]
        }
        self.iv_stop = QVisaUnitSelector.QVisaUnitSelector(self.iv_stop_config)

        # Compliance Spinbox
        self.iv_cmpl_config = {
            "unit": "A",
            "min": "u",
            "max": "",
            "label": "Compliance (A)",
            "limit": 1.0,
            "signed": False,
            "default": [100, "m"]
        }
        self.iv_cmpl = QVisaUnitSelector.QVisaUnitSelector(self.iv_cmpl_config)

        # Compliance
        self.iv_npts_config = {
            "unit": "__INT__",
            "label": "Number of Points",
            "limit": 256.0,
            "signed": False,
            "default": [51.0]
        }
        self.iv_npts = QVisaUnitSelector.QVisaUnitSelector(self.iv_npts_config)

        # Add sweep widgets to layout
        self.iv_ctrl_layout.addWidget(self.iv_meas_button)
        self.iv_ctrl_layout.addWidget(self.iv_start)
        self.iv_ctrl_layout.addWidget(self.iv_stop)
        self.iv_ctrl_layout.addWidget(self.iv_cmpl)
        self.iv_ctrl_layout.addWidget(self.iv_npts)
        self.iv_ctrl_layout.setContentsMargins(0, 0, 0, 0)

        # Set widget layout
        self.iv_ctrl.setLayout(self.iv_ctrl_layout)
Пример #20
0
def createStates(objects, selectedRect, parent):
    for obj in objects:
        state = QState(parent)
        state.assignProperty(obj, 'geometry', selectedRect)
        parent.addTransition(obj.clicked, state)
Пример #21
0
    scene.setBackgroundBrush(Qt.white)
    scene.addItem(p1)
    scene.addItem(p2)
    scene.addItem(p3)
    scene.addItem(p4)

    window = QGraphicsView(scene)
    window.setFrameStyle(0)
    window.setAlignment(Qt.AlignLeft | Qt.AlignTop)
    window.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
    window.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

    machine = QStateMachine()
    machine.setGlobalRestorePolicy(QStateMachine.RestoreProperties)

    group = QState(machine)
    selectedRect = QRect(86, 86, 128, 128)

    idleState = QState(group)
    group.setInitialState(idleState)

    objects = [p1, p2, p3, p4]
    createStates(objects, selectedRect, group)
    createAnimations(objects, machine)

    machine.setInitialState(group)
    machine.start()

    window.resize(300, 300)
    window.show()
Пример #22
0
    def gen_mpp_ctrl(self):

        #################################
        # mpp tracking controls
        #
        self.mpp_ctrl = QWidget()
        self.mpp_ctrl_layout = QVBoxLayout()

        # Create QStateMachine for output state
        self.mpp_state = QStateMachine()
        self.mpp_meas_button = QPushButton()
        self.mpp_meas_button.setStyleSheet(
            "background-color: #dddddd; border-style: solid; border-width: 1px; border-color: #aaaaaa; padding: 7px;"
        )

        # Create output states
        self.mpp_meas_off = QState()
        self.mpp_meas_on = QState()

        # Attach states to output button and define state transitions
        self.mpp_meas_off.assignProperty(self.mpp_meas_button, 'text',
                                         'MPP Monitor Off')
        self.mpp_meas_off.addTransition(self.mpp_meas_button.clicked,
                                        self.mpp_meas_on)
        self.mpp_meas_off.entered.connect(self.exec_mpp_stop)

        self.mpp_meas_on.assignProperty(self.mpp_meas_button, 'text',
                                        'MPP Monitor On')
        self.mpp_meas_on.addTransition(self.mpp_meas_button.clicked,
                                       self.mpp_meas_off)
        self.mpp_meas_on.entered.connect(self.exec_mpp_run)

        # Add states, set initial state, and start machine
        self.mpp_state.addState(self.mpp_meas_off)
        self.mpp_state.addState(self.mpp_meas_on)
        self.mpp_state.setInitialState(self.mpp_meas_off)
        self.mpp_state.start()

        # Tracking mode initialization
        # Note this example of passing arguments to a callback
        self.mpp_bias_config = {
            "unit": "V",
            "min": "m",
            "max": "",
            "label": "MPP Initialization (V)",
            "limit": 2.0,
            "signed": True,
            "default": [0.30, ""]
        }
        self.mpp_bias = QVisaUnitSelector.QVisaUnitSelector(
            self.mpp_bias_config)
        self.mpp_bias.unit_value.valueChanged.connect(
            lambda arg=self.mpp_bias.value(): self.update_bias(arg))

        # Compliance Spinbox
        self.mpp_cmpl_config = {
            "unit": "A",
            "min": "u",
            "max": "",
            "label": "Compliance (A)",
            "limit": 1.0,
            "signed": False,
            "default": [100, "m"]
        }
        self.mpp_cmpl = QVisaUnitSelector.QVisaUnitSelector(
            self.mpp_cmpl_config)

        # Tracking mode convergence
        self.mpp_ampl_config = {
            "unit": "V",
            "min": "u",
            "max": "m",
            "label": "Sense amplitude (mV)",
            "limit": 100,
            "signed": False,
            "default": [20.0, "m"]
        }
        self.mpp_ampl = QVisaUnitSelector.QVisaUnitSelector(
            self.mpp_ampl_config)

        # Delay
        self.mpp_gain_config = {
            "unit": "__DOUBLE__",
            "label": html.unescape("Proportional Gain (‰)"),
            "limit": 1000,
            "signed": False,
            "default": [30.0]
        }
        self.mpp_gain = QVisaUnitSelector.QVisaUnitSelector(
            self.mpp_gain_config)

        # Delay
        self.mpp_delay_config = {
            "unit": "__DOUBLE__",
            "label": "Measurement Interval (s)",
            "limit": 60.0,
            "signed": False,
            "default": [0.1]
        }
        self.mpp_delay = QVisaUnitSelector.QVisaUnitSelector(
            self.mpp_delay_config)

        # Add mpp widgets to layout
        self.mpp_ctrl_layout.addWidget(self.mpp_meas_button)
        self.mpp_ctrl_layout.addWidget(self.mpp_bias)
        self.mpp_ctrl_layout.addWidget(self.mpp_cmpl)
        self.mpp_ctrl_layout.addWidget(self.mpp_ampl)
        self.mpp_ctrl_layout.addWidget(self.mpp_gain)
        self.mpp_ctrl_layout.addWidget(self.mpp_delay)
        self.mpp_ctrl_layout.setContentsMargins(0, 0, 0, 0)

        # Set widget layout
        self.mpp_ctrl.setLayout(self.mpp_ctrl_layout)
Пример #23
0
if __name__ == "__main__":
    app = QApplication(sys.argv)

    tcs = mashina.TCSMashina()
    TCSstate = tcs_statemashina.statemashina.TCSStateMashina(
        tcs, configPath, 1000)
    startingpoint = tcs_statemashina.other.StartingPoint()
    TCSstate.addState(startingpoint)

    neutral = tcs_statemashina.neutral.Neutral()
    TCSstate.addState(neutral)

    startingpoint.addTransition(tcs.ready, neutral)

    charging = QState(QState.ParallelStates)
    TCSstate.addState(charging)

    neutral.addTransition(tcs.charge, charging)

    charging_ad = tcs_statemashina.charging.ad.Main(charging)

    charging_ad_phase_1A = tcs_statemashina.charging.ad.Phase_1A(charging_ad)
    charging_ad.setInitialState(charging_ad_phase_1A)

    charging_ad_phase_1B = tcs_statemashina.charging.ad.Phase_1B(charging_ad)
    charging_ad_phase_1A.addTransition(tcs.stableADTemp, charging_ad_phase_1B)

    charging_ad_phase_2 = tcs_statemashina.charging.ad.Phase_2(charging_ad)
    charging_ad_phase_1B.addTransition(charging_ad_phase_1B.warmup,
                                       charging_ad_phase_2)
Пример #24
0
        scene.addItem(item.pixmap_item)
        item.pixmap_item.setPos(-70, 170)

    # Cards as buttons
    buttonParent = QGraphicsRectItem()
    moveButton = Button(QPixmap('sol-images/s4.png'), buttonParent)
    centeredButton = Button(QPixmap('sol-images/palm.png'), buttonParent)

    moveButton.setPos(74, 40)
    centeredButton.setPos(-186, -102)

    scene.addItem(buttonParent)
    buttonParent.setPos(-73, -40)  #positions groups of buttons
    buttonParent.setZValue(65)

    rootState = QState()
    moveState = QState(rootState)
    centeredState = QState(rootState)

    for i, item in enumerate(items):
        # move
        moveState.assignProperty(
            item, 'pos',
            QPointF(-500 + qrand() % 500,
                    -400 + qrand() % 500))  #how big the effects are
        # centered
        centeredState.assignProperty(item, 'pos', QPointF())

    # interface
    view = View(scene)
    view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate)
Пример #25
0
    def set_states(self):
        """ Create state machine states """

        self.rootState = QState()
        # Initial setup states
        self.languageState = QState(self.rootState)
        self.loadState = QState(self.rootState)
        self.instructState = QState(self.rootState)
        self.nameState = QState(self.rootState)
        self.setplayersState = QState(self.rootState)
        self.tileState = QState(self.rootState)
        self.checkState = QState(self.rootState)
        self.setupState = QState(self.rootState)
        # Wait state between turns
        self.startState = QState(self.rootState)
        # Playing states
        self.playState = QState(self.rootState)
        self.blankState = QState(self.rootState)
        self.acceptState = QState(self.rootState)
        self.passState = QState(self.rootState)
        self.challengeState = QState(self.rootState)
        self.exchangeState = QState(self.rootState)
        self.endState = QState(self.rootState)
        # End state
        self.quitState = QFinalState()
Пример #26
0
    def __init__(self, size, parent=None):
        super(PadNavigator, self).__init__(parent)

        self.form = Ui_Form()

        splash = SplashItem()
        splash.setZValue(1)

        pad = FlippablePad(size)
        flipRotation = QGraphicsRotation(pad)
        xRotation = QGraphicsRotation(pad)
        yRotation = QGraphicsRotation(pad)
        flipRotation.setAxis(Qt.YAxis)
        xRotation.setAxis(Qt.YAxis)
        yRotation.setAxis(Qt.XAxis)
        pad.setTransformations([flipRotation, xRotation, yRotation])

        backItem = QGraphicsProxyWidget(pad)
        widget = QWidget()
        self.form.setupUi(widget)
        self.form.hostName.setFocus()
        backItem.setWidget(widget)
        backItem.setVisible(False)
        backItem.setFocus()
        backItem.setCacheMode(QGraphicsItem.ItemCoordinateCache)
        r = backItem.rect()
        backItem.setTransform(QTransform().rotate(180, Qt.YAxis).translate(
            -r.width() / 2, -r.height() / 2))

        selectionItem = RoundRectItem(QRectF(-60, -60, 120, 120),
                                      QColor(Qt.gray), pad)
        selectionItem.setZValue(0.5)

        smoothSplashMove = QPropertyAnimation(splash)
        smoothSplashOpacity = QPropertyAnimation(splash)
        smoothSplashMove.setEasingCurve(QEasingCurve.InQuad)
        smoothSplashMove.setDuration(250)
        smoothSplashOpacity.setDuration(250)

        smoothXSelection = QPropertyAnimation(selectionItem)
        smoothYSelection = QPropertyAnimation(selectionItem)
        smoothXRotation = QPropertyAnimation(xRotation)
        smoothYRotation = QPropertyAnimation(yRotation)
        smoothXSelection.setDuration(125)
        smoothYSelection.setDuration(125)
        smoothXRotation.setDuration(125)
        smoothYRotation.setDuration(125)
        smoothXSelection.setEasingCurve(QEasingCurve.InOutQuad)
        smoothYSelection.setEasingCurve(QEasingCurve.InOutQuad)
        smoothXRotation.setEasingCurve(QEasingCurve.InOutQuad)
        smoothYRotation.setEasingCurve(QEasingCurve.InOutQuad)

        smoothFlipRotation = QPropertyAnimation(flipRotation)
        smoothFlipScale = QPropertyAnimation(pad)
        smoothFlipXRotation = QPropertyAnimation(xRotation)
        smoothFlipYRotation = QPropertyAnimation(yRotation)
        flipAnimation = QParallelAnimationGroup(self)
        smoothFlipScale.setDuration(500)
        smoothFlipRotation.setDuration(500)
        smoothFlipXRotation.setDuration(500)
        smoothFlipYRotation.setDuration(500)
        smoothFlipScale.setEasingCurve(QEasingCurve.InOutQuad)
        smoothFlipRotation.setEasingCurve(QEasingCurve.InOutQuad)
        smoothFlipXRotation.setEasingCurve(QEasingCurve.InOutQuad)
        smoothFlipYRotation.setEasingCurve(QEasingCurve.InOutQuad)
        smoothFlipScale.setKeyValueAt(0, 1.0)
        smoothFlipScale.setKeyValueAt(0.5, 0.7)
        smoothFlipScale.setKeyValueAt(1, 1.0)
        flipAnimation.addAnimation(smoothFlipRotation)
        flipAnimation.addAnimation(smoothFlipScale)
        flipAnimation.addAnimation(smoothFlipXRotation)
        flipAnimation.addAnimation(smoothFlipYRotation)

        setVariablesSequence = QSequentialAnimationGroup()
        setFillAnimation = QPropertyAnimation(pad)
        setBackItemVisibleAnimation = QPropertyAnimation(backItem)
        setSelectionItemVisibleAnimation = QPropertyAnimation(selectionItem)
        setFillAnimation.setDuration(0)
        setBackItemVisibleAnimation.setDuration(0)
        setSelectionItemVisibleAnimation.setDuration(0)
        setVariablesSequence.addPause(250)
        setVariablesSequence.addAnimation(setBackItemVisibleAnimation)
        setVariablesSequence.addAnimation(setSelectionItemVisibleAnimation)
        setVariablesSequence.addAnimation(setFillAnimation)
        flipAnimation.addAnimation(setVariablesSequence)

        stateMachine = QStateMachine(self)
        splashState = QState(stateMachine)
        frontState = QState(stateMachine)
        historyState = QHistoryState(frontState)
        backState = QState(stateMachine)

        frontState.assignProperty(pad, "fill", False)
        frontState.assignProperty(splash, "opacity", 0.0)
        frontState.assignProperty(backItem, "visible", False)
        frontState.assignProperty(flipRotation, "angle", 0.0)
        frontState.assignProperty(selectionItem, "visible", True)

        backState.assignProperty(pad, "fill", True)
        backState.assignProperty(backItem, "visible", True)
        backState.assignProperty(xRotation, "angle", 0.0)
        backState.assignProperty(yRotation, "angle", 0.0)
        backState.assignProperty(flipRotation, "angle", 180.0)
        backState.assignProperty(selectionItem, "visible", False)

        stateMachine.addDefaultAnimation(smoothXRotation)
        stateMachine.addDefaultAnimation(smoothYRotation)
        stateMachine.addDefaultAnimation(smoothXSelection)
        stateMachine.addDefaultAnimation(smoothYSelection)
        stateMachine.setInitialState(splashState)

        anyKeyTransition = QEventTransition(self, QEvent.KeyPress, splashState)
        anyKeyTransition.setTargetState(frontState)
        anyKeyTransition.addAnimation(smoothSplashMove)
        anyKeyTransition.addAnimation(smoothSplashOpacity)

        enterTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                              Qt.Key_Enter, backState)
        returnTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                               Qt.Key_Return, backState)
        backEnterTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                                  Qt.Key_Enter, frontState)
        backReturnTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                                   Qt.Key_Return, frontState)
        enterTransition.setTargetState(historyState)
        returnTransition.setTargetState(historyState)
        backEnterTransition.setTargetState(backState)
        backReturnTransition.setTargetState(backState)
        enterTransition.addAnimation(flipAnimation)
        returnTransition.addAnimation(flipAnimation)
        backEnterTransition.addAnimation(flipAnimation)
        backReturnTransition.addAnimation(flipAnimation)

        columns = size.width()
        rows = size.height()
        stateGrid = []
        for y in range(rows):
            stateGrid.append([QState(frontState) for _ in range(columns)])

        frontState.setInitialState(stateGrid[0][0])
        selectionItem.setPos(pad.iconAt(0, 0).pos())

        for y in range(rows):
            for x in range(columns):
                state = stateGrid[y][x]

                rightTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                                      Qt.Key_Right, state)
                leftTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                                     Qt.Key_Left, state)
                downTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                                     Qt.Key_Down, state)
                upTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                                   Qt.Key_Up, state)

                rightTransition.setTargetState(stateGrid[y][(x + 1) % columns])
                leftTransition.setTargetState(
                    stateGrid[y][((x - 1) + columns) % columns])
                downTransition.setTargetState(stateGrid[(y + 1) % rows][x])
                upTransition.setTargetState(stateGrid[((y - 1) + rows) %
                                                      rows][x])

                icon = pad.iconAt(x, y)
                state.assignProperty(xRotation, "angle", -icon.x() / 6.0)
                state.assignProperty(yRotation, "angle", icon.y() / 6.0)
                state.assignProperty(selectionItem, "x", icon.x())
                state.assignProperty(selectionItem, "y", icon.y())
                frontState.assignProperty(icon, "visible", True)
                backState.assignProperty(icon, "visible", False)

                setIconVisibleAnimation = QPropertyAnimation(icon)
                setIconVisibleAnimation.setDuration(0)
                setVariablesSequence.addAnimation(setIconVisibleAnimation)

        scene = QGraphicsScene(self)
        scene.setBackgroundBrush(
            QBrush(QPixmap(":/images/blue_angle_swirl.jpg")))
        scene.setItemIndexMethod(QGraphicsScene.NoIndex)
        scene.addItem(pad)
        scene.setSceneRect(scene.itemsBoundingRect())
        self.setScene(scene)

        sbr = splash.boundingRect()
        splash.setPos(-sbr.width() / 2, scene.sceneRect().top() - 2)
        frontState.assignProperty(splash, "y", splash.y() - 100.0)
        scene.addItem(splash)

        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setMinimumSize(50, 50)
        self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)
        self.setCacheMode(QGraphicsView.CacheBackground)
        self.setRenderHints(QPainter.Antialiasing
                            | QPainter.SmoothPixmapTransform
                            | QPainter.TextAntialiasing)

        if QGLFormat.hasOpenGL():
            self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers)))

        stateMachine.start()
Пример #27
0
    def __init__(self, earth, desk_geo, screen_geo, *args, **kwargs):
        """
        Please see help(MainWindow) for more info.
        """
        super(MainWindow, self).__init__(*args, **kwargs)
        # Instantiate KeyboardCommands class
        self.commands = KeyboardCommands()
        # Will hold hand_recognition QtCapture class
        self.capture = None
        # Will hold camera object for OpenCV
        self.camera = None
        # Will hold thread for issuing GE commands
        self.command_thread = None
        # Make Qt gesture icon window frameless
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        # Get resolution, window size, and offsets for positioning
        self.google_earth = earth
        # Variables for popup windows
        self.popup_window = None
        self.popup_title = ""
        self.popup_text = ""
        # Available screen geometry
        self.desktop = desk_geo
        # Total screen geometry
        self.screen = screen_geo
        # Sets gesture icon window to be 1/4 of available screen space
        self.qt_window_height = int(self.desktop.height() * 1 / 4)
        # Set geometry of Qt gesture icon window
        self.setGeometry(
            QtWidgets.QStyle.alignedRect(
                QtCore.Qt.LeftToRight, QtCore.Qt.AlignCenter,
                QtCore.QSize(self.desktop.width(), self.qt_window_height),
                self.desktop))
        # Create layouts for organizing Qt gesture icon window
        self.layout = QVBoxLayout()
        self.layout1 = QHBoxLayout()
        self.layout2 = QHBoxLayout()
        self.layout3 = QHBoxLayout()
        # Dictionary to hold labels once they are created
        self.label_dict = dict()
        # Lists hold gesture icon file names and gesture icon titles
        self.image_list = [
            'images/index_up.png', 'images/v_sign.png',
            'images/thumb_left.png', 'images/thumb_right.png',
            'images/fist.png', 'images/five_wide.png', 'images/palm.png',
            'images/shaka.png'
        ]
        self.title_list = [
            'Move Up', 'Move Down', 'Move Left', 'Move Right', 'Zoom In',
            'Zoom Out', 'Tilt Up', 'Tilt Down'
        ]
        # Create and add 6 labels containing hand gesture image to layout2 and 6
        # labels with the gesture descriptions to layout1
        for num in range(0, 8):
            # Each label is created to hold gesture icon image
            self.label = QLabel(self)
            # Pixmap is created with the current gesture icon image
            self.pixmap = QPixmap(self.image_list[num])
            # Breakpoints to scale size of gesture icons for different resolutions
            if self.screen.width() >= 2560:
                self.pixmap = self.pixmap.scaledToWidth(225)
            elif self.screen.width() >= 1920:
                self.pixmap = self.pixmap.scaledToWidth(185)
            elif self.screen.width() > 1280 and self.screen.height() >= 1200:
                self.pixmap = self.pixmap.scaledToWidth(175)
            elif self.screen.width() > 800 and self.screen.height() >= 1024:
                self.pixmap = self.pixmap.scaledToWidth(125)
            elif self.screen.width() > 800:
                self.pixmap = self.pixmap.scaledToWidth(100)
            else:
                self.pixmap = self.pixmap.scaledToWidth(50)
            # Assigns gesture icon image to the current label
            self.label.setPixmap(self.pixmap)
            # Create gesture title label for the image
            self.label_title = QLabel(self.title_list[num])
            # Store current icon image label in dictionary
            self.label_dict[num] = self.label
            # Place current icon image label in layout
            self.layout2.addWidget(self.label_dict[num],
                                   alignment=QtCore.Qt.AlignCenter)
            # Place current icon image title label in layout
            self.layout1.addWidget(self.label_title,
                                   alignment=QtCore.Qt.AlignCenter)

        # Create state machine to reliably handle state changes during threading
        self.state_machine = QStateMachine()
        # Create button to handle state changes when pressed
        self.state_button = QPushButton(self)
        self.state_button.setStyleSheet("background-color: silver")
        # Connect button released signal to check_state slot
        self.state_button.released.connect(self.check_state)
        # Create on state for state machine
        self.on = QState()
        # Create off state for state machine
        self.off = QState()
        # Add transition for on state to off state when offSignal is emitted
        self.on.addTransition(self.offSignal, self.off)
        # Add transition for on state to on state when state_button clicked signal emitted
        self.on.addTransition(self.state_button.clicked, self.on)
        # Add transition for off state to on state when onSignal is emitted
        self.off.addTransition(self.onSignal, self.on)
        # Assign text property to state_button in on state
        self.on.assignProperty(self.state_button, "text",
                               "Start Gesture Navigation")
        # Assign text property to state_button in off state
        self.off.assignProperty(self.state_button, "text",
                                "Stop Gesture Navigation")
        # Add off state to state machine
        self.state_machine.addState(self.off)
        # Add on state to state machine
        self.state_machine.addState(self.on)
        # Set state machine initial state to on
        self.state_machine.setInitialState(self.on)
        # State state machine
        self.state_machine.start()
        # Create gesture tips button and connect it to start_gesture_tips slot
        self.tips_button = QPushButton("Gesture Navigation Tips")
        self.tips_button.setStyleSheet("background-color: silver")
        self.tips_button.pressed.connect(self.start_gesture_tips)
        # Create exit button and connect it to exit slot
        self.exit_button = QPushButton("Exit Program")
        self.exit_button.setStyleSheet("background-color: silver")
        self.exit_button.pressed.connect(self.exit)
        # Add tips, state, and exit button to layout 3
        self.layout3.addWidget(self.tips_button)
        self.layout3.addWidget(self.state_button)
        self.layout3.addWidget(self.exit_button)
        # Add layout 1, 2, and 3 to layout
        self.layout.addLayout(self.layout1)
        self.layout.addLayout(self.layout2)
        self.layout.addLayout(self.layout3)
        # Create widget to hold layout, add layout to widget
        self.widget = QWidget()
        self.widget.setLayout(self.layout)
        # Set widget with layouts as central widget
        self.setCentralWidget(self.widget)
Пример #28
0
    p5 = Pixmap(QPixmap(':/help-browser.png'))
    p6 = Pixmap(QPixmap(':/kchart.png'))

    scene = QGraphicsScene(0, 0, 400, 300)
    scene.setBackgroundBrush(scene.palette().window())
    scene.addItem(widget)
    scene.addItem(boxProxy)
    scene.addItem(p1)
    scene.addItem(p2)
    scene.addItem(p3)
    scene.addItem(p4)
    scene.addItem(p5)
    scene.addItem(p6)

    machine = QStateMachine()
    state1 = QState(machine)
    state2 = QState(machine)
    state3 = QState(machine)
    machine.setInitialState(state1)

    # State 1.
    state1.assignProperty(button, 'text', "Switch to state 2")
    state1.assignProperty(widget, 'geometry', QRectF(0, 0, 400, 150))
    state1.assignProperty(box, 'geometry', QRect(-200, 150, 200, 150))
    state1.assignProperty(p1, 'pos', QPointF(68, 185))
    state1.assignProperty(p2, 'pos', QPointF(168, 185))
    state1.assignProperty(p3, 'pos', QPointF(268, 185))
    state1.assignProperty(p4, 'pos', QPointF(68 - 150, 48 - 150))
    state1.assignProperty(p5, 'pos', QPointF(168, 48 - 150))
    state1.assignProperty(p6, 'pos', QPointF(268 + 150, 48 - 150))
    state1.assignProperty(p1, 'rotation', 0.0)
Пример #29
0
 def _make_save_state(self, form):
     s = QState()
     s.assignProperty(form.saveBtn, "enabled", True)
     return s
Пример #30
0
    scene = QGraphicsScene(0, 0, 300, 300)
    scene.setBackgroundBrush(Qt.black)
    scene.addItem(button1)
    scene.addItem(button2)
    scene.addItem(button3)
    scene.addItem(button4)

    window = QGraphicsView(scene)
    window.setFrameStyle(0)
    window.setAlignment(Qt.AlignLeft | Qt.AlignTop)
    window.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
    window.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

    machine = QStateMachine()

    group = QState()
    timer = QTimer()
    timer.setInterval(1250)
    timer.setSingleShot(True)
    group.entered.connect(timer.start)

    state1 = createGeometryState(button1, QRect(100, 0, 50, 50), button2,
                                 QRect(150, 0, 50, 50), button3,
                                 QRect(200, 0, 50, 50), button4,
                                 QRect(250, 0, 50, 50), group)

    state2 = createGeometryState(button1, QRect(250, 100, 50, 50), button2,
                                 QRect(250, 150, 50, 50), button3,
                                 QRect(250, 200, 50, 50), button4,
                                 QRect(250, 250, 50, 50), group)