Ejemplo n.º 1
0
    def createDisplay(self):
        self.displayLCD = QGroupBox("")
        layout = QHBoxLayout()

        paletteLosses = QPalette()
        paletteVictory = QPalette()

        paletteLosses.setColor(paletteLosses.WindowText, QColor(255, 000, 000))
        paletteVictory.setColor(paletteVictory.WindowText, QColor(000, 255, 000))

        self.lossesLcd = QLCDNumber(3)
        self.lossesLcd.setSegmentStyle(QLCDNumber.Filled)
        self.lossesLcd.setPalette(paletteLosses)

        self.victoryLcd = QLCDNumber(3)
        self.victoryLcd.setSegmentStyle(QLCDNumber.Filled)
        self.victoryLcd.setPalette(paletteVictory)

        self.lossesLcd.setMinimumHeight(100)
        self.victoryLcd.setMinimumHeight(100)

        self.lossesLcd.setMinimumWidth(150)
        self.victoryLcd.setMinimumWidth(150)

        layout.addWidget(self.victoryLcd)
        layout.addWidget(self.lossesLcd)

        self.displayLCD.setLayout(layout)
Ejemplo n.º 2
0
 def addNumbers(self):
     cavNum = QLCDNumber(2, self)
     self.cavSld.valueChanged.connect(cavNum.display)
     self.cavSld.setValue(99)
     cavNum.resize(60, 40)
     cavNum.move(150, 60)
     infNum = QLCDNumber(2, self)
     self.infSld.valueChanged.connect(infNum.display)
     self.infSld.setValue(99)
     infNum.resize(60, 40)
     infNum.move(0, 60)
Ejemplo n.º 3
0
    def initUI(self):
        #        self.setMinimumWidth(300)
        self.mainLayout = QHBoxLayout(self)
#         self.mainLayout.addStretch()
        self.scoreLCD = QLCDNumber(self)
        self.scoreLCD.setSegmentStyle(QLCDNumber.Flat)
        self.mainLayout.addWidget(self.scoreLCD)
        self.scoreLCD.setNumDigits(3)
        self.scoreLCD.setFixedSize(100, 60)
        self.scoreLCD.display(0)
        css = "QLCDNumber {{ color:rgb({},{},{});}}"
        self.scoreLCD.setStyleSheet(css.format(self.pcolour.red(),
                                               self.pcolour.green(),
                                               self.pcolour.blue()))

        self.nameLabel = QLabel(self)
        self.nameLabel.setText(self.player)
        sh = ("QLabel {{ font-size: 32px; font-weight: "
              "bold; color:rgb({},{},{});}}")
        self.nameLabel.setStyleSheet(sh.format(self.pcolour.red(),
                                               self.pcolour.green(),
                                               self.pcolour.blue()))
        self.mainLayout.addWidget(self.nameLabel)

        self.dealerPixmap = QtGui.QPixmap('icons/cards.png')
        self.nonDealerPixmap = QtGui.QPixmap()
        self.winnerPixmap = QtGui.QPixmap('icons/winner.png')

        self.iconlabel = IconLabel(self)
        self.iconlabel.setFixedSize(50, 50)
        self.iconlabel.setScaledContents(True)
        self.mainLayout.insertWidget(0, self.iconlabel)
#         self.mainLayout.addStretch()
        self.unsetDealer()
Ejemplo n.º 4
0
    def __init__(self, cue, **kwargs):
        super().__init__(**kwargs)
        self.cue = None

        self._selected = False
        self._accurate_timing = False
        self._show_dbmeter = False
        self._countdown_mode = True

        self._dbmeter_element = None
        self._fade_element = None

        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setLayout(QGridLayout())

        self.layout().setContentsMargins(0, 0, 0, 0)
        self.layout().setSpacing(2)
        self.layout().setColumnStretch(0, 6)
        self.layout().setRowStretch(0, 4)

        self.nameButton = QClickLabel(self)
        self.nameButton.setObjectName('ButtonCueWidget')
        self.nameButton.setWordWrap(True)
        self.nameButton.setAlignment(Qt.AlignCenter)
        self.nameButton.setFocusPolicy(Qt.NoFocus)
        self.nameButton.clicked.connect(self._clicked)
        self.nameButton.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.layout().addWidget(self.nameButton, 0, 0)

        self.statusIcon = QLabel(self.nameButton)
        self.statusIcon.setStyleSheet('background-color: transparent')
        self.statusIcon.setPixmap(CueWidget.STOP.pixmap(CueWidget.ICON_SIZE,
                                                        CueWidget.ICON_SIZE))

        self.seekSlider = QClickSlider(self.nameButton)
        self.seekSlider.setOrientation(Qt.Horizontal)
        self.seekSlider.setFocusPolicy(Qt.NoFocus)
        self.seekSlider.setVisible(False)

        self.dbMeter = QDbMeter(self)
        self.dbMeter.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.dbMeter.setVisible(False)

        self.timeBar = QProgressBar(self)
        self.timeBar.setTextVisible(False)
        self.timeBar.setLayout(QHBoxLayout())
        self.timeBar.layout().setContentsMargins(0, 0, 0, 0)
        self.timeDisplay = QLCDNumber(self.timeBar)
        self.timeDisplay.setStyleSheet('background-color: transparent')
        self.timeDisplay.setSegmentStyle(QLCDNumber.Flat)
        self.timeDisplay.setDigitCount(8)
        self.timeDisplay.display('00:00:00')
        self.timeBar.layout().addWidget(self.timeDisplay)
        self.timeBar.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.timeBar.setVisible(False)

        self._set_cue(cue)
Ejemplo n.º 5
0
 def initUI(self):
     self.lcd = QLCDNumber(self)
     vbox = QVBoxLayout()
     vbox.addWidget(self.lcd)
     self.setLayout(vbox)
     self.setGeometry(300, 300, 250, 150)
     self.setWindowTitle('WordspPerMinute')
     self.value = 0
     self.show()
 def createScoreLayout(self):
     self.playerScoreLcd = QLCDNumber(2)
     self.playerScoreLcd.setSegmentStyle(QLCDNumber.Filled)
     self.playerScoreLcd.setMinimumSize(75, 50)
     self.playerScoreLcd.display(0)
     self.opponentScoreLcd = QLCDNumber(2)
     self.opponentScoreLcd.setSegmentStyle(QLCDNumber.Filled)
     self.opponentScoreLcd.setMinimumSize(75, 50)
     self.opponentScoreLcd.display(0)
     layout = QHBoxLayout()
     layout.addStretch(1)
     layout.addWidget(self.createLabel('You: '))
     layout.addWidget(self.playerScoreLcd)
     layout.addStretch(1)
     layout.addWidget(self.createLabel('Opponent: '))
     layout.addWidget(self.opponentScoreLcd)
     layout.addStretch(1)
     return layout
Ejemplo n.º 7
0
    def _widgets(self):

        self.shiverTimer = QTime(0, 0, 0)
        self.timer = QTimer()
        self.timerLCDNumber = QLCDNumber()
        self.timerLCDNumber.setDigitCount(12)
        self.timerLCDNumber.display("00:00:00.000")
        self.stortPushButton = QPushButton(self._START)
        self.resetPushButton = QPushButton(self._RESET)
Ejemplo n.º 8
0
class SpeedWidget(QtWidgets.QWidget):
    def __init__(self):
        super(SpeedWidget, self).__init__()
        self.initUI()

    def initUI(self):
        self.lcd = QLCDNumber(self)
        vbox = QVBoxLayout()
        vbox.addWidget(self.lcd)
        self.setLayout(vbox)
        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle('WordspPerMinute')
        self.value = 0
        self.show()

    # set lcd display value
    def setValues(self, wpm):
        complete = int(wpm)
        self.lcd.display(complete)
Ejemplo n.º 9
0
    def __init__(self):
        super(TetrixWindow, self).__init__()

        self.board = TetrixBoard()

        nextPieceLabel = QLabel()
        nextPieceLabel.setFrameStyle(QFrame.Box | QFrame.Raised)
        nextPieceLabel.setAlignment(Qt.AlignCenter)
        self.board.setNextPieceLabel(nextPieceLabel)

        scoreLcd = QLCDNumber(5)
        scoreLcd.setSegmentStyle(QLCDNumber.Filled)
        levelLcd = QLCDNumber(2)
        levelLcd.setSegmentStyle(QLCDNumber.Filled)
        linesLcd = QLCDNumber(5)
        linesLcd.setSegmentStyle(QLCDNumber.Filled)

        startButton = QPushButton("&Start")
        startButton.setFocusPolicy(Qt.NoFocus)
        quitButton = QPushButton("&Quit")
        quitButton.setFocusPolicy(Qt.NoFocus)
        pauseButton = QPushButton("&Pause")
        pauseButton.setFocusPolicy(Qt.NoFocus)

        startButton.clicked.connect(self.board.start)
        pauseButton.clicked.connect(self.board.pause)
        quitButton.clicked.connect(QApplication.instance().quit)
        self.board.scoreChanged.connect(scoreLcd.display)
        self.board.levelChanged.connect(levelLcd.display)
        self.board.linesRemovedChanged.connect(linesLcd.display)

        layout = QGridLayout()
        layout.addWidget(self.createLabel("NEXT"), 0, 0)
        layout.addWidget(nextPieceLabel, 1, 0)
        layout.addWidget(self.createLabel("LEVEL"), 2, 0)
        layout.addWidget(levelLcd, 3, 0)
        layout.addWidget(startButton, 4, 0)
        layout.addWidget(self.board, 0, 1, 6, 1)
        layout.addWidget(self.createLabel("SCORE"), 0, 2)
        layout.addWidget(scoreLcd, 1, 2)
        layout.addWidget(self.createLabel("LINES REMOVED"), 2, 2)
        layout.addWidget(linesLcd, 3, 2)
        layout.addWidget(quitButton, 4, 2)
        layout.addWidget(pauseButton, 5, 2)
        self.setLayout(layout)

        self.setWindowTitle("Tetrix")
        self.resize(550, 370)
Ejemplo n.º 10
0
    def __init__(self):
        super(DedeNimeur, self).__init__()
        self.statusBar()

        self.size, self.height, self.width, self.mines = 30, 10, 10, 10
        self.lcd = QLCDNumber()
        self.lcd.setFixedSize(300, 60)
        self.board = Board(self.height, self.width, self.mines, self.size)
        self.timer = QBasicTimer()
        self.real_timer = QElapsedTimer()

        vbox = QVBoxLayout()
        vbox.addWidget(self.lcd)
        vbox.addWidget(self.board)

        central = QWidget()
        central.setLayout(vbox)
        self.setCentralWidget(central)

        start = QAction('Start', self)
        start.setStatusTip('Start')
        start.setShortcut('Ctrl+N')
        start.triggered.connect(self.init)

        exit = QAction('Exit', self)
        exit.setStatusTip('Exit')
        exit.setShortcut('Ctrl+Q')
        exit.triggered.connect(qApp.quit)

        height = QAction('Height', self)
        height.setStatusTip('Set board width')
        height.triggered.connect(self.set_height)
        width = QAction('Width', self)
        width.setStatusTip('Set board height')
        width.triggered.connect(self.set_width)
        mines = QAction('Mines', self)
        mines.setStatusTip('Set board mines')
        mines.triggered.connect(self.set_mines)
        size = QAction('Size', self)
        size.setStatusTip('Set button size')
        size.triggered.connect(self.set_size)

        toolbar = self.addToolBar('Toolbar')
        toolbar.addAction(start)
        toolbar.addAction(width)
        toolbar.addAction(height)
        toolbar.addAction(mines)
        toolbar.addAction(size)
        toolbar.addAction(exit)

        self.setWindowTitle(u'DédéNimeur')
        self.show()
Ejemplo n.º 11
0
    def __init__(self, time_allocation=15, parent=None):
        super(CountDownTimer, self).__init__(parent)
        self.time_allocation = time_allocation
        self.time_value = self.time_allocation

        # timer
        self.timer = QTimer(self)
        self.timer.timeout.connect(self.advance_time)

        # LCD time display
        self.lcd = QLCDNumber(self)
        self.lcd.setDigitCount(3)
        self.lcd.setSegmentStyle(QLCDNumber.Flat)
        self.lcd.display(self.time_value)
    def __init__(self, winParent):
        super(timeWidget, self).__init__()
        self.winParent = winParent
        self.seconds = 0

        hLayout = QHBoxLayout()

        timeLabel = QLabel("Time")
        self.lcd = QLCDNumber(self)
        self.lcd.setMaximumSize(100, 50)
        hLayout.addWidget(timeLabel, 0)
        hLayout.addWidget(self.lcd, 1)

        hSpacer = QSpacerItem(300, 30, QSizePolicy.Ignored,
                              QSizePolicy.Ignored)
        hLayout.addItem(hSpacer)

        self.setLayout(hLayout)

        timer = QTimer(self)
        timer.start(1000)
        timer.timeout.connect(self.printTime)

        # get the palette
        palette = self.lcd.palette()

        # foreground color
        palette.setColor(palette.WindowText, QColor(85, 85, 255))
        # background color
        palette.setColor(palette.Background, QColor(0, 170, 255))
        # "light" border
        palette.setColor(palette.Light, QColor(255, 0, 0))
        # "dark" border
        palette.setColor(palette.Dark, QColor(0, 255, 0))

        # set the palette
        self.lcd.setPalette(palette)
Ejemplo n.º 13
0
    def initUI(self):
        self.setGeometry(300, 300, 500, 300)
        self.setWindowTitle('Вычисление выражений')

        self.name_input = QLineEdit(self)
        self.name_input.move(15, 50)

        self.name1_input = QLineEdit(self)
        self.name1_input.move(15, 200)

        self.btn = QPushButton('->', self)
        self.btn.resize(100, 30)
        self.btn.move(150, 125)

        self.btn.clicked.connect(self.hello)

        self.label = QLabel(self)
        self.label.setText("Первое число(целое):")
        self.label.move(15, 15)

        self.label2 = QLabel(self)
        self.label2.setText("Второе число(целое):")
        self.label2.move(15, 165)

        self.label3 = QLabel(self)
        self.label3.setText("Сумма:")
        self.label3.move(300, 20)
        self.LCD_count1 = QLCDNumber(self)
        self.LCD_count1.move(351, 20)

        self.label4 = QLabel(self)
        self.label4.setText("Разность:")
        self.label4.move(290, 90)
        self.LCD_count2 = QLCDNumber(self)
        self.LCD_count2.move(351, 90)

        self.label5 = QLabel(self)
        self.label5.setText("Произведение:")
        self.label5.move(267, 160)
        self.LCD_count3 = QLCDNumber(self)
        self.LCD_count3.move(351, 160)

        self.label6 = QLabel(self)
        self.label6.setText("Частное:")
        self.label6.move(300, 210)
        self.LCD_count4 = QLCDNumber(self)
        self.LCD_count4.move(351, 210)
Ejemplo n.º 14
0
    def initUI(self):
        self.random_number()
        self.setGeometry(300, 300, 300, 300)
        self.setWindowTitle('Числовая игра')

        self.btn = QPushButton('Увеличить', self)
        self.btn.resize(self.btn.sizeHint())
        self.btn.move(50, 210)
        self.btn.clicked.connect(self.plus)

        self.btn = QPushButton('Уменьшить', self)
        self.btn.resize(self.btn.sizeHint())
        self.btn.move(150, 210)
        self.btn.clicked.connect(self.minus)

        self.label = QLabel(self)
        self.label.setText("Осталось ходов")
        self.label.move(20, 20)

        self.LCD_step = QLCDNumber(self)
        self.LCD_step.move(140, 10)
        self.LCD_step.resize(80, 40)
        self.LCD_step.display(self.step)

        self.LCD_x = QLCDNumber(self)
        self.LCD_x.move(60, 100)
        self.LCD_x.resize(160, 100)
        self.LCD_x.display(self.x)

        self.label_er = QLabel(self)
        self.label_er.setText(f'                                                                 '
                              f'                                          ')
        self.label_er.move(5, 60)

        self.label_er1 = QLabel(self)
        self.label_er1.setText(f'                                                                 ')
        self.label_er1.move(5, 70)
Ejemplo n.º 15
0
    def initUI(self):

        self.statusBar()

        btn1 = QPushButton('кнопка1', self)
        btn1.clicked.connect(self.buttonClicked)
        btn1.move(50, 10)

        btn2 = QPushButton('кнопка2', self)
        btn2.clicked.connect(self.showDialog1)
        btn2.move(200, 10)

        btn3 = QPushButton('кннопка3', self)
        btn3.clicked.connect(self.showDialog)
        btn3.move(350, 10)

        lbl1 = QLabel('label1', self)
        lbl1.move(50, 50)
        self.le = QLineEdit(self)
        self.le.move(100, 50)

        lcd = QLCDNumber(self)
        lcd.move(50, 100)
        sld = QSlider(Qt.Horizontal, self)
        sld.move(50, 150)

        cb = QCheckBox('Сменить статус', self)
        cb.move(50, 200)
        cb.toggle()
        cb.stateChanged.connect(self.check)

        sld.valueChanged.connect(lcd.display)

        self.setGeometry(0, 0, 500, 300)
        self.setWindowTitle('test7')
        self.setWindowIcon(QIcon('bit.png'))
        self.show()
Ejemplo n.º 16
0
    def __init__(self, parent):

        super().__init__(parent)

        self.btns = ['STOP', 'ROTATEL', 'RESTART', 'LEFT', 'ROTATER', 'RIGHT']
        pos = [(i + 1, j + 1) for i in range(2) for j in range(3)]

        self.lcd = QLCDNumber(Qt.Horizontal, self)
        self.btn = QPushButton('START', self)
        self.btn.clicked.connect(self.dealbtn)
        self.btn.setFocusPolicy(Qt.NoFocus)

        self.grid = QGridLayout()
        self.grid.setSpacing(10)

        self.tTritrisBoard = TritrisBoard(self)
        self.nextBoard = NextShapeBoard(self)
        #create buttons above the lcd
        self.grid.addWidget(self.tTritrisBoard, 1, 1, 5, 4)
        for pos, name in zip(pos, self.btns):
            button = QPushButton(name)
            button.setFocusPolicy(Qt.NoFocus)
            if name == 'STOP':
                button.clicked.connect(self.stop)
            elif name == 'ROTATEL':
                button.clicked.connect(self.tTritrisBoard.up)
            elif name == 'RESTART':
                button.clicked.connect(self.restart)
            elif name == 'LEFT':
                button.clicked.connect(self.tTritrisBoard.left)
            elif name == 'ROTATER':
                button.clicked.connect(self.tTritrisBoard.down)
            elif name == 'RIGHT':
                button.clicked.connect(self.tTritrisBoard.right)
            else:
                return
            self.grid.addWidget(button, pos[0], pos[1] + 4)
        self.grid.addWidget(self.nextBoard, 3, 5, 1, 3)
        self.grid.addWidget(self.lcd, 4, 5, 1, 3)
        self.grid.addWidget(self.btn, 5, 5, 1, 3)
        #show the score in lcd
        self.tTritrisBoard.score[int].connect(self.lcd.display)
        #handle tetris_board's operating status
        self.tTritrisBoard.status[str].connect(self.handle_status)
        #handle next shape signal
        self.tTritrisBoard.next[int].connect(self.nextBoard.showNext)
        self.tTritrisBoard.status.emit('wait_start')

        self.setLayout(self.grid)
Ejemplo n.º 17
0
 def addGoldInfo(self, font):
     '''
     Adds gold LCDNumber and connects it with the correct signal.
     '''
     goldLbl = QLabel('Gold:', self)
     goldLbl.move(300, 10)
     goldLbl.setFont(font)
     goldLcd = QLCDNumber(4, self)
     goldLcd.move(360, 0)
     goldLcd.setFrameShape(QFrame.NoFrame)
     goldLcd.resize(65, 40)
     self.sig.goldChanged.connect(goldLcd.display)
     self.sig.goldChanged.emit(self.game.player.gold)
    def initUI(self):

        # Basic example of the signals and slots mechanism
        lcd = QLCDNumber(
            self)  # An LCDNumber is a "Liquid Crystal Display" number
        slider = QSlider(Qt.Horizontal, self)  # Creates a horizontal slider

        vBox = QVBoxLayout()
        vBox.addWidget(lcd)
        vBox.addWidget(slider)

        slider.valueChanged.connect(
            lcd.display)  # Displays the sliders value via the LCD number

        # Event source = slider; Event object = valueChanged (the slider's value), which emits a
        # signal ; Event target = lcd

        # A signal is emitted when a particular event occurs. A slot is any python callable and
        # is called when its connected signal is emitted

        text = "x: N/A, y: N/A"

        self.posLabel = QLabel(text, self)  # Creates a label
        vBox.addWidget(self.posLabel)

        self.setMouseTracking(
            True
        )  # Is normally disabled, your cursors position is then only tracked when a mouse button
        # has been clicked

        buttonOne = QPushButton("Button 1", self)
        buttonTwo = QPushButton("Button 2", self)

        buttonOne.clicked.connect(self.identifySender)
        buttonTwo.clicked.connect(self.identifySender)
        self.senderLabel = QLabel(self)
        vBox.addWidget(self.senderLabel)

        mainLayout = QGridLayout(self)

        mainLayout.addWidget(buttonOne, 0, 0)
        mainLayout.addWidget(buttonTwo, 0, 1)
        mainLayout.addLayout(vBox, 2, 0)

        self.setLayout(mainLayout)

        self.setGeometry(200, 150, 1100, 800)
        self.setWindowTitle("Signals and slots")
        self.show()
Ejemplo n.º 19
0
    def initUI(self):

        self.controlsGroup = QGroupBox("运行样本")
        self.lcdNumber = QLCDNumber(self)
        self.slider = QSlider(Qt.Horizontal, self)
        self.pBar = QProgressBar(self)
        vbox = QVBoxLayout()
        vbox.addWidget(self.pBar)
        vbox.addWidget(self.lcdNumber)
        vbox.addWidget(self.slider)
        self.controlsGroup.setLayout(vbox)

        controlsLayout = QGridLayout()
        self.label1 = QLabel("保存状态:")
        self.saveLabel = QLabel()
        self.label2 = QLabel("运行状态:")
        self.runLabel = QLabel()
        self.buttonSave = QPushButton("保存")
        self.buttonRun = QPushButton("运行")
        self.buttonStop = QPushButton("停止")
        self.buttonDisconnect = QPushButton("解除关联")
        self.buttonConnect = QPushButton("绑定关联")

        controlsLayout.addWidget(self.label1, 0, 0)
        controlsLayout.addWidget(self.saveLabel, 0, 1)
        controlsLayout.addWidget(self.label2, 1, 0)
        controlsLayout.addWidget(self.runLabel, 1, 1)
        controlsLayout.addWidget(self.buttonSave, 2, 0)
        controlsLayout.addWidget(self.buttonRun, 2, 1)
        controlsLayout.addWidget(self.buttonStop, 2, 2)
        controlsLayout.addWidget(self.buttonDisconnect, 3, 0)
        controlsLayout.addWidget(self.buttonConnect, 3, 1)

        layout = QHBoxLayout()
        layout.addWidget(self.controlsGroup)
        layout.addLayout(controlsLayout)
        self.setLayout(layout)

        self.buttonRun.clicked.connect(self.buttonSave.clicked)
        self.slider.valueChanged.connect(self.pBar.setValue)
        self.slider.valueChanged.connect(self.lcdNumber.display)
        self.buttonSave.clicked.connect(self.showMessage)
        self.buttonRun.clicked.connect(self.showMessage)
        self.buttonDisconnect.clicked.connect(self.unbindConnection)
        self.buttonConnect.clicked.connect(self.bindConnection)
        self.buttonStop.clicked.connect(self.stop)

        self.setGeometry(300, 500, 500, 180)
        self.setWindowTitle('信号和槽')
Ejemplo n.º 20
0
 def addIncomeInfo(self, font):
     '''
     Adds the income LCDNumber and connects it with the correct signals.
     '''
     incomeLbl = QLabel("Income:", self)
     incomeLbl.setFont(font)
     incomeLbl.move(460, 10)
     incomeLcd = QLCDNumber(3, self)
     incomeLcd.move(530, 0)
     incomeLcd.setFrameShape(QFrame.NoFrame)
     incomeLcd.resize(60, 40)
     self.sig.incomeChanged.connect(incomeLcd.display)
     self.sig.incomeChanged.emit(self.game.player.income())
Ejemplo n.º 21
0
    def initUI(self):
        lcd = QLCDNumber(self)
        sld = QSlider(Qt.Horizontal, self)

        vbox = QVBoxLayout()
        vbox.addWidget(lcd)
        vbox.addWidget(sld)

        self.setLayout(vbox)
        # 在这里我们将滚动条的valueChanged信号连接到lcd的display插槽
        sld.valueChanged.connect(lcd.display)
        # sender是发出信号的对象。receiver是接收信号的对象。slot(插槽)是对信号做出反应的方法
        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle('Signal & slot')
        self.show()
Ejemplo n.º 22
0
    def initUI(self):

        lcd = QLCDNumber(self)
        sld = QSlider(Qt.Vertical, self)

        vbox = QHBoxLayout()
        vbox.addWidget(lcd)
        vbox.addWidget(sld)

        self.setLayout(vbox)
        sld.valueChanged.connect(lcd.display)

        self.setGeometry(500, 500, 500, 250)
        self.setWindowTitle('Signal & slot')
        self.show()
Ejemplo n.º 23
0
    def initUI(self):
        lcd = QLCDNumber(self)
        sld = QSlider(Qt.Horizontal, self)

        vbox = QVBoxLayout()
        vbox.addWidget(lcd)
        vbox.addWidget(sld)

        self.setLayout(vbox)
        sld.valueChanged.connect(lcd.display)

        self.x, self.y, self.width, self.height = 400, 400, 400, 400
        self.setGeometry(self.x, self.y, self.width, self.height)
        self.setWindowTitle('PyQt5 GUI')
        self.show()
Ejemplo n.º 24
0
class Example(QWidget):
    
    def __init__(self):
        super().__init__()
        
        self.initUI()
                


    def initUI(self):
        self.lcd = QLCDNumber(self)#设置数字类
        self.lcd.setDigitCount(25)
        self.lcd.setMode(QLCDNumber.Dec)
        self.lcd.setSegmentStyle(QLCDNumber.Flat)
        self.lcd.setStyleSheet("border: 1px solid green; color: green; background: silver;")#设置显示的颜色样式
        vbox = QVBoxLayout()#设置布局
        vbox.addWidget(self.lcd)
        self.setLayout(vbox)
        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle('hello')
        dir_path = os.path.abspath(os.path.dirname(__file__))+'\image\\1.ico'
        self.setWindowIcon(QIcon(dir_path))
        self.show()
        self.timer = QTimer()
        self.timer.start(1)
        self.timer.timeout.connect(self.flush)#使用了计时器
        '''
        创建计时器->设置1ms刷新间隔->每次刷新执行flush函数
        '''
        
        
    def flush(self):
        #获取系统当前时间
        dateTime=QDateTime.currentDateTime()
        #显示的内容
        self.lcd.display(dateTime.toString("yyyy-MM-dd HH:mm:ss.zzz"))
Ejemplo n.º 25
0
    def initUI(self):
        lcd = QLCDNumber(self)  # LCD화면의 숫자 표현(위젯)
        sld = QSlider(Qt.Horizontal, self)  # 진행 슬라이더

        vbox = QVBoxLayout()
        vbox.addWidget(lcd)
        vbox.addWidget(sld)  # 개채 배치하기

        self.setLayout(vbox)
        sld.valueChanged.connect(
            lcd.display)  # QLCDNumber에 있는 display 함수와 sld 슬라이더를 연결시킴

        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle('signal and slot')
        self.show()
Ejemplo n.º 26
0
    def setUI(self):
        lcd = QLCDNumber(self)
        slider = QSlider(Qt.Horizontal, self)

        miseEnPage = QVBoxLayout()
        miseEnPage.addWidget(slider)
        miseEnPage.addWidget(lcd)
        self.setLayout(miseEnPage)

        slider.valueChanged.connect(lcd.display)

        self.setGeometry(300, 300, 200, 100)
        self.setWindowTitle('Fenêtre principale')

        self.show()
Ejemplo n.º 27
0
class Game(QMainWindow):
    def __init__(self):
        super().__init__()
        self.resize(400, 430)
        self.setWindowTitle('Tetris')
        self.scores = 0
        self.tetBoard = Board(self)
        self.lcd = QLCDNumber(self)
        self.tetBoard.resize(200, 415)
        self.layout = QHBoxLayout()
        self.layout.addWidget(self.tetBoard)
        self.layout.addWidget(self.lcd)
        self.lcd.move(250, 150)
        self.setLayout(self.layout)
        self.statusbar = self.statusBar()
        self.tetBoard.msg2statusbar[str].connect(self.statusbar.showMessage)
        self.tetBoard.closeMsg.connect(self.close)
        self.tetBoard.scoresMsg.connect(self.increase)
        self.tetBoard.start()
        self.show()

    def increase(self, score):
        self.scores += score
        self.lcd.display(self.scores)
Ejemplo n.º 28
0
class parameterWidget(QWidget):
    def __init__(self,minimum,maximum):
        super(parameterWidget,self).__init__()
        self.container = QVBoxLayout()
        self.container.addStretch(1)
        self.slider = QSlider(Qt.Horizontal, self)
        self.slider.setMinimum(minimum)
        self.slider.setMaximum(maximum)
        self.slider.setTickInterval(1)
        self.slider.setSingleStep(1)
        self.container.addWidget(self.slider)
        self.lcd = QLCDNumber()
        self.lcd.setFixedHeight(100)
        self.lcd.setFixedWidth(100)
        self.lcd.resize(50, 100)
        self.container.addWidget(self.lcd)
        self.lcd.setDigitCount(8)
        self.slider.valueChanged.connect(self.update_lcd)
        self.container.addStretch(1)
        self.setLayout(self.container)

    @pyqtSlot(int)
    def update_lcd(self,value):
        self.lcd.display(str(value))
Ejemplo n.º 29
0
    def __init__(self):
        super(Demo, self).__init__()
        self.resize(600, 600)

        #  实例化一个QLCDNumber控件,
        #  然后通过setDiditCount()方法来设置一共可以显示多少为数字;
        self.lcd_1 = QLCDNumber(self)
        self.lcd_1.setDigitCount(10)
        self.lcd_1.display(1234567890)

        # lcd_2显示浮点型数字
        self.lcd_2 = QLCDNumber(self)
        # 通过setSegmentStyle()可以设置显示屏数字样式
        """
        常量                  值           描述
        QLCDNumber.Outline  0           让内容浮显,其颜色显示屏背景颜色相同
        QLCDNumber.Filled   1           让内容浮显,颜色窗口标题相同
        QLCDNumber.Flat     2           让内容扁平化显示,颜色同窗口标题颜色相同
        """
        self.lcd_2.setSegmentStyle(QLCDNumber.Flat)

        # setSmallDecimalPoint(bool)方法可以设置小数点的显示方式:
        # 若为True,那么小数点就会在两个数字之间显示出来,而不会单独占一个位置。如果为False,那就会单独占位(默认为False)。
        # self.lcd_2.setSmallDecimalPoint(True)
        self.lcd_2.setDigitCount(10)
        self.lcd_2.display(0.123456789)

        # 3. lcd_3显示的为字符串,可以显示的字母种类有限:A, B, C, D, E, F, h, H, L,
        # o, P, r, u, U, Y, O/0, S/5, g/9;
        self.lcd_3 = QLCDNumber(self)  # 3
        self.lcd_3.setSegmentStyle(QLCDNumber.Filled)
        self.lcd_3.display('HELLO')

        self.lcd_4 = QLCDNumber(self)  # 4
        self.lcd_4.setSegmentStyle(QLCDNumber.Outline)
        self.lcd_4.setMode(QLCDNumber.Hex)
        self.lcd_4.setDigitCount(6)
        self.lcd_4.display(666)

        self.v_layout = QVBoxLayout()
        self.v_layout.addWidget(self.lcd_1)
        self.v_layout.addWidget(self.lcd_2)
        self.v_layout.addWidget(self.lcd_3)
        self.v_layout.addWidget(self.lcd_4)

        self.setLayout(self.v_layout)
Ejemplo n.º 30
0
class Temperature_Page(QWidget):
    def __init__(self):
        QWidget.__init__(self)

        self.NowTemperature = QLCDNumber(self)
        self.WantTemperature = QLCDNumber(self)
        self.SettingDial = QDial(self)
        self.lbNow = QLabel("현재 온도", self)
        self.lbWant = QLabel("희망 온도", self)
        self.NowFont = self.lbNow.font()
        self.NowFont.setPointSize(40)
        self.NowFont.setBold(True)

        self.lbNow.resize(300, 50)
        self.lbNow.move(50, 50)
        self.lbNow.setAlignment(Qt.AlignCenter)
        self.lbNow.setFont(self.NowFont)

        self.lbWant.resize(300, 50)
        self.lbWant.move(400, 50)
        self.lbWant.setAlignment(Qt.AlignCenter)
        self.lbWant.setFont(self.NowFont)

        self.NowTemperature.resize(300, 100)
        self.NowTemperature.move(50, 130)

        self.WantTemperature.resize(300, 100)
        self.WantTemperature.move(400, 130)

        self.SettingDial.resize(190, 190)
        self.SettingDial.setRange(-20, 20)
        self.SettingDial.setNotchesVisible(True)
        self.SettingDial.move(460, 250)
        self.NowTemperature.display(sensorValue)

        self.SettingDial.valueChanged.connect(self.WantTemperature.display)
Ejemplo n.º 31
0
	def initUI(self):
		lcd = QLCDNumber(self)
		sld = QSlider(Qt.Horizontal,self)
		
		vbox = QVBoxLayout()
		vbox.addWidget(lcd)
		vbox.addWidget(sld)
		
		self.setLayout(vbox)
		sld.valueChanged.connect(lcd.display)
		#这里我们将滑块条的valuechange信号与ld数字显示的display槽连接在一起
		#发送者是一个发送了信号的对象,接受者是一个接受了信号的对象。槽是对信号做出反应的方法
		self.setGeometry(300,300,250,150)
		self.setWindowTitle('Signal & slot')
		self.show()
Ejemplo n.º 32
0
    def __init__(self):
        super().__init__()

        self.setWindowTitle("XXOO")
        lcd = QLCDNumber(self)
        slider = QSlider(Qt.Horizontal, self)

        vbox = QVBoxLayout()
        vbox.addWidget(lcd)
        vbox.addWidget(slider)

        self.setLayout(vbox)

        slider.valueChanged.connect(lcd.display)
        self.resize(350, 250)
Ejemplo n.º 33
0
    def initUI(self):
        lcd = QLCDNumber(self)
        sld = QSlider(Qt.Horizontal, self)

        vbox = QVBoxLayout()
        vbox.addWidget(lcd)
        vbox.addWidget(sld)

        self.setLayout(vbox)
        #Connect a valueChanged signal of the silder to the display slot of the lcd number
        sld.valueChanged.connect(lcd.display)

        self.setGeometry(300, 300, 300, 200)
        self.setWindowTitle('Singal and slot')
        self.show()
Ejemplo n.º 34
0
    def __init__(self):
        super(MainWindow, self).__init__()

        # 获取桌面尺寸
        desktop = QApplication.desktop()
        desk_width = desktop.screenGeometry().width()
        desk_height = desktop.screenGeometry().height()

        # 摄像头图像设置
        self.frame = DIYLabel(self)
        self.frame.setGeometry(0, 0, desk_width, desk_height)

        self.setupUi(self)

        # 按钮定位
        self.buttons = [
            self.att_rec, self.face_login, self.face_rec, self.face_reg
        ]
        map(
            lambda x: x.move(
                desk_width * 0.80, desk_height * 0.33 + self.buttons.index(x) *
                (x.height() + 8)), self.buttons)
        map(lambda x: x.raise_(), self.buttons)

        # 设置时钟
        self.clock = QLCDNumber(self)
        self.clock.setDigitCount(10)
        self.clock.setMode(QLCDNumber.Dec)
        self.clock.setSegmentStyle(QLCDNumber.Flat)
        self.clock.display(time.strftime("%X", time.localtime()))
        self.clock.setStyleSheet("QLCDNumber{color:rgba(255,0,0,100);}")
        self.clock.resize(280, 120)
        self.clock.move(50, desk_height - 30 - self.clock.height())

        self.setWindowFlags(Qt.FramelessWindowHint)  # 隐藏窗口
        self.showFullScreen()  # 窗体全屏
Ejemplo n.º 35
0
    def initUI(self):
        self.resize(370, 190)
        self.setWindowTitle('LCD数字')

        self.lcd = QLCDNumber(self)
        lb = QLabel("距离2022年北京-张家口冬季奥林匹克运动会还有", self)
        ft = QFont()
        ft.setPointSize(15)
        lb.setFont(ft)
        vbox = QVBoxLayout(self)
        vbox.addWidget(lb)
        vbox.addWidget(self.lcd)

        self.lcd.setDigitCount(13)
        self.lcd.setMode(QLCDNumber.Dec)
        self.lcd.setStyleSheet(
            "border: 2px solid black; color: red; background: silver;")

        time = QTimer(self)
        time.setInterval(1000)
        time.timeout.connect(self.refresh)
        time.start()

        self.show()
Ejemplo n.º 36
0
    def initUI(self):

        lcd = QLCDNumber(self)
        sld = QSlider(Qt.Horizontal, self)

        vbox = QVBoxLayout()
        vbox.addWidget(lcd)
        vbox.addWidget(sld)

        self.setLayout(vbox)
        sld.valueChanged.connect(lcd.display)

        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle('Signal and slot')
        self.show()
Ejemplo n.º 37
0
    def my_UI(self):
        lcd = QLCDNumber(self)  # LCDNumber 显示类
        sld = QSlider(Qt.Horizontal, self)  # QSlider 显示类

        vbox = QVBoxLayout()
        vbox.addWidget(lcd)
        vbox.addWidget(sld)

        self.setLayout(vbox)
        sld.valueChanged.connect(
            lcd.display)  # 将滑块条的valueChanged信号和lcd数字显示的display槽连接在一起

        self.setGeometry(300, 300, 300, 250)
        self.setWindowTitle('信号 & 槽')
        self.show()
Ejemplo n.º 38
0
    def __init__(self, parent=None):
        QWidget.__init__(self)
        self.setWindowTitle('slider')
        lcd = QLCDNumber(self)
        slider = QSlider(Qt.Horizontal, self)

        vbox = QVBoxLayout()
        vbox.addWidget(lcd)
        vbox.addWidget(slider)

        self.setLayout(vbox)

        slider.valueChanged.connect(lcd.display)
        slider.valueChanged.connect(self.display)
        self.resize(350, 250)
Ejemplo n.º 39
0
    def initUI(self):

        timer = QTimer(self)
        timer.timeout.connect(self.Time)
        timer.start(10)

        self.lcd = QLCDNumber(self)
        self.lcd.resize(250, 100)

        self.lcd.move(0, 30)
        self.lcd.display(strftime('%H' + ':' + '%M'))

        self.r1 = QRadioButton('Hide seconds', self)
        self.r1.move(10, 0)
        self.r2 = QRadioButton('Show seconds', self)
        self.r2.move(110, 0)

        self.r1.toggled.connect(self.woSecs)
        self.r2.toggled.connect(self.wSecs)

        self.setGeometry(300, 300, 250, 130)
        self.setWindowTitle('Clock')
        self.setWindowIcon(QIcon(''))
        self.show()
Ejemplo n.º 40
0
 def addMaintInfo(self, font):
     '''
     Adds maintenance QLCDNumber and connects it with the correct signals.
     '''
     maintLbl = QLabel("Total maintenance:", self)
     maintLbl.move(620, 10)
     maintLbl.setFont(font)
     maintLcd = QLCDNumber(3, self)
     maintLcd.move(840, 7)
     maintLcd.setFrameShape(QFrame.NoFrame)
     maintLcd.resize(50, 30)
     self.sig.maintChanged.connect(maintLcd.display)
     maint = self.game.player.get_armies_maint()
     self.sig.maintChanged.emit(maint[0] + maint[1])
Ejemplo n.º 41
0
    def __init__(self):
        super().__init__()

        lcd = QLCDNumber(self)
        sld = QSlider(Qt.Horizontal, self)

        vbox = QVBoxLayout()
        vbox.addWidget(lcd)
        vbox.addWidget(sld)

        self.setLayout(vbox)
        sld.valueChanged.connect(lcd.display)

        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle("Signals & Slots")
        self.show()
Ejemplo n.º 42
0
    def setup_ui(self):
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.timer = QTimer(parent=self)
        self.timer.setInterval(self.interval)
        self.timer.timeout.connect(self.do_countdown)
        self.lcd_number = QLCDNumber(parent=self)
        self.lcd_number.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.lcd_number.setFrameStyle(QFrame.NoFrame)
        self.lcd_number.setSegmentStyle(QLCDNumber.Flat)
        self.lcd_number.setDigitCount(6)

        layout = QVBoxLayout()
        layout.addWidget(self.lcd_number)
        self.setLayout(layout)

        self.reset_count()
Ejemplo n.º 43
0
    def initUI(self):
        lcd = QLCDNumber(self)  #数字
        sld = QSlider(Qt.Horizontal, self)  #横向滚动条

        vbox = QVBoxLayout()
        vbox.addWidget(lcd)
        vbox.addWidget(sld)

        self.setLayout(vbox)
        sld.valueChanged.connect(
            lcd.display)  #事件绑定,valueChanged信号连接到lcd的display插槽

        self.setGeometry(300, 300, 300, 220)  #x,y,w,h
        self.setWindowTitle('Icon')
        self.setWindowIcon(QIcon('web.png'))
        self.show()
Ejemplo n.º 44
0
    def SetupUi(self):
        self.qslider = QSlider(Qt.Horizontal)
        self.label = QLabel('0')
        self.lcd = QLCDNumber()

        hlayout = QHBoxLayout()
        hlayout.addWidget(self.label)
        hlayout.addWidget(self.lcd)

        vlayout = QVBoxLayout()
        vlayout.addLayout(hlayout)
        vlayout.addWidget(self.qslider)

        main_widget = QWidget()
        main_widget.setLayout(vlayout)
        self.setCentralWidget(main_widget)
Ejemplo n.º 45
0
    def initUI(self):
        lcd = QLCDNumber(self)
        sld = QSlider(Qt.Horizontal, self)

        vbox = QVBoxLayout()
        vbox.addWidget(lcd)
        vbox.addWidget(sld)

        self.setLayout(vbox)

        # here we have a valuechanged signal of the slider to the display of the lcd number
        # the sender is an object the sends a signal, the receiver is the object that receives the signal
        # the slot is the method that reacts the signal
        sld.valueChanged.connect(lcd.display)

        self.setWindowTitle('signal ans slot')
Ejemplo n.º 46
0
    def initUi(self):
        mainLayout = QVBoxLayout()
        self.setLayout(mainLayout)

        self.groupBox = QGroupBox("unit")
        self.radioButton1 = QRadioButton("s")
        self.radioButton1.toggled.connect(self.setUnit)
        self.radioButton2 = QRadioButton("0.1s")
        self.radioButton2.toggled.connect(self.setUnit)
        self.radioButton3 = QRadioButton("0.01s")
        self.radioButton3.toggled.connect(self.setUnit)
        self.radioButton4 = QRadioButton("1ms")
        self.radioButton4.toggled.connect(self.setUnit)
        self.radioButton1.setChecked(True)
        self.unitLayout = QHBoxLayout()
        self.unitLayout.addWidget(self.radioButton1)
        self.unitLayout.addWidget(self.radioButton2)
        self.unitLayout.addWidget(self.radioButton3)
        self.unitLayout.addWidget(self.radioButton4)
        self.groupBox.setLayout(self.unitLayout)
        mainLayout.addWidget(self.groupBox)

        self.buttonStart = QPushButton(self.tr("start"))
        mainLayout.addWidget(self.buttonStart)


        self.buttonStop = QPushButton(self.tr("stop"))
        mainLayout.addWidget(self.buttonStop)

        self.timeViewer = QLCDNumber()
        self.timeViewer.setFixedHeight(45)
        mainLayout.addWidget(self.timeViewer)

        self.timeForHuman = QLabel()
        mainLayout.addWidget(self.timeForHuman)


        self.buttonReset = QPushButton(self.tr("reset"))
        mainLayout.addWidget(self.buttonReset)

        self.timeSpinBox = QSpinBox()
        self.timeSpinBox.setRange(0,10000)
        mainLayout.addWidget(self.timeSpinBox)
        self.buttonCountDown = QPushButton(self.tr("countdown"))
        mainLayout.addWidget(self.buttonCountDown)
        self.buttonStopAlarm = QPushButton(self.tr("stopalarm"))
        mainLayout.addWidget(self.buttonStopAlarm)
class timeWidget(QWidget):

    time = pyqtSignal()
    def __init__(self,winParent):    
        super(timeWidget, self).__init__()
        self.winParent=winParent
        self.seconds = 0
        
        hLayout = QHBoxLayout()
        
        timeLabel = QLabel("Time")
        self.lcd = QLCDNumber(self)
        self.lcd.setMaximumSize(100,50)
        hLayout.addWidget(timeLabel,0)
        hLayout.addWidget(self.lcd, 1)

        hSpacer = QSpacerItem(300, 30, QSizePolicy.Ignored, QSizePolicy.Ignored)
        hLayout.addItem(hSpacer)

        self.setLayout(hLayout)

        timer = QTimer(self)
        timer.start(1000)
        timer.timeout.connect(self.printTime)


        # get the palette
        palette = self.lcd.palette()

        # foreground color
        palette.setColor(palette.WindowText, QColor(85, 85, 255))
        # background color
        palette.setColor(palette.Background, QColor(0, 170, 255))
        # "light" border
        palette.setColor(palette.Light, QColor(255, 0, 0))
        # "dark" border
        palette.setColor(palette.Dark, QColor(0, 255, 0))

        # set the palette
        self.lcd.setPalette(palette)

    def printTime(self):
        self.seconds += 1
        self.lcd.display(self.seconds)
Ejemplo n.º 48
0
    def __init__(self,winParent, percentaje):
        super(timeDigitalWidget, self).__init__()
        self.winParent=winParent
        self.seconds = 900
        self.pose3d = pose3d
        self.percentaje = percentaje
        self.show = False
        self.MAX_PERCENT = 30
        self.MAX_MARK = 10

        self.hLayout = QHBoxLayout()

        timeLabel = QLabel("Time")
        self.lcd = QLCDNumber(self)
        self.lcd.setMaximumSize(100,50)
        self.hLayout.addWidget(timeLabel,0)
        self.hLayout.addWidget(self.lcd, 1)

        hSpacer = QSpacerItem(300, 30, QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.hLayout.addItem(hSpacer)

        self.setLayout(self.hLayout)

        timer = QTimer(self)
        timer.start(1000)
        timer.timeout.connect(self.printTime)

        # get the palette
        palette = self.lcd.palette()

        # foreground color
        palette.setColor(palette.WindowText, QColor(85, 85, 255))
        # background color
        palette.setColor(palette.Background, QColor(0, 170, 255))
        # "light" border
        palette.setColor(palette.Light, QColor(255, 0, 0))
        # "dark" border
        palette.setColor(palette.Dark, QColor(0, 255, 0))

        # set the palette
        self.lcd.setPalette(palette)
Ejemplo n.º 49
0
    def __init__(self):
        super().__init__()
        self.setAcceptDrops(True)
        self.game = Game(4)  # Make game with 4 players

        self.sig = Signals()
        endTurnButton = QPushButton("&EndTurn", self)
        endTurnButton.clicked.connect(self.endTurn)
        endTurnButton.move(1260, 720)
        turnLcd = QLCDNumber(3, self)
        turnLcd.move(90, 715)
        turnLcd.setSegmentStyle(QLCDNumber.Filled)
        turnLcd.resize(60, 40)
        turnTxt = QLabel("Turn:", self)
        turnFont = QFont()
        turnFont.setPointSize(20)
        turnTxt.setFont(turnFont)
        turnTxt.move(20, 720)

        self.sig.turnChanged.connect(turnLcd.display)
        self.sig.turnChanged.emit(self.game.turn)

        quitB = QPushButton("&Quit", self)
        quitB.clicked.connect(self.quit)
        quitB.move(1150, 720)

        self.showPlayerInfo()

        self.coords = []
        self.setWindowTitle("Territory War")
        n = self.game.map.dim
        self.makeMap(1100 // n, 600 // n, n)
        self.setWindowState(Qt.WindowFullScreen)
        self.setFixedSize(self.size())

        self.showArmies()
        self.addDiplomacyLabels()

        thread = threading.Thread(target=self.game.start, args=(0, ))
        thread.start()
Ejemplo n.º 50
0
class CueWidget(QWidget):

    STOP = QIcon.fromTheme('led-off')
    START = QIcon.fromTheme('led-running')
    PAUSE = QIcon.fromTheme('led-pause')
    ERROR = QIcon.fromTheme('led-error')

    ICON_SIZE = 14

    context_menu_request = pyqtSignal(object, QPoint)
    edit_request = pyqtSignal(object)
    cue_executed = pyqtSignal(object)

    def __init__(self, cue, **kwargs):
        super().__init__(**kwargs)
        self.cue = None

        self._selected = False
        self._accurate_timing = False
        self._show_dbmeter = False
        self._countdown_mode = True

        self._dbmeter_element = None
        self._fade_element = None

        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setLayout(QGridLayout())

        self.layout().setContentsMargins(0, 0, 0, 0)
        self.layout().setSpacing(2)
        self.layout().setColumnStretch(0, 6)
        self.layout().setRowStretch(0, 4)

        self.nameButton = QClickLabel(self)
        self.nameButton.setObjectName('ButtonCueWidget')
        self.nameButton.setWordWrap(True)
        self.nameButton.setAlignment(Qt.AlignCenter)
        self.nameButton.setFocusPolicy(Qt.NoFocus)
        self.nameButton.clicked.connect(self._clicked)
        self.nameButton.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.layout().addWidget(self.nameButton, 0, 0)

        self.statusIcon = QLabel(self.nameButton)
        self.statusIcon.setStyleSheet('background-color: transparent')
        self.statusIcon.setPixmap(CueWidget.STOP.pixmap(CueWidget.ICON_SIZE,
                                                        CueWidget.ICON_SIZE))

        self.seekSlider = QClickSlider(self.nameButton)
        self.seekSlider.setOrientation(Qt.Horizontal)
        self.seekSlider.setFocusPolicy(Qt.NoFocus)
        self.seekSlider.setVisible(False)

        self.dbMeter = QDbMeter(self)
        self.dbMeter.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.dbMeter.setVisible(False)

        self.timeBar = QProgressBar(self)
        self.timeBar.setTextVisible(False)
        self.timeBar.setLayout(QHBoxLayout())
        self.timeBar.layout().setContentsMargins(0, 0, 0, 0)
        self.timeDisplay = QLCDNumber(self.timeBar)
        self.timeDisplay.setStyleSheet('background-color: transparent')
        self.timeDisplay.setSegmentStyle(QLCDNumber.Flat)
        self.timeDisplay.setDigitCount(8)
        self.timeDisplay.display('00:00:00')
        self.timeBar.layout().addWidget(self.timeDisplay)
        self.timeBar.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.timeBar.setVisible(False)

        self._set_cue(cue)

    @property
    def selected(self):
        return self._selected

    @selected.setter
    def selected(self, value):
        self._selected = value
        self._update_style(self.cue.stylesheet)

    def contextMenuEvent(self, event):
        self.context_menu_request.emit(self, event.globalPos())

    def mouseMoveEvent(self, event):
        if (event.buttons() == Qt.LeftButton and
                (event.modifiers() == Qt.ControlModifier or
                 event.modifiers() == Qt.ShiftModifier)):
            mime_data = QMimeData()
            mime_data.setText(PageWidget.DRAG_MAGIC)

            drag = QDrag(self)
            drag.setMimeData(mime_data)
            drag.setPixmap(self.grab(self.rect()))

            if event.modifiers() == Qt.ControlModifier:
                drag.exec_(Qt.MoveAction)
            else:
                drag.exec_(Qt.CopyAction)

            event.accept()
        else:
            event.ignore()

    def set_countdown_mode(self, mode):
        self._countdown_mode = mode
        self._update_time(self.cue.current_time())

    def set_accurate_timing(self, enable):
        self._accurate_timing = enable
        if self.cue.state == CueState.Pause:
            self._update_time(self.cue.current_time(), True)
        elif self.cue.state != CueState.Running:
            self._update_duration(self.cue.duration)

    def show_seek_slider(self, visible):
        self.seekSlider.setVisible(visible)
        self.update()

    def show_dbmeters(self, visible):
        if isinstance(self.cue, MediaCue):
            self._show_dbmeter = visible

            if self._dbmeter_element is not None:
                self._dbmeter_element.level_ready.disconnect(self.dbMeter.plot)
                self._dbmeter_element = None

            if visible:
                self._dbmeter_element = self.cue.media.element('DbMeter')
                if self._dbmeter_element is not None:
                    self._dbmeter_element.level_ready.connect(self.dbMeter.plot)

                self.layout().addWidget(self.dbMeter, 0, 1)
                self.layout().setColumnStretch(1, 1)
                self.dbMeter.show()
            else:
                self.dbMeter.hide()
                self.layout().setColumnStretch(1, 0)

            self.update()

    def _set_cue(self, cue):
        self.cue = cue
        self.cue.changed('name').connect(self._update_name, Connection.QtQueued)
        self.cue.changed('stylesheet').connect(self._update_style, Connection.QtQueued)
        self.cue.changed('duration').connect(self._update_duration, Connection.QtQueued)
        self.cue.changed('description').connect(self._update_description, Connection.QtQueued)

        if isinstance(cue, MediaCue):
            self.cue.media.changed('pipe').connect(self._media_updated)

            self.cue.paused.connect(self.dbMeter.reset, Connection.QtQueued)
            self.cue.stopped.connect(self.dbMeter.reset, Connection.QtQueued)
            self.cue.end.connect(self.dbMeter.reset, Connection.QtQueued)
            self.cue.error.connect(self.dbMeter.reset, Connection.QtQueued)

            self.seekSlider.sliderMoved.connect(self.cue.media.seek)
            self.seekSlider.sliderJumped.connect(self.cue.media.seek)

        # Cue status changed
        self.cue.started.connect(self._status_playing, Connection.QtQueued)
        self.cue.stopped.connect(self._status_stopped, Connection.QtQueued)
        self.cue.paused.connect(self._status_paused, Connection.QtQueued)
        self.cue.error.connect(self._status_error, Connection.QtQueued)
        self.cue.end.connect(self._status_stopped, Connection.QtQueued)

        self._cue_time = CueTime(self.cue)
        self._cue_time.notify.connect(self._update_time)

        self._update_name(cue.name)
        self._update_style(cue.stylesheet)
        self._update_duration(self.cue.duration)

    def _media_updated(self):
        self.show_dbmeters(self._show_dbmeter)

        new_fade = self.cue.media.element('Fade')
        if new_fade is not self._fade_element:
            if self._fade_element is not None:
                self._fade_element.enter_fadein.disconnect(self._enter_fadein)
                self._fade_element.enter_fadeout.disconnect(self._enter_fadeout)
                self._fade_element.exit_fadein.disconnect(self._exit_fade)
                self._fade_element.exit_fadeout.disconnect(self._exit_fade)

            if new_fade is not None:
                self._fade_element = new_fade
                self._fade_element.enter_fadein.connect(self._enter_fadein)
                self._fade_element.enter_fadeout.connect(self._enter_fadeout)
                self._fade_element.exit_fadein.connect(self._exit_fade)
                self._fade_element.exit_fadeout.connect(self._exit_fade)

    def _update_name(self, name):
        self.nameButton.setText(name)

    def _update_description(self, description):
        self.nameButton.setToolTip(description)

    def _clicked(self, event):
        if not self.seekSlider.geometry().contains(event.pos()):
            if event.button() != Qt.RightButton:
                if event.modifiers() == Qt.ShiftModifier:
                    self.edit_request.emit(self.cue)
                elif event.modifiers() == Qt.ControlModifier:
                    self.selected = not self.selected
                else:
                    self.cue_executed.emit(self.cue)
                    self.cue.execute()

    def _update_style(self, stylesheet):
        stylesheet += 'text-decoration: underline;' if self.selected else ''
        self.nameButton.setStyleSheet(stylesheet)

    def _enter_fadein(self):
        p = self.timeDisplay.palette()
        p.setColor(p.WindowText, QColor(0, 255, 0))
        self.timeDisplay.setPalette(p)

    def _enter_fadeout(self):
        p = self.timeDisplay.palette()
        p.setColor(p.WindowText, QColor(255, 50, 50))
        self.timeDisplay.setPalette(p)

    def _exit_fade(self):
        self.timeDisplay.setPalette(self.timeBar.palette())

    def _status_stopped(self):
        self.statusIcon.setPixmap(CueWidget.STOP.pixmap(CueWidget.ICON_SIZE,
                                                        CueWidget.ICON_SIZE))
        self._update_time(0, True)

    def _status_playing(self):
        self.statusIcon.setPixmap(CueWidget.START.pixmap(CueWidget.ICON_SIZE,
                                                         CueWidget.ICON_SIZE))

    def _status_paused(self):
        self.statusIcon.setPixmap(CueWidget.PAUSE.pixmap(CueWidget.ICON_SIZE,
                                                         CueWidget.ICON_SIZE))

    def _status_error(self, cue, error, details):
        self.statusIcon.setPixmap(CueWidget.ERROR.pixmap(CueWidget.ICON_SIZE,
                                                         CueWidget.ICON_SIZE))
        QDetailedMessageBox.dcritical(self.cue.name, error, details)

    def _update_duration(self, duration):
        # Update the maximum values of seek-slider and time progress-bar
        if duration > 0:
            if not self.timeBar.isVisible():
                self.layout().addWidget(self.timeBar, 1, 0, 1, 2)
                self.layout().setRowStretch(1, 1)
                self.timeBar.show()
            self.timeBar.setMaximum(duration)
            self.seekSlider.setMaximum(duration)
        else:
            self.timeBar.hide()
            self.layout().setRowStretch(1, 0)

        # If not in playing or paused update the widget showed time
        if self.cue.state != CueState.Running or self.cue.state != CueState.Running:
            self._update_time(duration, True)

    def _update_time(self, time, ignore_visibility=False):
        if ignore_visibility or not self.visibleRegion().isEmpty():
            # If the given value is the duration or < 0 set the time to 0
            if time == self.cue.duration or time < 0:
                time = 0

            # Set the value the seek slider
            self.seekSlider.setValue(time)

            # If in count-down mode the widget will show the remaining time
            if self._countdown_mode:
                time = self.cue.duration - time

            # Set the value of the timer progress-bar
            if self.cue.duration > 0:
                self.timeBar.setValue(time)

            # Show the time in the widget
            self.timeDisplay.display(strtime(time, accurate=self._accurate_timing))

    def resizeEvent(self, event):
        self.update()

    def update(self):
        super().update()
        self.layout().activate()

        xdim = self.nameButton.width()
        ydim = self.nameButton.height() / 5
        ypos = self.nameButton.height() - ydim

        self.seekSlider.setGeometry(0, ypos, xdim, ydim)
        self.statusIcon.setGeometry(4, 4, CueWidget.ICON_SIZE,
                                    CueWidget.ICON_SIZE)
class PlayingMediaWidget(QWidget):

    def __init__(self, cue, **kwargs):
        super().__init__(**kwargs)

        self.cue = cue
        self.cue_time = CueTime(cue)
        self.cue_time.notify.connect(self._time_updated, Connection.QtQueued)

        self._dbmeter_element = None
        self._accurate_time = False

        scroll_size = (self.parent().verticalScrollBar().width() + 5)
        self.setGeometry(0, 0, self.parent().width() - scroll_size, 102)
        self.setFocusPolicy(Qt.NoFocus)

        self.gridLayoutWidget = QWidget(self)
        self.gridLayoutWidget.setGeometry(self.geometry())
        self.gridLayout = QGridLayout(self.gridLayoutWidget)
        self.gridLayout.setContentsMargins(2, 2, 2, 2)

        self.nameLabel = QLabel(self.gridLayoutWidget)
        self.nameLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.nameLabel.setText(cue.name)
        self.nameLabel.setToolTip(cue.name)
        self.gridLayout.addWidget(self.nameLabel, 0, 0, 1, 3)

        self.playPauseButton = QPushButton(self.gridLayoutWidget)
        self.playPauseButton.setSizePolicy(QSizePolicy.Ignored,
                                           QSizePolicy.Ignored)
        self.playPauseButton.setIcon(QIcon.fromTheme('media-playback-pause'))
        self.playPauseButton.setIconSize(QSize(24, 24))
        self.playPauseButton.setFocusPolicy(Qt.NoFocus)
        self.playPauseButton.clicked.connect(self._pause)
        self.gridLayout.addWidget(self.playPauseButton, 1, 0)

        self.stopButton = QPushButton(self.gridLayoutWidget)
        self.stopButton.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.stopButton.setIcon(QIcon.fromTheme('media-playback-stop'))
        self.stopButton.setIconSize(QSize(24, 24))
        self.stopButton.setFocusPolicy(Qt.NoFocus)
        self.stopButton.clicked.connect(self._stop)
        self.gridLayout.addWidget(self.stopButton, 1, 1)

        self.timeDisplay = QLCDNumber(self.gridLayoutWidget)
        self.timeDisplay.setStyleSheet('background-color: transparent')
        self.timeDisplay.setSegmentStyle(QLCDNumber.Flat)
        self.timeDisplay.setDigitCount(8)
        self.timeDisplay.display(strtime(cue.media.duration))
        self.gridLayout.addWidget(self.timeDisplay, 1, 2)

        self.seekSlider = QClickSlider(self.gridLayoutWidget)
        self.seekSlider.setOrientation(Qt.Horizontal)
        self.seekSlider.setRange(0, cue.media.duration)
        self.seekSlider.setFocusPolicy(Qt.NoFocus)
        self.seekSlider.sliderMoved.connect(self._seek)
        self.seekSlider.sliderJumped.connect(self._seek)
        self.seekSlider.setVisible(False)

        self.dbmeter = QDbMeter(self.gridLayoutWidget)
        self.dbmeter.setVisible(False)

        self.gridLayout.setRowStretch(0, 1)
        self.gridLayout.setRowStretch(1, 2)
        self.gridLayout.setColumnStretch(0, 3)
        self.gridLayout.setColumnStretch(1, 3)
        self.gridLayout.setColumnStretch(2, 5)

        cue.changed('name').connect(self.name_changed)
        cue.media.changed('duration').connect(self.update_duration)
        cue.media.played.connect(self._pause_to_play)
        cue.media.paused.connect(self._play_to_pause)

        self.fade = self.cue.media.element('Fade')
        if self.fade is not None:
            self.fade.enter_fadein.connect(self.enter_fadein)
            self.fade.enter_fadeout.connect(self.enter_fadeout)
            self.fade.exit_fadein.connect(self.exit_fade)
            self.fade.exit_fadeout.connect(self.exit_fade)

    def enter_fadeout(self):
        p = self.timeDisplay.palette()
        p.setColor(p.Text, QColor(255, 50, 50))
        self.timeDisplay.setPalette(p)

    def enter_fadein(self):
        p = self.timeDisplay.palette()
        p.setColor(p.Text, QColor(0, 255, 0))
        self.timeDisplay.setPalette(p)

    def exit_fade(self):
        self.timeDisplay.setPalette(self.palette())

    def name_changed(self, name):
        self.nameLabel.setText(name)
        self.nameLabel.setToolTip(name)

    def set_accurate_time(self, enable):
        self._accurate_time = enable

    def set_seek_visible(self, visible):
        if visible and not self.seekSlider.isVisible():
            self.gridLayout.addWidget(self.seekSlider, 2, 0, 1, 3)
            self.gridLayout.setRowStretch(2, 1)
        elif not visible and self.seekSlider.isVisible():
            self.gridLayout.removeWidget(self.seekSlider)
            self.gridLayout.setRowStretch(2, 0)

        self.seekSlider.setVisible(visible)

    def set_dbmeter_visible(self, visible):
        if self._dbmeter_element is not None:
            self._dbmeter_element.level_ready.disconnect(self.dbmeter.plot)
            self._dbmeter_element = None

        if visible:
            self._dbmeter_element = self.cue.media.element('DbMeter')
            if self._dbmeter_element is not None:
                self._dbmeter_element.level_ready.connect(self.dbmeter.plot)

        # Add/Remove the QDbMeter in the layout
        if visible and not self.dbmeter.isVisible():
            self.gridLayout.addWidget(self.dbmeter, 0, 3, 4, 1)
            self.gridLayout.setColumnStretch(3, 1)
        elif not visible and self.dbmeter.isVisible():
            self.gridLayout.removeWidget(self.dbmeter)
            self.gridLayout.setColumnStretch(3, 0)

        self.dbmeter.setVisible(visible)

    def _time_updated(self, time):
        if not self.visibleRegion().isEmpty():
            # If the given value is the duration or < 0 set the time to 0
            if time == self.cue.media.duration or time < 0:
                time = 0

            # Set the value the seek slider
            self.seekSlider.setValue(time)

            # Show the time in the widget
            self.timeDisplay.display(strtime(self.cue.media.duration - time,
                                             accurate=self._accurate_time))

    def update_duration(self, media, duration):
        self.seekSlider.setMaximum(duration)

    def _stop(self, *args):
        self.cue.stop()

    def _play(self, *args):
        self.cue.start()

    def _pause(self, *args):
        self.cue.pause()

    def _seek(self, position):
        self.cue.media.seek(position)

    def _play_to_pause(self):
        self.playPauseButton.clicked.disconnect()
        self.playPauseButton.clicked.connect(self._play)
        self.playPauseButton.setIcon(QIcon.fromTheme('media-playback-start'))

    def _pause_to_play(self):
        self.playPauseButton.clicked.disconnect()
        self.playPauseButton.clicked.connect(self._pause)
        self.playPauseButton.setIcon(QIcon.fromTheme('media-playback-pause'))
Ejemplo n.º 52
0
class Ui_Widget(object):
    """ Klasa definiująca GUI """

    def setupUi(self, Widget):

        # widgety rysujące kształty, instancje klasy Ksztalt
        self.ksztalt1 = Ksztalt(self, Ksztalty.Polygon)
        self.ksztalt2 = Ksztalt(self, Ksztalty.Ellipse)
        self.ksztaltAktywny = self.ksztalt1

        # przyciski CheckBox ###
        uklad = QVBoxLayout()  # układ pionowy
        self.grupaChk = QButtonGroup()
        for i, v in enumerate(('Kwadrat', 'Koło', 'Trójkąt', 'Linia')):
            self.chk = QCheckBox(v)
            self.grupaChk.addButton(self.chk, i)
            uklad.addWidget(self.chk)
        self.grupaChk.buttons()[self.ksztaltAktywny.ksztalt].setChecked(True)
        # CheckBox do wyboru aktywnego kształtu
        self.ksztaltChk = QCheckBox('<=')
        self.ksztaltChk.setChecked(True)
        uklad.addWidget(self.ksztaltChk)

        # układ poziomy dla kształtów oraz przycisków CheckBox
        ukladH1 = QHBoxLayout()
        ukladH1.addWidget(self.ksztalt1)
        ukladH1.addLayout(uklad)
        ukladH1.addWidget(self.ksztalt2)
        # koniec CheckBox ###

        # Slider i LCDNumber ###
        self.suwak = QSlider(Qt.Horizontal)
        self.suwak.setMinimum(0)
        self.suwak.setMaximum(255)
        self.lcd = QLCDNumber()
        self.lcd.setSegmentStyle(QLCDNumber.Flat)
        # układ poziomy (splitter) dla slajdera i lcd
        ukladH2 = QSplitter(Qt.Horizontal, self)
        ukladH2.addWidget(self.suwak)
        ukladH2.addWidget(self.lcd)
        ukladH2.setSizes((125, 75))

        # przyciski RadioButton ###
        self.ukladR = QHBoxLayout()
        for v in ('R', 'G', 'B'):
            self.radio = QRadioButton(v)
            self.ukladR.addWidget(self.radio)
        self.ukladR.itemAt(0).widget().setChecked(True)
        # grupujemy przyciski
        self.grupaRBtn = QGroupBox('Opcje RGB')
        self.grupaRBtn.setLayout(self.ukladR)
        self.grupaRBtn.setObjectName('Radio')
        self.grupaRBtn.setCheckable(True)
        # układ poziomy dla grupy Radio
        ukladH3 = QHBoxLayout()
        ukladH3.addWidget(self.grupaRBtn)
        # koniec RadioButton ###

        # główny układ okna, pionowy ###
        ukladOkna = QVBoxLayout()
        ukladOkna.addLayout(ukladH1)
        ukladOkna.addWidget(ukladH2)
        ukladOkna.addLayout(ukladH3)

        self.setLayout(ukladOkna)  # przypisanie układu do okna głównego
        self.setWindowTitle('Widżety')
Ejemplo n.º 53
0
class Objetives(QWidget):
    NumButtons = 3

    def __init__(self, parent=None):
        super(Objetives, self).__init__(parent)

        self.createDisplay()
        self.createDisplayAverage()
        self.createButtons()

        self.numVictory = 0
        self.numLosses = 0

        mainLayout = QGridLayout()
        mainLayout.addWidget(self.displayLCD)
        mainLayout.addWidget(self.horizontalGroupBox)
        mainLayout.addWidget(self.displayWinPercent)

        self.setLayout(mainLayout)

        self.setWindowTitle("Objetives")

    def createButtons(self):
        self.horizontalGroupBox = QGroupBox("")
        layout = QGridLayout()

        self.victoryButton = self.createButton("Victory", "+",self.addVictoryOrLosses)
        self.lossesButton = self.createButton("Losses", "+",self.addVictoryOrLosses)
        self.victoryDecreaseButton = self.createButton("DV","-",self.addVictoryOrLosses)
        self.losseDecreaseButton = self.createButton("DL","-",self.addVictoryOrLosses)

        self.lossesButton.setMinimumWidth(150)
        self.victoryButton.setMinimumWidth(150)

        self.losseDecreaseButton.setMaximumHeight(20)
        self.victoryDecreaseButton.setMaximumHeight(20)

        layout.addWidget(self.victoryButton, 0, 0, 1, 1)
        layout.addWidget(self.lossesButton, 0, 2, 1, 1)
        layout.addWidget(self.victoryDecreaseButton, 1, 0, 1, 1)
        layout.addWidget(self.losseDecreaseButton, 1, 2, 1, 1)

        self.horizontalGroupBox.setLayout(layout)

    def createDisplayAverage(self):
        self.displayWinPercent = QGroupBox("Wins")
        layout = QHBoxLayout()

        self.progressBar = QProgressBar()
        self.progressBar.setRange(0, 100)
        # self.progressBar.setValue(5000)

        layout.addWidget(self.progressBar)

        self.displayWinPercent.setLayout(layout)

    def createDisplay(self):
        self.displayLCD = QGroupBox("")
        layout = QHBoxLayout()

        paletteLosses = QPalette()
        paletteVictory = QPalette()

        paletteLosses.setColor(paletteLosses.WindowText, QColor(255, 000, 000))
        paletteVictory.setColor(paletteVictory.WindowText, QColor(000, 255, 000))

        self.lossesLcd = QLCDNumber(3)
        self.lossesLcd.setSegmentStyle(QLCDNumber.Filled)
        self.lossesLcd.setPalette(paletteLosses)

        self.victoryLcd = QLCDNumber(3)
        self.victoryLcd.setSegmentStyle(QLCDNumber.Filled)
        self.victoryLcd.setPalette(paletteVictory)

        self.lossesLcd.setMinimumHeight(100)
        self.victoryLcd.setMinimumHeight(100)

        self.lossesLcd.setMinimumWidth(150)
        self.victoryLcd.setMinimumWidth(150)

        layout.addWidget(self.victoryLcd)
        layout.addWidget(self.lossesLcd)

        self.displayLCD.setLayout(layout)

    def addVictoryOrLosses(self):
        clickedButton = self.sender()
        clickedOperator = clickedButton.text()
        operand = float(1)

        if clickedOperator == "Victory":
            self.numVictory = self.numVictory + 1
            self.victoryLcd.display(str(self.numVictory))

        if clickedOperator == "DV":
            self.numVictory = self.numVictory - 1
            self.victoryLcd.display(str(self.numVictory))

        if clickedOperator == "Losses":
            self.numLosses = self.numLosses + 1
            self.lossesLcd.display(str(self.numLosses))

        if clickedOperator == "DL":
            self.numLosses = self.numLosses - 1
            self.lossesLcd.display(str(self.numLosses))

        self.calculateAverage()

    def calculateAverage(self):
        total = self.numVictory + self.numLosses

        # self.progressBar.setValue((int(self.numVictory / total * 100)))
        self.progressBar.setValue(100)
        # self.victoryLcdAv.display(str(int(self.numVictory / total * 100)))
        # self.lossesLcdAv.display(str(int(self.numLosses / total * 100)))

    def createButton(self, text, op, member):
        button = Button(text,op)
        button.clicked.connect(member)
        return button
Ejemplo n.º 54
0
 def initUI(self, gameboard): 
     
     self.setStyleSheet("QWidget { background: #BCBCBC}")
     self.setFrameStyle(QFrame.Sunken | QFrame.StyledPanel)
     self.setFixedSize((gameboard.width - 1)*blockSize, 120)
     self.grid = QGridLayout()
     self.setLayout(self.grid)
     
     hbox = QHBoxLayout()
     vbox = QVBoxLayout()
     
     towerLabel = QLabel()
     towerLabel.setPixmap(QPixmap(os.path.join('./Pictures/', "tower.png")))
     
     vbox.addWidget(towerLabel)
     
     vbox.addLayout(hbox)
     self.grid.addLayout(vbox, 0, 0)
     
     towers = gameboard.getTowers()
     i = 0
     buttons = 0
     
     # We go through the list of different towers in the map and add buttons for them to the bottom left corner of the screen.
     while i < len(towers):
         if towers[i] == "t1":
             self.musketeerButton = BuyButton(QPixmap(os.path.join('./Pictures/', "musketeer_buybutton.png")), QPixmap(os.path.join('./Pictures/', "musketeer_buybutton_hover.png")), QPixmap(os.path.join('./Pictures/', "musketeer_buybutton_pressed.png")), self)
             self.musketeerButton.move(buttons*towerButtonSize + 10, 50)
             self.musketeerButton.clicked.connect(self.musketeerButtonClick)
             hbox.addWidget(self.musketeerButton)
             buttons += 1
         elif towers[i] == "t2":
             self.cannonButton = BuyButton(QPixmap(os.path.join('./Pictures/', "cannon_buybutton.png")), QPixmap(os.path.join('./Pictures/', "cannon_buybutton_hovered.png")), QPixmap(os.path.join('./Pictures/', "cannon_buybutton_pressed.png")), self)
             self.cannonButton.move(buttons*towerButtonSize + 10, 50)
             self.cannonButton.clicked.connect(self.cannonButtonClick)
             hbox.addWidget(self.cannonButton)
             buttons += 1
         i += 1
     
     hbox.addStretch()
     
     '''
     slider2 = QSlider(Qt.Horizontal, self)
     slider2.setFocusPolicy(Qt.NoFocus)
     slider2.setSliderPosition(100 - self.parent.gameSpeed)
     #slider2.setGeometry(210, 140, 100, 20)
     slider2.valueChanged[int].connect(self.changeGameSpeed)
     
     hbox2 = QHBoxLayout()
     hbox2.addWidget(slider2)
     hbox2.addStretch()
     
     self.grid.addLayout(hbox2, 0, 1)
     '''
     
     hbox3 = QHBoxLayout()
     vbox3 = QVBoxLayout()
     hbox3.addStretch()
     
     self.lcd = QLCDNumber(self)
     
     vbox3.addStretch()
     vbox3.addWidget(self.lcd)
     vbox3.addStretch()
     
     self.pauseButton = QPushButton('Pause')
     self.pauseButton.clicked.connect(self.pauseGame)
 
     # I could add a restart button
     
     vbox3.addWidget(self.pauseButton)      
     self.grid.addLayout(vbox3, 0,2)
     
     self.show()
class SinglePlayerGame(QWidget):
    def __init__(self, difficulty=1, numberOfGames=1):
        super(SinglePlayerGame, self).__init__()
        self.difficulty = difficulty
        self.numberOfGames = numberOfGames
        self.gamesPlayed = 0
        self.playerScore = 0
        self.opponentScore = 0
        self.playerIsNotFirst = False

        self.gamesCounter = QLabel()
        self.gamesCounter.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self.updateGameCounter()

        mainLayout = QVBoxLayout()

        self.gameWidget = BotGame(self.getOpponent())
        self.gameWidget.gameEnded.connect(self.updateScoreAndReset)
        self.saveButton = QPushButton('Save series')
        self.saveButton.clicked.connect(self.saveGame)
        self.message = self.createLabel('')
        self.message.hide()
        mainLayout.addLayout(self.createScoreLayout())
        mainLayout.addWidget(self.gameWidget)
        mainLayout.addWidget(self.message)
        pack = self.packInHStretch([self.gamesCounter, self.saveButton])
        mainLayout.addLayout(pack)
        self.setLayout(mainLayout)

    def createScoreLayout(self):
        self.playerScoreLcd = QLCDNumber(2)
        self.playerScoreLcd.setSegmentStyle(QLCDNumber.Filled)
        self.playerScoreLcd.setMinimumSize(75, 50)
        self.playerScoreLcd.display(0)
        self.opponentScoreLcd = QLCDNumber(2)
        self.opponentScoreLcd.setSegmentStyle(QLCDNumber.Filled)
        self.opponentScoreLcd.setMinimumSize(75, 50)
        self.opponentScoreLcd.display(0)
        layout = QHBoxLayout()
        layout.addStretch(1)
        layout.addWidget(self.createLabel('You: '))
        layout.addWidget(self.playerScoreLcd)
        layout.addStretch(1)
        layout.addWidget(self.createLabel('Opponent: '))
        layout.addWidget(self.opponentScoreLcd)
        layout.addStretch(1)
        return layout

    def packInHStretch(self, widgets):
        layout = QHBoxLayout()
        layout.addStretch(1)
        for widget in widgets:
            layout.addWidget(widget)
            layout.addStretch(1)
        return layout

    def displayMessage(self, message):
        self.message.setText(message)
        self.message.show()
        self.repaint()

    def hideMessage(self):
        self.message.hide()
        self.repaint()

    def updateScoreAndReset(self):
        self.gamesPlayed += 1
        self.playerIsNotFirst = not self.playerIsNotFirst
        result = self.gameWidget.board.state
        message = ''
        if result == game.boards.State.X_WON:
            self.playerScore += 3
            message = 'Congrats! You won the game!'
        elif result == game.boards.State.O_WON:
            self.opponentScore += 3
            message = 'Sorry! You lost the game!'
        elif result == game.boards.State.DRAW:
            self.playerScore += 1
            self.opponentScore += 1
            message = 'The game ended in a draw!'
        self.displayMessage(message)
        self.playerScoreLcd.display(self.playerScore)
        self.opponentScoreLcd.display(self.opponentScore)
        if self.numberOfGames > self.gamesPlayed:
            for i in range(3, 0, -1):
                self.displayMessage(message + ' New game starting in ' +
                                    str(i))
                time.sleep(1)
            self.hideMessage()
            self.gameWidget.reset(self.playerIsNotFirst)
            self.updateGameCounter()
        else:
            self.announceResult()

    def announceResult(self):
        if self.playerScore > self.opponentScore:
            self.displayMessage('Congrats! You won the series!')
        elif self.playerScore < self.opponentScore:
            self.displayMessage('Sorry. You lost the series!')
        else:
            self.displayMessage('The series ended in a draw!')

    def updateGameCounter(self):
        self.gamesCounter.setText('Game ' + str(self.gamesPlayed + 1) +
                                  ' of ' + str(self.numberOfGames))

    def createLabel(self, text):
        lbl = QLabel(text)
        lbl.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        font = QFont()
        font.setPointSize(12)
        lbl.setFont(font)
        return lbl

    def getOpponent(self):
        return game.players.ai.select_bot(self.difficulty)

    def saveGame(self):
        if self.gamesPlayed == self.numberOfGames:
            if self.gameWidget.board.state != game.boards.State.IN_PROGRESS:
                self.displayMessage('Cannot save. The game has ended.')
                return
        filename = QFileDialog().getSaveFileName(self, 'Save game',
                                                 'untitledgame')
        if not filename[0]:
            return
        self.displayMessage('Saving...')
        with open(filename[0], 'wb') as handle:
            pickle.dump(self.getConfiguration(), handle)
        self.displayMessage('Saved!')

    def getConfiguration(self):
        return (self.difficulty,
                self.numberOfGames,
                self.gamesPlayed,
                self.playerScore,
                self.opponentScore,
                self.playerIsNotFirst,
                self.gameWidget.board)

    def validateConfig(self, config):
        if not isinstance(config, tuple):
            return False
        if len(config) != 7:
            return False
        if not isinstance(config[0], int) or config[0] not in range(1, 5):
            return False
        if not isinstance(config[1], int) or config[1] < 1:
            return False
        if not isinstance(config[2], int) or config[2] > config[1]:
            return False
        if not isinstance(config[3], int) or config[3] < 0:
            return False
        if not isinstance(config[4], int) or config[4] < 0:
            return False
        if not isinstance(config[5], bool):
            return False
        if not isinstance(config[6], game.boards.Macroboard):
            return False
        return True

    def loadConfiguration(self, config):
        if not self.validateConfig(config):
            raise ValueError('Invalid configuration')
        self.difficulty = config[0]
        self.numberOfGames = config[1]
        self.gamesPlayed = config[2]
        self.playerScore = config[3]
        self.opponentScore = config[4]
        self.playerIsNotFirst = config[5]
        self.gameWidget.loadBoard(config[6])
        self.gameWidget.setSecondPlayer(self.getOpponent())
        self.updateGameCounter()
        self.playerScoreLcd.display(self.playerScore)
        self.opponentScoreLcd.display(self.opponentScore)
Ejemplo n.º 56
0
    def setupUi(self, Widget):

        # widgety rysujące kształty, instancje klasy Ksztalt
        self.ksztalt1 = Ksztalt(self, Ksztalty.Polygon)
        self.ksztalt2 = Ksztalt(self, Ksztalty.Ellipse)
        self.ksztaltAktywny = self.ksztalt1

        # przyciski CheckBox ###
        uklad = QVBoxLayout()  # układ pionowy
        self.grupaChk = QButtonGroup()
        for i, v in enumerate(('Kwadrat', 'Koło', 'Trójkąt', 'Linia')):
            self.chk = QCheckBox(v)
            self.grupaChk.addButton(self.chk, i)
            uklad.addWidget(self.chk)
        self.grupaChk.buttons()[self.ksztaltAktywny.ksztalt].setChecked(True)
        # CheckBox do wyboru aktywnego kształtu
        self.ksztaltChk = QCheckBox('<=')
        self.ksztaltChk.setChecked(True)
        uklad.addWidget(self.ksztaltChk)

        # układ poziomy dla kształtów oraz przycisków CheckBox
        ukladH1 = QHBoxLayout()
        ukladH1.addWidget(self.ksztalt1)
        ukladH1.addLayout(uklad)
        ukladH1.addWidget(self.ksztalt2)
        # koniec CheckBox ###

        # Slider i LCDNumber ###
        self.suwak = QSlider(Qt.Horizontal)
        self.suwak.setMinimum(0)
        self.suwak.setMaximum(255)
        self.lcd = QLCDNumber()
        self.lcd.setSegmentStyle(QLCDNumber.Flat)
        # układ poziomy (splitter) dla slajdera i lcd
        ukladH2 = QSplitter(Qt.Horizontal, self)
        ukladH2.addWidget(self.suwak)
        ukladH2.addWidget(self.lcd)
        ukladH2.setSizes((125, 75))

        # przyciski RadioButton ###
        self.ukladR = QHBoxLayout()
        for v in ('R', 'G', 'B'):
            self.radio = QRadioButton(v)
            self.ukladR.addWidget(self.radio)
        self.ukladR.itemAt(0).widget().setChecked(True)
        # grupujemy przyciski
        self.grupaRBtn = QGroupBox('Opcje RGB')
        self.grupaRBtn.setLayout(self.ukladR)
        self.grupaRBtn.setObjectName('Radio')
        self.grupaRBtn.setCheckable(True)
        # układ poziomy dla grupy Radio
        ukladH3 = QHBoxLayout()
        ukladH3.addWidget(self.grupaRBtn)
        # koniec RadioButton ###

        # Lista ComboBox i SpinBox ###
        self.listaRGB = QComboBox(self)
        for v in ('R', 'G', 'B'):
            self.listaRGB.addItem(v)
        self.listaRGB.setEnabled(False)
        # SpinBox
        self.spinRGB = QSpinBox()
        self.spinRGB.setMinimum(0)
        self.spinRGB.setMaximum(255)
        self.spinRGB.setEnabled(False)
        # układ pionowy dla ComboBox i SpinBox
        uklad = QVBoxLayout()
        uklad.addWidget(self.listaRGB)
        uklad.addWidget(self.spinRGB)
        # do układu poziomego grupy Radio dodajemy układ ComboBox i SpinBox
        ukladH3.insertSpacing(1, 25)
        ukladH3.addLayout(uklad)
        # koniec ComboBox i SpinBox ###

        # przyciski PushButton ###
        uklad = QHBoxLayout()
        self.grupaP = QButtonGroup()
        self.grupaP.setExclusive(False)
        for v in ('R', 'G', 'B'):
            self.btn = QPushButton(v)
            self.btn.setCheckable(True)
            self.grupaP.addButton(self.btn)
            uklad.addWidget(self.btn)
        # grupujemy przyciski
        self.grupaPBtn = QGroupBox('Przyciski RGB')
        self.grupaPBtn.setLayout(uklad)
        self.grupaPBtn.setObjectName('Push')
        self.grupaPBtn.setCheckable(True)
        self.grupaPBtn.setChecked(False)
        # koniec PushButton ###

        # główny układ okna, wertykalny ###
        ukladOkna = QVBoxLayout()
        ukladOkna.addLayout(ukladH1)
        ukladOkna.addWidget(ukladH2)
        ukladOkna.addLayout(ukladH3)
        ukladOkna.addWidget(self.grupaPBtn)

        self.setLayout(ukladOkna)  # przypisanie układu do okna głównego
        self.setWindowTitle('Widżety')
Ejemplo n.º 57
0
class Ten(QWidget):

    def __init__(self, parent=None):
        super().__init__(parent)

        self._START = '&START'
        self._STOP = 'S&TOP'
        self._RESET = '&RESET'
        self._FORMAT = 'hh:mm:ss.zzz'

        self._widgets()
        self._layout()
        self._properties()
        self._connections()

    def _widgets(self):

        self.shiverTimer = QTime(0, 0, 0)
        self.timer = QTimer()
        self.timerLCDNumber = QLCDNumber()
        self.timerLCDNumber.setDigitCount(12)
        self.timerLCDNumber.display("00:00:00.000")
        self.stortPushButton = QPushButton(self._START)
        self.resetPushButton = QPushButton(self._RESET)

    def _layout(self):

        grid = QGridLayout()
        grid.addWidget(self.timerLCDNumber, 0, 0, 1, 2)
        grid.addWidget(self.stortPushButton, 1, 0)
        grid.addWidget(self.resetPushButton, 1, 1)

        self.setLayout(grid)

    def _properties(self):

        self.resize(350, 125)
        self.setWindowTitle('{} {}'.format(__title__, __version__))
        self.setWindowFlags(Qt.MSWindowsFixedSizeDialogHint)

    def _connections(self):

        self.timer.timeout.connect(self.showStopwatch)
        self.stortPushButton.clicked.connect(self.on_stortPushButton_clicked)
        self.resetPushButton.clicked.connect(self.on_resetPushButton_clicked)

    def showStopwatch(self):
        """
            Event handler for showing elapsed time, just like a stopwatch
        """

        self.shiverTimer = self.shiverTimer.addMSecs(1)
        text = self.shiverTimer.toString(self._FORMAT)
        self.timerLCDNumber.display(text)

    def on_stortPushButton_clicked(self):

        if self.stortPushButton.text() == self._START:
            self.timer.start(1)                     # Start the timer
            self.stortPushButton.setText(self._STOP)
        else:
            self.timer.stop()                       # Stop the timer
            self.stortPushButton.setText(self._START)

    def on_resetPushButton_clicked(self):

        self.timer.stop()
        self.shiverTimer = QTime(0, 0, 0)
        self.timerLCDNumber.display(self.shiverTimer.toString(self._FORMAT))

        if self.stortPushButton.text() == self._STOP:
            self.stortPushButton.setText(self._START)
Ejemplo n.º 58
0
class BottomButtons(QFrame):
    
    def __init__(self, parent):
        super(BottomButtons, self).__init__(parent)
        self.parent = parent
        self.isPaused = False
        self.seconds = 0
        self.clockTimer = QBasicTimer()
        self.clockTimer.start(1000, self)
        self.initUI(self.parent.gameboard)
        
        
    def initUI(self, gameboard): 
        
        self.setStyleSheet("QWidget { background: #BCBCBC}")
        self.setFrameStyle(QFrame.Sunken | QFrame.StyledPanel)
        self.setFixedSize((gameboard.width - 1)*blockSize, 120)
        self.grid = QGridLayout()
        self.setLayout(self.grid)
        
        hbox = QHBoxLayout()
        vbox = QVBoxLayout()
        
        towerLabel = QLabel()
        towerLabel.setPixmap(QPixmap(os.path.join('./Pictures/', "tower.png")))
        
        vbox.addWidget(towerLabel)
        
        vbox.addLayout(hbox)
        self.grid.addLayout(vbox, 0, 0)
        
        towers = gameboard.getTowers()
        i = 0
        buttons = 0
        
        # We go through the list of different towers in the map and add buttons for them to the bottom left corner of the screen.
        while i < len(towers):
            if towers[i] == "t1":
                self.musketeerButton = BuyButton(QPixmap(os.path.join('./Pictures/', "musketeer_buybutton.png")), QPixmap(os.path.join('./Pictures/', "musketeer_buybutton_hover.png")), QPixmap(os.path.join('./Pictures/', "musketeer_buybutton_pressed.png")), self)
                self.musketeerButton.move(buttons*towerButtonSize + 10, 50)
                self.musketeerButton.clicked.connect(self.musketeerButtonClick)
                hbox.addWidget(self.musketeerButton)
                buttons += 1
            elif towers[i] == "t2":
                self.cannonButton = BuyButton(QPixmap(os.path.join('./Pictures/', "cannon_buybutton.png")), QPixmap(os.path.join('./Pictures/', "cannon_buybutton_hovered.png")), QPixmap(os.path.join('./Pictures/', "cannon_buybutton_pressed.png")), self)
                self.cannonButton.move(buttons*towerButtonSize + 10, 50)
                self.cannonButton.clicked.connect(self.cannonButtonClick)
                hbox.addWidget(self.cannonButton)
                buttons += 1
            i += 1
        
        hbox.addStretch()
        
        '''
        slider2 = QSlider(Qt.Horizontal, self)
        slider2.setFocusPolicy(Qt.NoFocus)
        slider2.setSliderPosition(100 - self.parent.gameSpeed)
        #slider2.setGeometry(210, 140, 100, 20)
        slider2.valueChanged[int].connect(self.changeGameSpeed)
        
        hbox2 = QHBoxLayout()
        hbox2.addWidget(slider2)
        hbox2.addStretch()
        
        self.grid.addLayout(hbox2, 0, 1)
        '''
        
        hbox3 = QHBoxLayout()
        vbox3 = QVBoxLayout()
        hbox3.addStretch()
        
        self.lcd = QLCDNumber(self)
        
        vbox3.addStretch()
        vbox3.addWidget(self.lcd)
        vbox3.addStretch()
        
        self.pauseButton = QPushButton('Pause')
        self.pauseButton.clicked.connect(self.pauseGame)
    
        # I could add a restart button
        
        vbox3.addWidget(self.pauseButton)      
        self.grid.addLayout(vbox3, 0,2)
        
        self.show()
    
    
    def changeGameSpeed(self, value):
        self.parent.gameSpeed = 100 - value
        if not self.isPaused:
            self.parent.timer.stop()
            self.parent.timer.start(self.parent._gameSpeed, self.parent)
    
        
    def musketeerButtonClick(self):
        
        if self.isPaused == False:
            if self.parent.gameboard.money > Musketeer().price:
                self.parent.isTowerSelected = True
                self.parent.selectedTower = Musketeer()
                self.statusBarMessage('Musketeer tower selected')
            else:
                self.statusBarMessage("You don't have enough money.")
        else:
            self.statusBarMessage("The game is paused. You can't build towers.")
        
        
    def cannonButtonClick(self):
        
        if self.parent.gameover == False:
            if self.isPaused == False:
                if self.parent.gameboard.money > Cannon().price:
                    self.parent.isTowerSelected = True
                    self.parent.selectedTower = Cannon()
                    self.statusBarMessage('Cannon tower selected')
                else:    
                    self.statusBarMessage("You don't have enough money.")
            else:
                self.statusBarMessage("The game is paused. You can't build towers.")
        else: self.statusBarMessage("The game has ended can't build towers.")
        

    def pauseGame(self, pressed):
        
        if self.parent.gameover == False:
        
            if self.isPaused == False:
                self.statusBarMessage('Game paused')
                self.pauseButton.setText('Play')
                self.isPaused = True 
                self.parent.timer.stop()  
                self.clockTimer.stop()
                
            else:
                self.statusBarMessage('')
                self.pauseButton.setText('Pause')
                self.isPaused = False 
                self.parent.timer.start(self.parent._gameSpeed, self.parent)
                self.clockTimer.start(1000, self)
        
        else:
            self.statusBarMessage('The game has ended.')
    
    
    def timerEvent(self, event):
        self.seconds += 1
        self.lcd.display("%.2d:%.2d" % (self.seconds // 60, self.seconds % 60))
        
    
    def statusBarMessage(self, message):
        self.parent.statusBar().showMessage(message)
    def __init__(self, cue, **kwargs):
        super().__init__(**kwargs)

        self.cue = cue
        self.cue_time = CueTime(cue)
        self.cue_time.notify.connect(self._time_updated, Connection.QtQueued)

        self._dbmeter_element = None
        self._accurate_time = False

        scroll_size = (self.parent().verticalScrollBar().width() + 5)
        self.setGeometry(0, 0, self.parent().width() - scroll_size, 102)
        self.setFocusPolicy(Qt.NoFocus)

        self.gridLayoutWidget = QWidget(self)
        self.gridLayoutWidget.setGeometry(self.geometry())
        self.gridLayout = QGridLayout(self.gridLayoutWidget)
        self.gridLayout.setContentsMargins(2, 2, 2, 2)

        self.nameLabel = QLabel(self.gridLayoutWidget)
        self.nameLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.nameLabel.setText(cue.name)
        self.nameLabel.setToolTip(cue.name)
        self.gridLayout.addWidget(self.nameLabel, 0, 0, 1, 3)

        self.playPauseButton = QPushButton(self.gridLayoutWidget)
        self.playPauseButton.setSizePolicy(QSizePolicy.Ignored,
                                           QSizePolicy.Ignored)
        self.playPauseButton.setIcon(QIcon.fromTheme('media-playback-pause'))
        self.playPauseButton.setIconSize(QSize(24, 24))
        self.playPauseButton.setFocusPolicy(Qt.NoFocus)
        self.playPauseButton.clicked.connect(self._pause)
        self.gridLayout.addWidget(self.playPauseButton, 1, 0)

        self.stopButton = QPushButton(self.gridLayoutWidget)
        self.stopButton.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.stopButton.setIcon(QIcon.fromTheme('media-playback-stop'))
        self.stopButton.setIconSize(QSize(24, 24))
        self.stopButton.setFocusPolicy(Qt.NoFocus)
        self.stopButton.clicked.connect(self._stop)
        self.gridLayout.addWidget(self.stopButton, 1, 1)

        self.timeDisplay = QLCDNumber(self.gridLayoutWidget)
        self.timeDisplay.setStyleSheet('background-color: transparent')
        self.timeDisplay.setSegmentStyle(QLCDNumber.Flat)
        self.timeDisplay.setDigitCount(8)
        self.timeDisplay.display(strtime(cue.media.duration))
        self.gridLayout.addWidget(self.timeDisplay, 1, 2)

        self.seekSlider = QClickSlider(self.gridLayoutWidget)
        self.seekSlider.setOrientation(Qt.Horizontal)
        self.seekSlider.setRange(0, cue.media.duration)
        self.seekSlider.setFocusPolicy(Qt.NoFocus)
        self.seekSlider.sliderMoved.connect(self._seek)
        self.seekSlider.sliderJumped.connect(self._seek)
        self.seekSlider.setVisible(False)

        self.dbmeter = QDbMeter(self.gridLayoutWidget)
        self.dbmeter.setVisible(False)

        self.gridLayout.setRowStretch(0, 1)
        self.gridLayout.setRowStretch(1, 2)
        self.gridLayout.setColumnStretch(0, 3)
        self.gridLayout.setColumnStretch(1, 3)
        self.gridLayout.setColumnStretch(2, 5)

        cue.changed('name').connect(self.name_changed)
        cue.media.changed('duration').connect(self.update_duration)
        cue.media.played.connect(self._pause_to_play)
        cue.media.paused.connect(self._play_to_pause)

        self.fade = self.cue.media.element('Fade')
        if self.fade is not None:
            self.fade.enter_fadein.connect(self.enter_fadein)
            self.fade.enter_fadeout.connect(self.enter_fadeout)
            self.fade.exit_fadein.connect(self.exit_fade)
            self.fade.exit_fadeout.connect(self.exit_fade)
Ejemplo n.º 60
0
class timeDigitalWidget(QWidget):

    time = pyqtSignal()
    def __init__(self,winParent, percentaje):
        super(timeDigitalWidget, self).__init__()
        self.winParent=winParent
        self.seconds = 900
        self.pose3d = pose3d
        self.percentaje = percentaje
        self.show = False
        self.MAX_PERCENT = 30
        self.MAX_MARK = 10

        self.hLayout = QHBoxLayout()

        timeLabel = QLabel("Time")
        self.lcd = QLCDNumber(self)
        self.lcd.setMaximumSize(100,50)
        self.hLayout.addWidget(timeLabel,0)
        self.hLayout.addWidget(self.lcd, 1)

        hSpacer = QSpacerItem(300, 30, QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.hLayout.addItem(hSpacer)

        self.setLayout(self.hLayout)

        timer = QTimer(self)
        timer.start(1000)
        timer.timeout.connect(self.printTime)

        # get the palette
        palette = self.lcd.palette()

        # foreground color
        palette.setColor(palette.WindowText, QColor(85, 85, 255))
        # background color
        palette.setColor(palette.Background, QColor(0, 170, 255))
        # "light" border
        palette.setColor(palette.Light, QColor(255, 0, 0))
        # "dark" border
        palette.setColor(palette.Dark, QColor(0, 255, 0))

        # set the palette
        self.lcd.setPalette(palette)

    def showMark(self):
        self.show = True
        mark = self.testPercentaje()
        markLabel = QLabel('Final mark: ' + str(mark))
        self.hLayout.addWidget(markLabel, 0)
        self.setLayout(self.hLayout)

    def printTime(self):

        if self.seconds > 0:
            self.seconds -= 1
        else:
            if not self.show:
                self.showMark()
        self.lcd.display(self.seconds)


    def testPercentaje(self):
        pHouse = self.percentaje.calculatePercentaje()
        markPerc = float(pHouse) * float(self.MAX_MARK) / float(self.MAX_PERCENT)
        if pHouse > self.MAX_PERCENT:
            markPerc = 10
        return markPerc