Exemplo n.º 1
0
class MainWindow(Ui_MainWindow, QMainWindow):
    """
    主界面二次设计
    """
    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()  # 窗体全屏
Exemplo n.º 2
0
class WheelBox(QWidget):
    valueChanged = pyqtSignal('double', name="valueChanged")

    def __init__(self, title, min, max, stepSize, parent):
        super().__init__(parent)

        self.__d_number = QLCDNumber(self)
        self.__d_number.setSegmentStyle(QLCDNumber.Filled)
        self.__d_number.setAutoFillBackground(True)
        self.__d_number.setFixedHeight(self.__d_number.sizeHint().height() * 2)
        self.__d_number.setFocusPolicy(Qt.WheelFocus)

        pal = QPalette(Qt.black)
        pal.setColor(QPalette.WindowText, Qt.green)
        self.__d_number.setPalette(pal)

        self.__d_wheel = Wheel(self)
        self.__d_wheel.setOrientation(Qt.Vertical)
        self.__d_wheel.setInverted(True)
        self.__d_wheel.setRange(min, max)
        self.__d_wheel.setSingleStep(stepSize)
        self.__d_wheel.setPageStepCount(5)
        self.__d_wheel.setFixedHeight(self.__d_number.height())

        self.__d_number.setFocusProxy(self.__d_wheel)

        font = QFont("Helvetica", 10)
        font.setBold(True)

        self.__d_label = QLabel(title, self)
        self.__d_label.setFont(font)

        hLayout = QHBoxLayout()
        hLayout.setContentsMargins(0, 0, 0, 0)
        hLayout.setSpacing(2)
        hLayout.addWidget(self.__d_number, 10)
        hLayout.addWidget(self.__d_wheel)

        vLayout = QVBoxLayout(self)
        vLayout.addLayout(hLayout, 10)
        vLayout.addWidget(self.__d_label, 0, Qt.AlignTop | Qt.AlignHCenter)

        self.__d_wheel.valueChanged.connect(self.display)

        self.__d_wheel.valueChanged.connect(self.valueChanged)

    def display(self, value):
        self.__d_number.display(value)

    def theme(self):
        return self.__d_wheel.palette().color(QPalette.Window)

    def setTheme(self, color):
        self.__d_wheel.setPalette(QPalette(color))

    def setValue(self, value):
        self.__d_wheel.setValue(value)
        self.__d_number.display(value)

    def value(self):
        return self.__d_wheel.value()

    theme = pyqtProperty(QColor, theme, setTheme)
class Example(QWidget):

    def __init__(self):
        super().__init__()

        self.initUI()

    def initUI(self):
        self.cnt = 0
        self.txt = 'aa'
        self.labList = []
        self.labTop=130
        datetime = QDateTime.currentDateTime()
        self.lcd = QLCDNumber(self)
        self.sld = QSlider(Qt.Horizontal, self)
        self.sld.setRange(1, 10)
        self.sld.setSingleStep(1)
        self.sld.setTickPosition(QSlider.TicksBelow)

        self.rbtn1 = QRadioButton('Lotto 6 aus 49', self)

        self.rbtn2 = QRadioButton(self)
        self.rbtn2.setText('Euro Jackpot')
        self.rbtn2.setChecked(True)

        self.btn1 = QPushButton('RUN', self)

        self.lbl1 = QLabel("How many?", self)
        self.lbl1.move(10, 10)
        self.lcd.move(10, self.lbl1.height())
        self.sld.move(10, self.lbl1.height() + self.lcd.height())
        self.lbl2 = QLabel('|', self)
        self.lbl3 = QLabel('|', self)
        self.lbl2.move(self.lcd.width(), self.lbl1.height())
        self.lbl3.move(self.sld.width(), self.lbl1.height() + self.lcd.height())
        self.lbl4 = QLabel("Which Lottery?",self)
        self.lbl4.move(115,10)
        self.rbtn1.move(115, self.lbl4.height())
        self.rbtn2.move(115, self.lbl4.height() + self.rbtn1.height())
        self.btn1.move(10, self.lbl1.height() + self.lcd.height() + self.sld.height())
        self.rbtn1.toggle()
        self.rbtn2.toggle()

        self.sld.valueChanged.connect(self.lcd.display)
        self.btn1.clicked.connect(self.buttonClicked)
        self.setGeometry(2000, 300, 300, 300)
        self.setWindowIcon(QIcon('logo\web.png'))
        self.setWindowTitle('Let win!!!')
        self.center()
        self.show()


    def buttonClicked(self):
        self.cnt = int(self.sld.value())
        self.lab = QLabel(str(self.cnt)+"are picked",self)
        self.lab.move(10, self.labTop)
        self.lab.show()


        if self.rbtn1.isChecked():
            self.txt = self.rbtn1.text()
            self.lab1 = QLabel(self.txt+ "ㄱㄱ", self)
            self.lab1.move(10, self.labTop+20)
            self.lab1.show()
            for i in range(0,self.cnt):
                lotto = random.sample(range(1, 49), 6)
                lotto.sort()
                bonus_number = random.sample(range(0, 9), 1)
                bonus_number.sort()
                self.labList.append(QLabel(str(lotto) + '    Losnummer: '+ str(bonus_number), self))
                self.labList[i].move(10, self.labTop+50 + (i*20))
                self.labList[i].show()
        else:
            self.txt = self.rbtn2.text()
            self.lab1 = QLabel(self.txt+ "ㄱㄱ", self)
            self.lab1.move(10, self.labTop+20)
            self.lab1.show()
            for i in range(0,self.cnt):
                Euro_jackpot = random.sample(range(1, 50), 5)
                Euro_jackpot.sort()
                lucky_number = random.sample(range(1, 10), 2)
                lucky_number.sort()
                self.labList.append(QLabel(str(Euro_jackpot) + '    Lucky number: ' + str(lucky_number), self))
                self.labList[i].move(10, self.labTop+50 + (i*20))
                self.labList[i].show()





    def center(self):
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())