def __init__(self): if not path.exists(algorithm_directory): os.makedirs(algorithm_directory, exist_ok=True) self.fmodel = QFileSystemModel() self.fmodel.setRootPath(algorithm_directory) self.module_list = QTreeView() self.module_list.setModel(self.fmodel) self.module_list.setRootIndex(self.fmodel.index(algorithm_directory)) self.module_button = QPushButton("Change Directory") self.module_button.clicked.connect(self.change_dir) self.start_date = ToggleButton('Start Date') self.end_date = ToggleButton('End Date', 'Default (Present)') self.test_types = ['Profit', 'Accuracy'] self.test_type = QComboBox() self.test_type.addItems(self.test_types) self.test_output = QTextEdit() self.test_output.setDisabled(True) self.run_btn = QPushButton('Run Test') self.profit = QLCDNumber() self.accuracy = QLCDNumber() super().__init__('Jencks Stock Algorithm Tester')
def __init__(self, parent=None): super(TempConverter, self).__init__(parent) # Create widgets self.labelC = QLabel("Celsius") self.labelF = QLabel("Fahrenheit") self.dialC = QDial() self.dialF = QDial() self.lcdC = QLCDNumber() self.lcdF = QLCDNumber() layoutC = QVBoxLayout() layoutC.addWidget(self.labelC) layoutC.addWidget(self.dialC) layoutC.addWidget(self.lcdC) layoutF = QVBoxLayout() layoutF.addWidget(self.labelF) layoutF.addWidget(self.dialF) layoutF.addWidget(self.lcdF) layoutGeneral = QHBoxLayout() layoutGeneral.addLayout(layoutC) layoutGeneral.addLayout(layoutF) self.setLayout(layoutGeneral)
def initUI(self): grid = QGridLayout() self.setLayout(grid) self.setGeometry(300, 300, 400, 300) self.setWindowTitle('Grid') self.lcd = QLCDNumber() grid.addWidget(self.lcd, 0, 0, 3, 0) grid.setSpacing(10) names = [ 'Cls', 'Bc', '', 'Close', '7', '8', '9', '/', '4', '5', '6', '*', '1', '2', '3', '-', '0', '.', '=', '+' ] positions = [(i, j) for i in range(4, 9) for j in range(4, 8)] for position, name in zip(positions, names): if name == '': continue button = QPushButton(name) grid.addWidget(button, *position) button.clicked.connect(self.aa) self.show()
def __init__(self, bomb_count: int, parent=None): super(TopWidget, self).__init__(parent) self.setFrameStyle(QFrame.Panel | QFrame.Sunken) self.setLineWidth(3) self.setMidLineWidth(3) self.center = parent self.bombCounter = QLCDNumber(len(str(bomb_count)) + 1) p = self.bombCounter.palette() p.setColor(QPalette.Background, Qt.black) p.setColor(p.Light, Qt.darkRed) self.bombCounter.setPalette(p) self.bombCounter.display(bomb_count) self.resetButton = QToolButton() self.resetButton.setIcon(QIcon(self._icon_locations['smile'])) self.resetButton.clicked.connect(self.center.board.reset_board) self.timer = CustomTimer(1000) upper_layout = QHBoxLayout() upper_layout.setMargin(5) upper_layout.addWidget(self.bombCounter) upper_layout.addWidget(self.resetButton) upper_layout.addWidget(self.timer) upper_layout.setAlignment(self.bombCounter, Qt.AlignLeft) upper_layout.setAlignment(self.resetButton, Qt.AlignHCenter) upper_layout.setAlignment(self.timer, Qt.AlignRight) self.setLayout(upper_layout)
def init_ui(self): """初始化游戏界面""" # 1.确定游戏界面的标题,大小和背景颜色 self.setObjectName('MainWindow') self.setWindowTitle('扫雷') self.setWindowIcon(QIcon(':/minesweeper.ico')) self.setFixedSize(50 * self.ms.length + 100, 50 * self.ms.width + 180) self.setStyleSheet('#MainWindow{background-color: #f6edd2}') self.remain_boom = QLCDNumber(2, self) self.remain_boom.move(50, 50) self.remain_boom.setFixedSize(60, 50) self.remain_boom.setStyleSheet( "border: 2px solid blue; color: red; background: black;") self.remain_boom.display( '{:>02d}'.format(self.ms.b_num if self.ms.b_num >= 0 else 0)) self.timer = QBasicTimer() self.second = 0 self.time = QLCDNumber(3, self) self.time.move(50 * self.ms.length - 40, 50) self.time.setFixedSize(90, 50) self.time.setStyleSheet( "border: 2px solid blue; color: red; background: black;") self.time.display('{:>03d}'.format(self.second)) self.btn = QPushButton(self) self.btn.move(25 * self.ms.length + 20, 50) self.btn.setFixedSize(50, 50) self.btn.setIcon(QIcon(':/普通.png')) self.btn.setIconSize(QSize(45, 45)) self.btn.setStyleSheet('QPushButton{border:None}') self.btn.clicked.connect(self.restart) self.over_signal = 0 self.rank = sqlite3.connect('rank.db') self.c = self.rank.cursor()
def initUI(self): grid = QGridLayout() grid.setHorizontalSpacing(2) grid.setVerticalSpacing(2) # Reference # https://stackoverflow.com/questions/16673074/how-can-i-fully-disable-resizing-a-window-including-the-resize-icon-when-the-mou grid.setSizeConstraint(QLayout.SetFixedSize) self.setLayout(grid) # This is register self.ent = Register() # This is display value of register self.lcd = QLCDNumber(self) self.lcd.setDigitCount(self.max_chars + 2) self.lcd.setSmallDecimalPoint(True) self.lcd.display(self.ent.get_text()) self.lcd.setStyleSheet("QLCDNumber {color:darkgreen;}") self.lcd.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) grid.addWidget(self.lcd, 0, 0, 1, 4) grid.setRowMinimumHeight(0, 40) for key in self.keys_info: but = QPushButton(key['label']) method_name = key['method'] method = getattr(self, method_name) but.clicked.connect(method) but.setStyleSheet( "QPushButton {font-size:12pt; padding:5px 30px; color:#666;}") but.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) grid.addWidget(but, key['y'], key['x'], key['h'], key['w'])
def setupUi(self, Dialog): if Dialog.objectName(): Dialog.setObjectName(u"Dialog") Dialog.resize(878, 528) icon = QIcon() icon.addFile("./icon.ico") Dialog.setWindowIcon(icon) self.verticalLayout = QVBoxLayout(Dialog) self.verticalLayout.setObjectName(u"verticalLayout") self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setObjectName(u"horizontalLayout") self.questionLable = QLabel(Dialog) self.questionLable.setObjectName(u"questionLable") font = QFont() font.setFamily(u"\u5fae\u8f6f\u96c5\u9ed1") font.setPointSize(12) self.questionLable.setFont(font) self.questionLable.setWordWrap(True) self.questionLable.setMargin(0) self.questionLable.setIndent(0) self.horizontalLayout.addWidget(self.questionLable) self.lcd = QLCDNumber(Dialog) self.lcd.setObjectName(u"lcd") sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.lcd.sizePolicy().hasHeightForWidth()) self.lcd.setSizePolicy(sizePolicy) self.lcd.setMinimumSize(QSize(120, 60)) self.lcd.setSmallDecimalPoint(True) self.lcd.setDigitCount(4) self.lcd.setSegmentStyle(QLCDNumber.Flat) self.lcd.setProperty("value", 120.000000000000000) self.horizontalLayout.addWidget(self.lcd) self.verticalLayout.addLayout(self.horizontalLayout) self.line = QFrame(Dialog) self.line.setObjectName(u"line") self.line.setFrameShape(QFrame.HLine) self.line.setFrameShadow(QFrame.Sunken) self.verticalLayout.addWidget(self.line) self.answerLable = QLabel(Dialog) self.answerLable.setObjectName(u"answerLable") font1 = QFont() font1.setFamily(u"Yu Gothic UI") font1.setPointSize(14) self.answerLable.setFont(font1) self.answerLable.setWordWrap(True) self.verticalLayout.addWidget(self.answerLable) self.retranslateUi(Dialog) QMetaObject.connectSlotsByName(Dialog)
def initUI(self): mainLayout = QVBoxLayout() self.setLayout(mainLayout) self.timeViewer = QLCDNumber() self.timeViewer.setFixedHeight(45) self.timeViewer.setDigitCount(8) # 00:00:00 mainLayout.addWidget(self.timeViewer) self.buttonStart = QPushButton(self.tr("start countup")) self.buttonStart.setMinimumHeight(35) mainLayout.addWidget(self.buttonStart) self.buttonPause = QPushButton(self.tr("pause countup")) self.buttonPause.setMinimumHeight(35) mainLayout.addWidget(self.buttonPause) self.buttonReset = QPushButton(self.tr("reset countup")) self.buttonReset.setMinimumHeight(35) mainLayout.addWidget(self.buttonReset) mainLayout.addSpacing(10) countdown_edit_hlayout = QHBoxLayout() self.countdown_edit_hour = QComboBox() self.countdown_edit_hour.setMinimumHeight(35) self.countdown_edit_hour.setFont(self.countdown_edit_font) self.countdown_edit_hour.addItems([f'{i}' for i in range(0, 24)]) self.countdown_edit_minute = QComboBox() self.countdown_edit_minute.setMinimumHeight(35) self.countdown_edit_minute.setFont(self.countdown_edit_font) self.countdown_edit_minute.addItems([f'{i}' for i in range(0, 60)]) self.countdown_edit_second = QComboBox() self.countdown_edit_second.setMinimumHeight(35) self.countdown_edit_second.setFont(self.countdown_edit_font) self.countdown_edit_second.addItems([f'{i}' for i in range(0, 60)]) countdown_edit_hlayout.addWidget(self.countdown_edit_hour) countdown_edit_hlayout.addWidget(self.countdown_edit_minute) countdown_edit_hlayout.addWidget(self.countdown_edit_second) mainLayout.addLayout(countdown_edit_hlayout) self.buttonCountDown = QPushButton(self.tr("start countdown")) self.buttonCountDown.setMinimumHeight(35) self.buttonCountDownPause = QPushButton(self.tr("pause countdown")) self.buttonCountDownPause.setMinimumHeight(35) self.buttonCountDownReset = QPushButton(self.tr("reset countdown")) self.buttonCountDownReset.setMinimumHeight(35) mainLayout.addWidget(self.buttonCountDown) mainLayout.addWidget(self.buttonCountDownPause) mainLayout.addWidget(self.buttonCountDownReset)
def initUI(self): lcd = QLCDNumber(self) dial = QDial(self) self.setGeometry(300,300,350,250) self.setWindowTitle('signal') lcd.setGeometry(100,50,150,60) dial.setGeometry(120,120,100,100) dial.valueChanged.connect(lcd.display) self.show()
def create_lcd(digit_count, lcd_color): lcd = QLCDNumber() lcd.setDigitCount(digit_count) lcd.setSegmentStyle(QLCDNumber.Flat) lcd.setStyleSheet( f"""QLCDNumber {{ background-color: black; color: {lcd_color}; }}""" ) return lcd
def __init__(self, parent=None): super().__init__(parent=parent) self.layout = QVBoxLayout() self.setLayout(self.layout) self.score = QLCDNumber() self.score.setMinimumHeight(80) self.score.setStyleSheet(self.normal_style) self.layout.addWidget(self.score) self.player = QLineEdit() self.player.setStyleSheet(self.normal_style) self.player.setFont(self.font) self.player.setAlignment(Qt.AlignCenter) self.layout.addWidget(self.player)
class Demo(QWidget): def __init__(self): super().__init__() self.resize(300, 300) #输入个人信息 label1 = QLabel("请输入姓名") name = QLineEdit() #文本标签 label2 = QLabel("请选择测试项目") label2.resize(20, 20) #下拉选择框 cb = QComboBox(self) cb.move(100, 50) cb.addItem('仰卧起坐') cb.addItem('俯卧撑') cb.addItem('引体向上') #开始 结束测试按钮 button1 = QPushButton("开始测试") button1.clicked.connect(self.start) #倒计时功能 self.a = 60 self.clock = QLCDNumber() self.clock.display(self.a) #布局 layout = QVBoxLayout(self) layout.addWidget(label1) layout.addWidget(name) layout.addWidget(label2) layout.addWidget(cb) layout.addWidget(button1) layout.addWidget(self.clock) self.setLayout(layout) def start(self): self.timer = QTimer(self) self.timer.timeout.connect(self.updateTime) self.timer.start(1000) def updateTime(self): if self.a >= 0: self.a -= 1 self.clock.display(self.a)
def __init__(self, parent=None): # 初始化,无父类 super().__init__(parent) self.lcd_number = QLCDNumber() # 创建一个lcd数字显示器对象 self.slider = QSlider(Qt.Horizontal) # 创建滑动条,水平显示 self.layout = QVBoxLayout() # 两元素使用垂直布局(上下排列) self.layout.addWidget(self.lcd_number) # 将lcd_num对象加入 self.layout.addWidget(self.slider) # 将slider对象加入 self.setLayout(self.layout) self.setFixedSize(120, 100) # 设置整个控件大小 self.lcd_number.setDigitCount(2) # 设置lcd显示器最多显示两位数字 self.slider.setRange(0, 99) # 设置可调节的范围 self.slider.valueChanged.connect( self.lcd_number.display) # 滑动条的值修改,连接到lcd的显示值
def initUI(self): lcd = QLCDNumber(self) sld = QSlider(QtCore.Qt.Horizontal, self) vbox = QVBoxLayout() vbox.addWidget(lcd) vbox.addWidget(sld) self.setLayout(vbox) sld.valueChanged.connect(lcd.display)
def __init__(self): QWidget.__init__(self) self.amtLabel = QLabel('Loan Amount') self.roiLabel = QLabel('Rate of Interest') self.yrsLabel = QLabel('No. of Years') self.emiLabel = QLabel('EMI per month') self.emiValue = QLCDNumber() self.emiValue.setSegmentStyle(QLCDNumber.Flat) self.emiValue.setFixedSize(QSize(130, 30)) self.emiValue.setDigitCount(8) self.amtText = QLineEdit('10000') self.roiSpin = QSpinBox() self.roiSpin.setMinimum(1) self.roiSpin.setMaximum(15) self.yrsSpin = QSpinBox() self.yrsSpin.setMinimum(1) self.yrsSpin.setMaximum(20) self.roiDial = QDial() self.roiDial.setNotchesVisible(True) self.roiDial.setMaximum(15) self.roiDial.setMinimum(1) self.roiDial.setValue(1) self.yrsSlide = QSlider(Qt.Horizontal) self.yrsSlide.setMaximum(20) self.yrsSlide.setMinimum(1) self.calculateButton = QPushButton('Calculate EMI') self.myGridLayout = QGridLayout() self.myGridLayout.addWidget(self.amtLabel, 0, 0) self.myGridLayout.addWidget(self.roiLabel, 1, 0) self.myGridLayout.addWidget(self.yrsLabel, 2, 0) self.myGridLayout.addWidget(self.amtText, 0, 1) self.myGridLayout.addWidget(self.roiSpin, 1, 1) self.myGridLayout.addWidget(self.yrsSpin, 2, 1) self.myGridLayout.addWidget(self.roiDial, 1, 2) self.myGridLayout.addWidget(self.yrsSlide, 2, 2) self.myGridLayout.addWidget(self.calculateButton, 3, 1) self.setLayout(self.myGridLayout) self.setWindowTitle("A simple EMI calculator") self.roiDial.valueChanged.connect(self.roiSpin.setValue) self.connect(self.roiSpin, SIGNAL("valueChanged(int)"), self.roiDial.setValue) self.yrsSlide.valueChanged.connect(self.yrsSpin.setValue) self.connect(self.yrsSpin, SIGNAL("valueChanged(int)"),self.yrsSlide, SLOT("setValue(int)")) self.connect(self.calculateButton, SIGNAL("clicked()"),self.showEMI)
def __init__(self, parent=None): super().__init__(parent) self.setWindowTitle(self.tr("Settings menu")) icon = QIcon('img/settings.png') self.setWindowIcon(icon) main_layout = QVBoxLayout() upper_layout = QHBoxLayout() bottom_layout = QHBoxLayout() #Left UP Window left_up_layout = QVBoxLayout() lcd_layout = QHBoxLayout() label = QLabel(self.tr('Counter')) lcd = QLCDNumber() lcd.setDigitCount(3) lcd_layout.addWidget(label) lcd_layout.addWidget(lcd) self.__add_pushbutton = QPushButton(self.tr('Add')) self.__quit_pushbutton = QPushButton(self.tr('Quit')) left_up_layout.addLayout(lcd_layout) left_up_layout.addWidget(self.__add_pushbutton) left_up_layout.addWidget(self.__quit_pushbutton) #Righte Up Window right_up_layout = QVBoxLayout() # Right Bottom Window left_bottom_layut = QVBoxLayout() # Right Bottom window reght_bottom_layout = QFormLayout() self.setLayout(main_layout) main_layout.addLayout(upper_layout) main_layout.addLayout(bottom_layout) upper_layout.addLayout(left_up_layout)
def __init__(self, line1: str, line2: str, valor: float): super().__init__() vBox = QVBoxLayout(self) lb1 = QLabel(line1) lb1.setAlignment(Qt.AlignCenter) self.out = QLCDNumber() self.out.setDigitCount(7) self.out.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.out.setMinimumSize(90, 60) self.out.setSegmentStyle(QLCDNumber.SegmentStyle.Flat) self.out.display(valor) self.out.setStyleSheet( "QLCDNumber { background-color: white; color: red; }") vBox.addWidget(lb1) if line2 != '': lb2 = QLabel(line2) lb2.setAlignment(Qt.AlignCenter) vBox.addWidget(lb2) vBox.addWidget(self.out) vBox.setAlignment(Qt.AlignTop | Qt.AlignLeft)
def __init__(self, lien): QWidget.__init__(self) self.setFixedWidth(340) self.__restriction = QIntValidator() self.precision = 0 self.masse = 0 self.rho = 1000 self.__label_title = QLabel('''Tirant d'Eau''') self.__label_title.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter) A = QFont("DIN Condensed", 45) self.__label_title.setFixedHeight(100) self.__label_title.setFont(A) self.layout = QGridLayout() self.button_compute = QPushButton('Compute') self.button_compute.sizeHint() self.__label_precision = QLabel('Tolérance') self.__label_precision.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter) self.text_precision = QLineEdit() self.__label_poids = QLabel('Masse (kg)') self.__label_poids.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter) self.text_poids = QLineEdit() self.text_poids.setValidator(self.__restriction) self.text_precision.textChanged.connect(self.l1) self.text_poids.textChanged.connect(self.l2) self.eau_de_mer = QRadioButton('''Eau De Mer''') self.eau_de_mer.setChecked(True) self.eau_douce = QRadioButton('''Eau Douce''') A = QFont("DIN Condensed", 20) self.__label_LCD = QLabel('''Tirant d'eau (m)''') self.__label_LCD.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter) self.__label_LCD.setFont(A) self.LCD = QLCDNumber() '''Association Layout''' self.layout.addWidget(self.__label_title, 0, 0, 1, 0) self.layout.addWidget(self.__label_precision, 2, 0, 1, 0) self.layout.addWidget(self.text_precision, 3, 0, 1, 0) self.layout.addWidget(self.__label_poids, 4, 0, 1, 0) self.layout.addWidget(self.text_poids, 5, 0, 1, 0) self.layout.addWidget(self.eau_de_mer, 8, 0) self.layout.addWidget(self.eau_douce, 8, 1) self.layout.addWidget(self.button_compute, 9, 0, 1, 0) self.layout.addWidget(self.__label_LCD, 11, 0, 1, 0) self.layout.addWidget(self.LCD, 12, 0, 1, 0) self.setLayout(self.layout)
def initUI(self): lcd = QLCDNumber(self) sld = QSlider(Qt.Horizontal, self) vb = QVBoxLayout() vb.addWidget(lcd) vb.addWidget(sld) self.setLayout(vb) sld.valueChanged.connect(lcd.display) self.resize(250,150)
class TLoginWindow(QWidget, QtCore.QObject): def __init__(self): super().__init__() self.resize(300,300) #输入个人信息 label_name=QLabel("请输入姓名") self.edit_name=QLineEdit() #文本标签 label_pos=QLabel("请选择测试项目") label_pos.resize(20,20) #下拉选择框 self.cbox_pos=QComboBox(self) self.cbox_pos.move(100,50) self.cbox_pos.addItem('仰卧起坐') self.cbox_pos.addItem('俯卧撑') self.cbox_pos.addItem('引体向上') #开始测试按钮 self.start_button = QPushButton("开始测试") # button1.clicked.connect(self.start) #倒计时功能 init = 60 self.lcd_cntDown=QLCDNumber() self.lcd_cntDown.display(init) #布局 layout =QVBoxLayout(self) layout.addWidget(label_name) layout.addWidget(self.edit_name) layout.addWidget(label_pos) layout.addWidget(self.cbox_pos) layout.addWidget(self.start_button) layout.addWidget(self.lcd_cntDown) self.setLayout(layout)
class Example(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): grid = QGridLayout() self.setLayout(grid) self.setGeometry(300, 300, 400, 300) self.setWindowTitle('Grid') self.lcd = QLCDNumber() grid.addWidget(self.lcd, 0, 0, 3, 0) grid.setSpacing(10) names = [ 'Cls', 'Bc', '', 'Close', '7', '8', '9', '/', '4', '5', '6', '*', '1', '2', '3', '-', '0', '.', '=', '+' ] positions = [(i, j) for i in range(4, 9) for j in range(4, 8)] for position, name in zip(positions, names): if name == '': continue button = QPushButton(name) grid.addWidget(button, *position) button.clicked.connect(self.aa) self.show() def aa(self): sender = self.sender().text() ls = ['/', '*', '-', '=', '+'] if sender in ls: self.lcd.display('A') else: self.lcd.display(sender)
def initUI(self): lcd = QLCDNumber(self) sld = QSlider(QtCore.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 & slot') self.show()
def __init__(self, m1m3): super().__init__() self.m1m3 = m1m3 self.lastEnabled = None def _addButton(text, onClick, default=False): button = QPushButton(text) button.clicked.connect(onClick) button.setEnabled(False) button.setAutoDefault(default) return button self.startButton = _addButton(self.TEXT_START, self.start, True) self.enableButton = _addButton(self.TEXT_ENABLE, self.enable, True) self.raiseButton = _addButton(self.TEXT_RAISE, self.raiseControl, True) self.engineeringButton = _addButton(self.TEXT_ENTER_ENGINEERING, self.engineering) self.exitButton = _addButton(self.TEXT_STANDBY, self.exit) self.supportedNumber = QLCDNumber(6) self.supportedNumber.setAutoFillBackground(True) self.minPressure = QLCDNumber(6) self.minPressure.setAutoFillBackground(True) self.maxPressure = QLCDNumber(6) self.maxPressure.setAutoFillBackground(True) dataLayout = QFormLayout() dataLayout.addRow("Supported", self.supportedNumber) dataLayout.addRow("Min pressure", self.minPressure) dataLayout.addRow("Max pressure", self.maxPressure) commandLayout = QVBoxLayout() commandLayout.addWidget(self.startButton) commandLayout.addWidget(self.enableButton) commandLayout.addWidget(self.raiseButton) commandLayout.addWidget(self.engineeringButton) commandLayout.addWidget(self.exitButton) commandLayout.addLayout(dataLayout) commandLayout.addStretch() self.supportPercentage = QProgressBar() self.supportPercentage.setOrientation(Qt.Vertical) self.supportPercentage.setRange(0, 100) self.supportPercentage.setTextVisible(True) self.supportPercentage.setFormat("%p%") layout = QHBoxLayout() layout.addLayout(commandLayout) layout.addWidget(self.supportPercentage) self.setLayout(layout) # connect SAL signals self.m1m3.detailedState.connect(self.detailedState) self.m1m3.forceActuatorState.connect(self.forceActuatorState) self.m1m3.hardpointMonitorData.connect(self.hardpointMonitorData)
def __init__(self, minval, maxval, startval, numdigits, background, color): super().__init__() self.lcd = QLCDNumber() self.lcd.setDigitCount(numdigits) self.lcd.setSegmentStyle(QLCDNumber.Flat) self.lcd.setStyleSheet( f"""QLCDNumber {{ background-color: {background}; color: {color}; }}""" ) self.slider = QSlider(Qt.Vertical) self.slider.setMinimum(minval) self.slider.setMaximum(maxval) self.slider.valueChanged.connect(self.display_slider_value_in_lcd) self.slider.setValue(startval) self.display_slider_value_in_lcd() grid = QGridLayout() grid.addWidget(self.lcd, 0, 0, 4, 4) grid.addWidget(self.slider, 0, 4, 4, 1) self.setLayout(grid) self.show()
class TopWidget(QFrame): # TODO: Use Qt's embedded resources for images and icons _icon_locations = { 'smile': './assets/smile.jpg', 'open': './assets/open.jpg', 'dead': './assets/dead.jpg' } def __init__(self, bomb_count: int, parent=None): super(TopWidget, self).__init__(parent) self.setFrameStyle(QFrame.Panel | QFrame.Sunken) self.setLineWidth(3) self.setMidLineWidth(3) self.center = parent self.bombCounter = QLCDNumber(len(str(bomb_count)) + 1) p = self.bombCounter.palette() p.setColor(QPalette.Background, Qt.black) p.setColor(p.Light, Qt.darkRed) self.bombCounter.setPalette(p) self.bombCounter.display(bomb_count) self.resetButton = QToolButton() self.resetButton.setIcon(QIcon(self._icon_locations['smile'])) self.resetButton.clicked.connect(self.center.board.reset_board) self.timer = CustomTimer(1000) upper_layout = QHBoxLayout() upper_layout.setMargin(5) upper_layout.addWidget(self.bombCounter) upper_layout.addWidget(self.resetButton) upper_layout.addWidget(self.timer) upper_layout.setAlignment(self.bombCounter, Qt.AlignLeft) upper_layout.setAlignment(self.resetButton, Qt.AlignHCenter) upper_layout.setAlignment(self.timer, Qt.AlignRight) self.setLayout(upper_layout) def update_counter(self, counter: int): self.bombCounter.display(counter) def kill_smile(self): self.resetButton.setIcon(QIcon(self._icon_locations['dead'])) def revive_smile(self): self.resetButton.setIcon((QIcon(self._icon_locations['smile'])))
def initUI(self): # on créée un bouton et un slider number = QLCDNumber(self) slider = QSlider(Qt.Horizontal, self) # on les met tous deux dans un QVBoxLayout pour qu'ils soient affichés # l'un au dessus de l'autre vbox = QVBoxLayout() vbox.addWidget(number) vbox.addWidget(slider) self.setLayout(vbox) # Here we connect a valueChanged signal of the slider to the display # slot of the lcd number. slider.valueChanged.connect(number.display) self.setGeometry(300, 300, 250, 150) self.setWindowTitle("Signal and s**t") self.show()
def initUI(self): lcd = QLCDNumber(self) volume = power_bar.PowerBar([ "#053061", "#2166ac", "#4393c3", "#92c5de", "#d1e5f0", "#f7f7f7", "#fddbc7", "#f4a582", "#d6604d", "#b2182b", "#67001f" ]) volume.setBarSolidPercent(0.8) volume.setBarPadding(5) volume.show() vbox = QVBoxLayout() vbox.addWidget(volume) vbox.addWidget(lcd) self.setLayout(vbox) self.setGeometry(300, 300, 250, 550) self.setWindowTitle('EXample fin') self.show()
def initUI(self): lcd = QLCDNumber(self) sld = QSlider(Qt.Horizontal, self) is_binary = QRadioButton("is binary?", self) vbox = QVBoxLayout() vbox.addWidget(lcd) vbox.addWidget(sld) vbox.addWidget(is_binary) self.setLayout(vbox) # sld.setRange(0, 10) sld.setMaximum(1000) sld.setMinimum(-100) sld.valueChanged.connect(lcd.display) is_binary.toggled.connect(self.switch_binary) self.setGeometry(300, 300, 250, 150) self.setWindowTitle('EXample 6') self.show()
def init_ui(self): self.layout = QGridLayout() # Runway information self.runways = QGroupBox("Runways") self.runwayLayout = QGridLayout() for i, runway in enumerate(self.airport.runways): # Seems like info is missing in pydcs, even if the attribute is there lr = "" if runway.leftright == 1: lr = "L" elif runway.leftright == 2: lr = "R" self.runwayLayout.addWidget( QLabel("Runway " + str(runway.heading) + lr), i, 0) # Seems like info is missing in pydcs, even if the attribute is there if runway.ils: self.runwayLayout.addWidget(QLabel("ILS "), i, 1) self.runwayLayout.addWidget(QLCDNumber(6, runway.ils), i, 1) else: self.runwayLayout.addWidget(QLabel("NO ILS"), i, 1) self.runways.setLayout(self.runwayLayout) self.layout.addWidget(self.runways, 0, 0) self.layout.addWidget(QLabel("<b>Parking Slots :</b>"), 1, 0) self.layout.addWidget(QLabel(str(len(self.airport.parking_slots))), 1, 1) stretch = QVBoxLayout() stretch.addStretch() self.layout.addLayout(stretch, 2, 0) self.setLayout(self.layout)
def setupUi(self, parent): """Setup the interfaces for the clock.""" if not self.objectName(): self.setObjectName(u"Clock") sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(parent.sizePolicy().hasHeightForWidth()) parent.setSizePolicy(sizePolicy) parent.setAutoFillBackground(True) parent.setWindowFlag(Qt.Widget, True) if os.uname().sysname == "Linux" or self.frameless: parent.setWindowFlag(Qt.FramelessWindowHint, True) self.tabWidget = QTabWidget(parent) self.tabWidget.setObjectName(u"tabWidget") self.tabWidget.setGeometry(QRect(0, 0, 800, 460)) # This works for Mac, but seems to not work with Linux/Arm/RPi # tabbar = self.tabWidget.tabBar() # tabbar.setMinimumSize(50, 24) # tabfont = QFont() # tabfont.setBold(True) # tabfont.setItalic(True) # tabfont.setPointSize(32) # tabbar.setFont(tabfont) # Setup the TABS self.clock = QWidget() self.clock.setObjectName(u"clock") self.tabWidget.addTab(self.clock, "") self.tabWidget.setTabText(self.tabWidget.indexOf(self.clock), "Clock") self.weather = QWeather(parent=None, debug=self.debug) self.tabWidget.addTab(self.weather, "") self.tabWidget.setTabText(self.tabWidget.indexOf(self.weather), "Weather") self.settings = QWidget() self.settings.setObjectName(u"settings") self.tabWidget.addTab(self.settings, "") self.tabWidget.setTabText(self.tabWidget.indexOf(self.settings), "Settings") self.tabWidget.setCurrentIndex(0) ################################################################################################# # Setup Clock Page ################################################################################################# self.analog = AnalogClock(self.clock) # DIGITAL clock in "clock" tab self.Digital = QLabel(self.clock) self.Digital.setObjectName(u"Digital") self.Digital.setGeometry(QRect(0, 5, 765, 71)) self.Digital.setAutoFillBackground(False) self.Digital.setStyleSheet(u"") self.Digital.setText(u"Current Time - Date + time") # Weather Icon self.weathericon = QWeatherIcon((480, 5), self.weather, parent=self.clock) self.weather.weather_updated.connect(self.weathericon.update) # Weather info on the Clock page. self.minipanel = QTempMiniPanel((475, 105), self.weather, parent=self.clock) self.weather.temp_updated.connect(self.minipanel.update) self.hilo = QHiLoTide((580, 5), parent=self.clock, debug=self.debug) # Moon phase self.moon = QMoon(pos=(450, 210), parent=self.clock, size=216, web=self.web) # Push buttons in "clock tab. push_button_width = 111 push_button_height = 40 push_button_x = 670 push_button_y = 220 self.ledball_off = QPushButton(self.clock) self.ledball_off.setObjectName(u"ledball_off") self.ledball_off.setText(u"LED off") self.ledball_off.setGeometry(QRect(push_button_x, push_button_y, push_button_width, push_button_height)) self.ledball_on = QPushButton(self.clock) self.ledball_on.setObjectName(u"ledball_on") self.ledball_on.setText(u"LED on ") self.ledball_on.setGeometry(QRect(push_button_x, push_button_y+push_button_height, push_button_width, push_button_height)) self.ledball_on2 = QPushButton(self.clock) self.ledball_on2.setObjectName(u"ledball_on2") self.ledball_on2.setText(u"LED on 2") self.ledball_on2.setGeometry(QRect(push_button_x, push_button_y+push_button_height*2, push_button_width, push_button_height)) self.sleep = QPushButton(self.clock) self.sleep.setObjectName(u"sleep") self.sleep.setText(u"Sleep") self.sleep.setGeometry(QRect(push_button_x, push_button_y+push_button_height*3+10, push_button_width, push_button_height)) ################################################################################################# # Setup Weather Page ################################################################################################# ################################################################################################# # Setup Setting Page ################################################################################################# self.timeEdit = QTimeEdit(self.settings) self.timeEdit.setObjectName(u"timeEdit") self.timeEdit.setDisplayFormat(u"h:mm AP") self.timeEdit.setGeometry(QRect(200, 30, 191, 41)) font8 = QFont() font8.setFamily(u"Gill Sans") font8.setPointSize(16) font8.setBold(False) font8.setItalic(False) font8.setWeight(50) self.timeEdit.setFont(font8) self.timeEdit.setAutoFillBackground(True) self.timeEdit.setTime(self.bedtime) self.bedtime_label = QLabel(self.settings) self.bedtime_label.setObjectName(u"bedtime_label") self.bedtime_label.setText(u"Set Bedtime:") self.bedtime_label.setGeometry(QRect(200, 0, 151, 31)) self.bedtime_label.setFont(font8) self.bedtime_label.setAutoFillBackground(True) self.Brightness_Value = QLCDNumber(self.settings) self.Brightness_Value.setObjectName(u"Brightness_Value") self.Brightness_Value.setGeometry(QRect(20, 120, 61, 31)) self.Brightness_Value.setStyleSheet(u"color: \"White\";\n" "margin:0px;\n" "border:0px;background:\"transparent\";") self.Brightness_Value.setDigitCount(3) self.Brightness_Value.setProperty("value", 180.000000000000000) self.Brightness = QSlider(self.settings) self.Brightness.setObjectName(u"Brightness") self.Brightness.setGeometry(QRect(30, 160, 51, 261)) self.Brightness.setAutoFillBackground(False) self.Brightness.setMaximum(255) self.Brightness.setValue(self.LCD_brightness) self.Brightness.setOrientation(Qt.Vertical) self.Brightness_label = QLabel(self.settings) self.Brightness_label.setObjectName(u"Brightness_label") self.Brightness_label.setText(u"Brightness") self.Brightness_label.setGeometry(QRect(20, 70, 101, 41)) font10 = QFont() font10.setFamily(u"Arial Black") font10.setPointSize(12) font10.setBold(True) font10.setWeight(75) self.Brightness_label.setFont(font10) self.temp_test = QLabel(self.settings) self.temp_test.setObjectName(u"temp_test") self.temp_test.setText(u"T20.5 C") self.temp_test.setFont(font8) self.temp_test.setGeometry(QRect(630, 60, 141, 51)) # self.temp_test.setFont(font_bold_20) self.temp_test_slide = QSlider(self.settings) self.temp_test_slide.setObjectName(u"temp_test_slide") self.temp_test_slide.setGeometry(QRect(660, 150, 51, 271)) self.temp_test_slide.setAutoFillBackground(False) self.temp_test_slide.setMinimum(-250) self.temp_test_slide.setMaximum(450) self.temp_test_slide.setSingleStep(5) self.temp_test_slide.setPageStep(25) self.temp_test_slide.setValue(38) self.temp_test_slide.setOrientation(Qt.Vertical) self.temp_check_outside = QCheckBox(self.settings) self.temp_check_outside.setObjectName(u"temp_check_outside") self.temp_check_outside.setText(u"Outside") self.temp_check_outside.setGeometry(QRect(640, 110, 86, 20)) self.grace_period = QSpinBox(self.settings) self.grace_period.setObjectName(u"grace_period") self.grace_period.setGeometry(QRect(411, 31, 111, 41)) self.grace_period.setFont(font8) self.grace_period.setMinimum(1) self.grace_period.setMaximum(60) self.grace_period.setValue(self.bedtime_grace_period) self.grace_period.setDisplayIntegerBase(10) self.grace_period_label = QLabel(self.settings) self.grace_period_label.setObjectName(u"grace_period_label") self.grace_period_label.setText(u"Grace period:") self.grace_period_label.setGeometry(QRect(410, 10, 111, 16)) self.grace_period_label.setFont(font8) ################################################################################################# # SET ALL LABEL TEXTS ################################################################################################# # if QT_CONFIG(tooltip) self.sleep.setToolTip(u"Put display to sleep") self.ledball_on2.setToolTip(u"Turn on the LED Ball, mode 2") self.ledball_on.setToolTip(u"Turn on the LED Ball.") self.ledball_off.setToolTip(u"Turn off the LED Ball.") # endif // QT_CONFIG(tooltip) ################################################################################################# # Make the Connections. ################################################################################################# self.temp_test_slide.valueChanged.connect(self.test_temp_update) self.temp_check_outside.clicked.connect(self.test_temp_update) self.ledball_off.clicked.connect(self.set_ledball_off) self.ledball_on.clicked.connect(self.set_ledball_on) self.ledball_on2.clicked.connect(self.set_ledball_on2) self.sleep.clicked.connect(self.set_sleep) self.timeEdit.timeChanged.connect(self.set_bedtime) self.grace_period.valueChanged.connect(self.set_grace_period) self.Brightness.valueChanged.connect(self.set_screen_brightness) self.Brightness.valueChanged.connect(self.Brightness_Value.display)