def __init__(self): super().__init__() self.setBackgroundRole(Qt.QPalette.Base) self.setAutoFillBackground(True) p = self.palette() p.setColor(self.backgroundRole(), Qt.Qt.black) self.setPalette(p) self.image_label = Qt.QLabel(self) self.image_label.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding) self.image_label.setAlignment(Qt.Qt.AlignCenter) self.text_label = Qt.QLabel(self) self.text_label.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding) self.text_label.setAlignment(Qt.Qt.AlignCenter) self.layout = Qt.QGridLayout() self.layout.addWidget(self.image_label, 1, 0) self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(self.text_label, 0, 0) self.setLayout(self.layout) self.showFullScreen()
def __init__(self, changed_signal, parent=None): super().__init__(parent) l = Qt.QFormLayout() self.setLayout(l) self.intervals = None self.fpss = None self.last_interval = None self.last_fps = None self._sample_count = None self.acquired_sample_count = 0 self.prev_t = None self.sample_count_spinbox = Qt.QSpinBox() self.sample_count_spinbox.setRange(2, 1024) self.sample_count_spinbox.valueChanged[int].connect( self._on_sample_count_spinbox_value_changed) l.addRow('Sample count:', self.sample_count_spinbox) fps_box = Qt.QHBoxLayout() fps_box.setSpacing(3) l.addRow(fps_box) self.rate_field = Qt.QLabel() self.rate_field.setFont(Qt.QFont('Courier')) rate_suffix = Qt.QLabel('fps') fps_box.addWidget(self.rate_field, alignment=Qt.Qt.AlignRight) fps_box.addWidget(rate_suffix, alignment=Qt.Qt.AlignLeft) fps_box.addSpacing(12) self.interval_field = Qt.QLabel() self.interval_field.setFont(Qt.QFont('Courier')) self.interval_suffix = Qt.QLabel() fps_box.addWidget(self.interval_field, alignment=Qt.Qt.AlignRight) fps_box.addWidget(self.interval_suffix, alignment=Qt.Qt.AlignLeft) self.sample_count = 60 changed_signal.connect(self.notify)
def __init__(self, parent, top, g_id, cover, nick): super().__init__(parent) self.top = top self.setProperty('class', 'the-room') self.setFixedSize(140, 150) self.g_id = g_id layer = CommonVBox() h_layer = CommonHBox() id_label = qt.QLabel(str(g_id), self) id_label.setAlignment(qt.Qt.AlignCenter) id_label.setProperty('class', 'id') cover_img = qt.QLabel(self) cover_img.setProperty('class', 'cover') cover_img.setFixedSize(66, 60) cover_img.setScaledContents(True) cover_img.setPixmap(qt.QPixmap(f'./static/avatar/{cover}.png')) join_btn = CommonBtn('加入', self) join_btn.clicked.connect(self.join_room) h_layer.addWidget(cover_img) nick_ = qt.QLabel(nick, self) nick_.setProperty('class', 'nick') nick_.setWordWrap(True) h_layer.addWidget(nick_) layer.addWidget(id_label, 0) layer.addLayout(h_layer, 2) layer.addWidget(join_btn, 0) self.setLayout(layer)
def __init__(self, items, width, height, *args, **kwargs): Qt.QDialog.__init__(self, *args, **kwargs) self.setWindowTitle(TITLE) self.layout = Qt.QVBoxLayout() self.setLayout(self.layout) icon = get_icons('images/icon.png') self.icon = Qt.QLabel(self) self.icon.setPixmap(icon.pixmap(85, 80)) self.layout.addWidget(self.icon) scroll = Qt.QScrollArea(self) scroll.setWidgetResizable(True) self.content = Qt.QWidget() scroll.setWidget(self.content) lay = Qt.QVBoxLayout(self.content) for item in items: lay.addWidget(Qt.QLabel(item, self)) self.layout.addWidget(scroll) self.ok_button = Qt.QPushButton('&OK', self) self.ok_button.setIcon(get_icons('images/ok.png')) self.ok_button.clicked.connect(self.close) self.ok_layout = Qt.QHBoxLayout() self.ok_layout.addStretch() self.ok_layout.addWidget(self.ok_button) self.layout.addLayout(self.ok_layout) self.setStyleSheet( 'QScrollArea{{min-width: {}px; min-height: {}px}}'.format( width, height))
def __init__(self, parent, top): super().__init__(parent) self.top = top self.setProperty("class", "act-info") layer = qt.QVBoxLayout() self.user_info = UserInfo(self, top) self.game_num = qt.QLabel(self) self.win_num = qt.QLabel(self) btn_frm = qt.QFrame(self) btn_layer = CommonHBox() self.save_btn = IcoButton(self.top, btn_frm, '保存', ico=0xe010) self.save_btn.clicked.connect(self.do_save) self.exit_btn = IcoButton(self.top, btn_frm, '退出', ico=0xe009) self.exit_btn.clicked.connect(self.do_exit) btn_layer.addWidget(self.save_btn) btn_layer.addWidget(self.exit_btn) btn_frm.setLayout(btn_layer) layer.addWidget(self.user_info, 3) layer.addWidget(self.game_num, 2) layer.addWidget(self.win_num, 1) layer.addWidget(btn_frm) self.setLayout(layer) self.save_signal.connect(self.save_result)
def __init__(self, parent): super(AboutDlg, self).__init__(parent) settings = Qt.QSettings() print(settings.applicationName(), settings.organizationName()) print("Groups", settings.childGroups()) for key in settings.allKeys(): print("KEY: {}:{}".format(key, settings.value(key))) prefix = settings.value(defines.WOW_VERSION_KEY) print("prefix", prefix) prefix = settings.value("version") print("prefix", prefix) settings.beginGroup(prefix) box = Qt.QVBoxLayout(self) box.addWidget(Qt.QLabel("Lcurse version: {}".format(VERSION), self)) settings = Qt.QSettings() box.addWidget(Qt.QLabel("Wow version: {}".format(prefix), self)) settings.beginGroup(prefix) box.addWidget( Qt.QLabel( "Wow path: {}".format(settings.value(defines.WOW_FOLDER_KEY)), self)) box.addWidget( Qt.QLabel( "Wow toc: {}".format(settings.value(defines.WOW_TOC_KEY)), self)) settings.endGroup() btnBox = Qt.QDialogButtonBox(Qt.QDialogButtonBox.Ok) btnBox.accepted.connect(self.close) box.addWidget(btnBox) self.show()
def __init__(self, parent=None): """ Create panel. Arguments: parent (Optional[QWidget]): Parent widget. Defaults to *None*. """ Q.QFrame.__init__(self, parent) self.setFrameStyle(Q.QFrame.Box | Q.QFrame.Sunken) self.setSizePolicy(Q.QSizePolicy.Expanding, Q.QSizePolicy.Expanding) self._icon = Q.QLabel(self) self._icon.setSizePolicy(Q.QSizePolicy.Fixed, Q.QSizePolicy.Fixed) self._title = Q.QLabel(self) base = Q.QWidget(self) self._container = Q.QVBoxLayout(base) self._container.setContentsMargins(0, 0, 0, 0) self._buttonbox = Q.QDialogButtonBox(Q.Qt.Horizontal, self) v_layout = Q.QVBoxLayout(self) h_layout = Q.QHBoxLayout() h_layout.addWidget(self._icon) h_layout.addWidget(self._title) v_layout.addLayout(h_layout) v_layout.addWidget(HLine(self)) v_layout.addWidget(base) v_layout.addWidget(self._buttonbox) self._buttonbox.clicked.connect(self._clicked) self.hide()
def __init__(self, app, parent): super().__init__() exam_data = parent.exam_data finish_button = Qt.QPushButton('Закончить экзамен', self) finish_button.setObjectName('Button') finish_button.setFont(Qt.QFont('Arial', 20)) finish_button.clicked.connect( lambda: app.finish_exam(exam_data['rowid'])) info_str = (' Всего баллов: ' + str(exam_data['total_score']) + ' (из ' + str(exam_data['total_maxscore']) + ')') info_label = Qt.QLabel(info_str, self) info_label.setFont(Qt.QFont('Arial', 20)) timer_label = Qt.QLabel(self) timer_label.setFont(Qt.QFont('Arial', 25)) timer = Timer() timer.tie(timer_label) timer.start(exam_data['end'] - int(time()), lambda: app.finish_exam(exam_data['rowid'])) status_layout = Qt.QHBoxLayout() status_layout.addWidget(finish_button) status_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) status_layout.addWidget(info_label) status_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) status_layout.addStretch(1) status_layout.addWidget(timer_label) self.setLayout(status_layout)
def __init__(self, parent, addons): super(CheckDlg, self).__init__(parent) settings = Qt.QSettings() layout = Qt.QVBoxLayout(self) if len(addons) == 1: layout.addWidget(Qt.QLabel(self.tr("Verifying if the addon needs an update..."))) else: layout.addWidget(Qt.QLabel(self.tr("Verifying which addon needs an update..."))) self.progress = Qt.QProgressBar(self) self.progress.setRange(0, len(addons)) self.progress.setValue(0) self.progress.setFormat("%v / %m | %p%") layout.addWidget(self.progress) cancelBox = Qt.QHBoxLayout() cancelBox.addStretch() self.cancelButton = Qt.QPushButton(self.tr("Cancel"), self) self.cancelButton.clicked.connect(self.onCancel) cancelBox.addWidget(self.cancelButton) cancelBox.addStretch() layout.addLayout(cancelBox) self.addons = addons self.maxThreads = int(settings.value(defines.LCURSE_MAXTHREADS_KEY, defines.LCURSE_MAXTHREADS_DEFAULT)) self.sem = Qt.QSemaphore(self.maxThreads) # safe to use without a mutex because reading and writing are independent of each other, # and GIL will make these atomic operations. self.cancelled = False # protected with self.progressMutex self.progressMutex = Lock() self.progressOrAborted = 0 self.closeSignal.connect(self.close)
def __init__(self): super().__init__() self.setGeometry(540, 65, 320, 200) self.setWindowTitle('MainWindow') self.labelMain = Qt.QLabel("Результат потоковой задачи WorkThreadMain: ") self.labelThread = Qt.QLabel("Результат Потоковой задачи WorkThread: ") validator = Qt.QIntValidator(1, 999, self) validator.setBottom(1) self.lineEdit = Qt.QLineEdit() self.lineEdit.setPlaceholderText("Начильный параметр для потоковой задачи WorkThread") # self.lineEdit будет принимать только целые числа от 1 до 999 self.lineEdit.setValidator(validator) self.btn = Qt.QPushButton("Start поток WorkThread") self.btn.clicked.connect(self.on_btn) self.btnMain = Qt.QPushButton("Запустить поток WorkThreadMain") self.btnMain.clicked.connect(self.on_btnMain) layout = Qt.QVBoxLayout(self) layout.addWidget(self.labelMain) layout.addWidget(self.labelThread) layout.addWidget(self.lineEdit) layout.addWidget(self.btn) layout.addWidget(self.btnMain) self.msg = MsgBox() self.thread = None self.threadMain = None
def add_row(self, row, name, unit, value_property, target_property, range_low, range_high): layout = self.layout() target_label = Qt.QLabel('Target {}:'.format(name)) target_label.setAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignVCenter) #target_label.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding) layout.addWidget(target_label, row, 0) target = Qt.QLineEdit() target.setValidator( Qt.QDoubleValidator(range_low, range_high, 1, parent=self)) update = self.subscribe( target_property, callback=lambda value: target.setText(str(value))) def editing_finished(): try: value = float(target.text()) update(value) except Exception as e: Qt.QMessageBox.warning(self, 'Could not set {}'.format(name), e.args[0]) target.editingFinished.connect(editing_finished) layout.addWidget(target, row, 1) label = Qt.QLabel('{}\t{}: - {}'.format(unit, name, unit)) layout.addWidget(label, row, 2) self.subscribe(value_property, callback=lambda value: label.setText( '{}\t{}: {} {}'.format(unit, name, value, unit)), readonly=True)
def __init__(self, p, top): super().__init__(p) self.top = top self.choose_color = config['color'] self.setProperty('class', 'set') layer = qt.QVBoxLayout() self.server_cfg = qt.QFrame(self) layer_1 = CommonHBox() layer_1.addWidget(qt.QLabel('服务器', self.server_cfg)) self.server_input = qt.QLineEdit(config['server'], self.server_cfg) layer_1.addWidget(self.server_input) self.server_cfg.setLayout(layer_1) self.color_cfg = qt.QFrame(self) layer_2 = CommonHBox() layer_2.addWidget(qt.QLabel('主题', self.server_cfg)) self.white = qt.QPushButton(self.color_cfg) self.white.clicked.connect(self.set_white) self.white.setProperty('class', 'white') self.dracula = qt.QPushButton(self.color_cfg) self.dracula.clicked.connect(self.set_dracula) self.dracula.setProperty('class', 'dracula') layer_2.addWidget(self.white) layer_2.addWidget(self.dracula) self.color_cfg.setLayout(layer_2) self.save_btn = CommonBtn('保存', self) self.save_btn.clicked.connect(self.save) layer.addWidget(self.server_cfg) layer.addWidget(self.color_cfg) layer.addWidget(self.save_btn) self.setLayout(layer)
def refresh_info(self): # 删除旧元素 while self.info_layout.count(): obj = self.info_layout.itemAt(0).widget() if isinstance(obj, Qt.QFrame): obj.setParent(None) self.info_rows = [] for key in self.keys: if key in self.top.config['dont_show_sub'].get(self.id_, []): continue row = Qt.QFrame(self.info_container) row.key = key row.setProperty('class', 'row') row_layout = Qt.QHBoxLayout() label_name = Qt.QLabel(self.top.config['prop_chinese'][key], row) label_name.setProperty('class', 'name') label_name.key = 'name' label_value = Qt.QLabel('0', row) label_value.setProperty('class', 'value') label_value.key = 'value' row_layout.setSpacing(0) row_layout.setContentsMargins(0, 0, 0, 0) row_layout.addWidget(label_name) row_layout.addWidget(label_value) row.setLayout(row_layout) self.info_layout.addWidget(row) self.info_rows.append(row)
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.win_act = winAct.WinAction() self.resize(925, 598) self.setWindowIcon(QtGui.QIcon('window_icon.png')) self.setWindowTitle('AtomParser') self.label = Qt.QLabel(self) pixmap = QtGui.QPixmap('bgrnd.jpg') self.label.resize(pixmap.width(), pixmap.height()) self.label.setPixmap(pixmap) self.add = QtWidgets.QPushButton('', self) self.add.setIcon(QtGui.QIcon('plus.png')) self.add.resize(30, 30) self.add.setIconSize(QtCore.QSize(40, 40)) self.add.move(270, 50) self.add.clicked.connect(self.add_file) upld = Qt.QLabel('Upload file', self) upld.resize(150, 30) upld.setStyleSheet('font: 28px fantasy') upld.move(50, 50) self.sensors = QtWidgets.QComboBox(self) self.sensors.resize(0, 0) self.sensors.currentIndexChanged.connect(self.change_sensor)
def __init__(self, parent, title, *args, **kwargs): Qt.QDialog.__init__(self, parent, *args, **kwargs) self.setWindowTitle(title) self.setWindowFlags(QtCore.Window | QtCore.WindowTitleHint | QtCore.CustomizeWindowHint) self.layout = Qt.QVBoxLayout() self.setLayout(self.layout) icon = get_icons('images/icon.png') self.icon = Qt.QLabel(self) self.icon.setPixmap(icon.pixmap(42, 40)) self.layout.addWidget(self.icon) self.info_label = Qt.QLabel('Launching ElasticSearch...') self.layout.addWidget(self.info_label) self.cancel_button = Qt.QPushButton('&Cancel', self) self.cancel_button.clicked.connect(self.cancel) self.layout.addWidget(self.cancel_button) self.reason = None launcher = Launcher() Qt.QThreadPool.globalInstance().start(launcher)
def _populate_table(self, elements=[]): self.signalMapper2 = QtCore.QSignalMapper(self) self.signalMapper2.mapped[Qt.QWidget].connect(self.elementToggler) for i in pt_indexes: pt_button = HoverableButton(i) pt_button.setStyleSheet(""" padding-left: 5px; padding-right: 3px; padding-top: 1px; padding-bottom: 1px;""") if i in elements: pt_button.setChecked(True) self.setCellWidget(pt_indexes[i][0], pt_indexes[i][1], pt_button) pt_button.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) pt_button.toggled.connect(self.signalMapper2.map) self.signalMapper2.setMapping(pt_button, pt_button) line = Qt.QFrame() line.setFrameShape(Qt.QFrame.HLine) line.setFrameShadow(Qt.QFrame.Sunken) self.setCellWidget(6, 3, line) #dissable inert gasses, H and Li: for i in ['H', 'He', 'Ne', 'Ar', 'Xe', 'Kr', 'Rn', 'Li']: self.cellWidget(pt_indexes[i][0], pt_indexes[i][1]).setEnabled(False) lant_text = Qt.QLabel('Lan') act_text = Qt.QLabel('Act') lant_text.setAlignment(QtCore.Qt.AlignCenter) act_text.setAlignment(QtCore.Qt.AlignCenter) self.setCellWidget(5, 2, lant_text) self.setCellWidget(6, 2, act_text) lant_text.setEnabled(False) act_text.setEnabled(False) self.setMinimumWidth(self.horizontalHeader().length() + 10)
def timerXADCEvent(self): # read from xadc registers: # print(self.qplots.isVisible()) if not self.sl.dev.valid_socket: return try: (Vccint, Vccaux, Vbram) = self.sl.readZynqXADCsupply() ZynqTempInDegC = self.sl.readZynqTemperature() # print('Zynq temperature (max 85 degC operating): %.2f degC' % ZynqTempInDegC) self.qlbl_Temp.setText( 'Zynq temperature (max 85 degC operating): %.2f degC' % ZynqTempInDegC) self.qlbl_vccint.setText('Vccint = %.2f V' % Vccint) self.qlbl_vccaux.setText('Vccaux = %.2f V' % Vccaux) self.qplots.addDataPoint(time.perf_counter() - self.time_start, [ZynqTempInDegC]) except: self.qlbl_Temp = Qt.QLabel('Zynq temperature: N/A degC') self.qlbl_vccint = Qt.QLabel('Vccint = N/A V') self.qlbl_vccaux = Qt.QLabel('Vccaux = N/A V') # read ext clk frequency: try: self.lblExtClkFreq.setText('Ext clk freq = %.8f MHz' % (self.sl.getExtClockFreq() / 1e6)) except: self.lblExtClkFreq.setText('Ext clk freq = N/A MHz')
def __init__(self, app, parent): super().__init__(parent) question_data = parent.question_data statement_label = Qt.QLabel(question_data['statement'], self) statement_label.setFont(Qt.QFont('Arial', 20)) statement_label.setWordWrap(True) answer_title = Qt.QLabel('Ответ:', self) answer_title.setFont(Qt.QFont('Arial', 30)) answer_input = Qt.QLineEdit(self) answer_input.setFont(Qt.QFont('Arial', 20)) answer_input.setMinimumWidth(500) answer_input.setFocus() check_button = Qt.QPushButton('Проверить', self) check_button.setObjectName('Button') check_button.setFont(Qt.QFont('Arial', 20)) check_button.clicked.connect(lambda: app.send_submission( question_data['rowid'], answer_input.text())) answer_input.returnPressed.connect(check_button.click) self.lower_layout.addWidget(answer_title) self.lower_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) self.lower_layout.addWidget(answer_input) self.lower_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) self.lower_layout.addStretch(1) self.lower_layout.addWidget(check_button) self.layout.addWidget(statement_label) self.layout.addStretch(1)
def __init__(self, parent): super(PreferencesDlg, self).__init__(parent) self.settings = Qt.QSettings() layout = Qt.QVBoxLayout(self) layout.addWidget(Qt.QLabel(self.tr("WoW Install Folder:"), self)) folderlayout = Qt.QHBoxLayout() self.wowInstallFolder = Qt.QLineEdit(self.getWowFolder(), self) folderlayout.addWidget(self.wowInstallFolder) btn = Qt.QPushButton(self.tr("..."), self) btn.clicked.connect(self.browseForWoWFolder) folderlayout.addWidget(btn) layout.addLayout(folderlayout) layout.addWidget(Qt.QLabel(self.tr("Max. concurrent Threads:"), self)) self.maxthreads = Qt.QSpinBox(self) self.maxthreads.setMinimum(1) self.maxthreads.setMaximum(1000) self.maxthreads.setValue(self.getMaxThreads()) layout.addWidget(self.maxthreads) bottom = Qt.QHBoxLayout() bottom.addSpacing(100) btn = Qt.QPushButton(self.tr("Save"), self) btn.clicked.connect(self.accept) btn.setDefault(True) bottom.addWidget(btn) btn = Qt.QPushButton(self.tr("Cancel"), self) btn.clicked.connect(self.reject) bottom.addWidget(btn) layout.addSpacing(100) layout.addLayout(bottom) self.setLayout(layout)
def init_cbx(self): self.remember_pwd_checkbox = QtWidgets.QCheckBox() self.remember_pwd_checkbox.clicked.connect(self.remember_pwd) self.auto_login_checkbox = QtWidgets.QCheckBox() self.auto_login_checkbox.clicked.connect(self.auto_login) self.remember_proxy_checkbox = QtWidgets.QCheckBox() self.remember_proxy_checkbox.clicked.connect(self.remember_proxy) self.require_flag_checkbox = QtWidgets.QCheckBox() self.require_flag_checkbox.clicked.connect(self.set_require_flag) self.cache_flag_checkbox = QtWidgets.QCheckBox() self.cache_flag_checkbox.clicked.connect(self.set_cache_flag) cbxLayout = Qt.QHBoxLayout() #cbxLayout.setSpacing(10) rem_Layout = Qt.QHBoxLayout() rem_Layout.setSpacing(1) rem_Layout.addWidget(self.remember_pwd_checkbox) rem_Layout.addWidget(QtWidgets.QLabel("记住密码")) rem_Widget = QtWidgets.QWidget() rem_Widget.setLayout(rem_Layout) auto_login_Layout = Qt.QHBoxLayout() auto_login_Layout.setSpacing(1) auto_login_Layout.addWidget(self.auto_login_checkbox) auto_login_Layout.addWidget(Qt.QLabel("显示密码")) auto_login_Widget = QtWidgets.QWidget() auto_login_Widget.setLayout(auto_login_Layout) rem_proxy_Layout = Qt.QHBoxLayout() rem_proxy_Layout.setSpacing(1) rem_proxy_Layout.addWidget(self.remember_proxy_checkbox) rem_proxy_Layout.addWidget(Qt.QLabel("记住代理")) rem_proxy_Widget = QtWidgets.QWidget() rem_proxy_Widget.setLayout(rem_proxy_Layout) require_flag_Layout = Qt.QHBoxLayout() require_flag_Layout.setSpacing(1) require_flag_Layout.addWidget(self.require_flag_checkbox) require_flag_Layout.addWidget(Qt.QLabel("更改必修")) require_flag_Widget = QtWidgets.QWidget() require_flag_Widget.setLayout(require_flag_Layout) cache_flag_Layout = Qt.QHBoxLayout() cache_flag_Layout.setSpacing(1) cache_flag_Layout.addWidget(self.cache_flag_checkbox) cache_flag_Layout.addWidget(Qt.QLabel("读取缓存")) cache_flag_Widget = QtWidgets.QWidget() cache_flag_Widget.setLayout(cache_flag_Layout) #cbxLayout.setSpacing(5) cbxLayout.addWidget(rem_Widget) cbxLayout.addWidget(auto_login_Widget) cbxLayout.addWidget(rem_proxy_Widget) cbxLayout.addWidget(require_flag_Widget) cbxLayout.addWidget(cache_flag_Widget) return cbxLayout
def init_widgets(self): lbl_width = 45 val_width = 125 lbl_height = 12 #Device devLabel = Qt.QLabel("Device:") devLabel.setAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignVCenter) devLabel.setStyleSheet("QLabel {font:10pt; color:rgb(255,0,0);}") devLabel.setFixedWidth(lbl_width) self.devTextBox = Qt.QLineEdit() self.devTextBox.setText("/dev/ttyUSB0") self.devTextBox.setEchoMode(Qt.QLineEdit.Normal) self.devTextBox.setStyleSheet( "QLineEdit {font:10pt; background-color:rgb(200,75,75); color:rgb(0,0,0);}" ) self.devTextBox.setFixedWidth(val_width) self.devTextBox.setFixedHeight(20) dev_hbox = Qt.QHBoxLayout() dev_hbox.addWidget(devLabel) dev_hbox.addWidget(self.devTextBox) #Connection Button & Connection Status self.connect_button = Qt.QPushButton("Connect") self.connect_button.setStyleSheet( "QPushButton {font:10pt; background-color:rgb(200,0,0);}") self.connect_button.setFixedHeight(20) self.connect_button.setFixedWidth(100) btn_hbox = Qt.QHBoxLayout() btn_hbox.addStretch(1) btn_hbox.addWidget(self.connect_button) btn_hbox.addStretch(1) status_lbl = Qt.QLabel('Status:') status_lbl.setAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignVCenter) status_lbl.setStyleSheet("QLabel {font:10pt; color:rgb(255,0,0);}") status_lbl.setFixedHeight(lbl_height) status_lbl.setFixedWidth(lbl_width) self.conn_status_lbl = Qt.QLabel('Disconnected') self.conn_status_lbl.setAlignment(Qt.Qt.AlignLeft | Qt.Qt.AlignVCenter) self.conn_status_lbl.setStyleSheet( "QLabel {font:10pt; font-weight:bold; color:rgb(255,0,0);}") self.conn_status_lbl.setFixedWidth(val_width) self.conn_status_lbl.setFixedHeight(lbl_height) status_hbox = Qt.QHBoxLayout() status_hbox.addWidget(status_lbl) status_hbox.addWidget(self.conn_status_lbl) vbox = Qt.QVBoxLayout() vbox.addLayout(dev_hbox) vbox.addLayout(status_hbox) vbox.addLayout(btn_hbox) vbox.addStretch(1) self.setLayout(vbox)
def __init__(self, text, back_function, main_function): super().__init__() back_button = Qt.QPushButton(Qt.QIcon(common.LEFT), '', self) back_button.setObjectName('Flat') back_button.setCursor(Qt.Qt.PointingHandCursor) back_button.setIconSize(Qt.QSize(35, 35)) back_button.setFixedSize(Qt.QSize(55, 55)) back_button.clicked.connect(lambda _: back_function()) confirm_title = Qt.QLabel('Подтвердите действие', self) confirm_title.setFont(Qt.QFont('Arial', 30)) confirm_label = Qt.QLabel(text, self) confirm_label.setFont(Qt.QFont('Arial', 25)) confirm_label.setAlignment(Qt.Qt.AlignCenter) confirm_label.setWordWrap(True) confirm_label.setStyleSheet('color: red') yes_button = Qt.QPushButton(Qt.QIcon(common.TICK), 'Да, продолжить', self) yes_button.setObjectName('Button') yes_button.setIconSize(Qt.QSize(35, 35)) yes_button.setFont(Qt.QFont('Arial', 20)) yes_button.clicked.connect(lambda _: main_function()) no_button = Qt.QPushButton(Qt.QIcon(common.CROSS), 'Нет, отменить', self) no_button.setObjectName('Button') no_button.setIconSize(Qt.QSize(35, 35)) no_button.setFont(Qt.QFont('Arial', 20)) no_button.clicked.connect(lambda _: back_function()) upper_layout = Qt.QHBoxLayout() upper_layout.addWidget(back_button) upper_layout.addStretch(1) upper_layout.addWidget(confirm_title) upper_layout.addStretch(1) button_layout = Qt.QHBoxLayout() button_layout.addStretch(1) button_layout.addWidget(yes_button) button_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) button_layout.addWidget(no_button) button_layout.addStretch(1) layout = Qt.QVBoxLayout() layout.addLayout(upper_layout) layout.addStretch(1) layout.addWidget(confirm_label) layout.addSpacerItem(Qt.QSpacerItem(0, 30)) layout.addLayout(button_layout) layout.addStretch(1) self.setLayout(layout)
def make_widgets_for_property(self, property, type, readonly): label = Qt.QLabel(property + ':') self.layout().addWidget(label, self._row, 0) widget = self.make_widget(property, type, readonly) ret = [label, widget] self.layout().addWidget(widget, self._row, 1) if property in self.units: unit_label = Qt.QLabel(self.units[property]) ret.append(unit_label) self.layout().addWidget(unit_label, self._row, 2) self._row += 1 return ret
def __init__(self, app, parent): super().__init__(parent) question_data = parent.question_data question_result = parent.question_result next_question_id = None if parent.question_number < len(parent.questions_ids): next_question_id = parent.questions_ids[parent.question_number] self.answer = question_result['answer'] if question_result else '' statement_label = Qt.QLabel(question_data['statement'], self) statement_label.setFont(Qt.QFont('Arial', 20)) statement_label.setWordWrap(True) self.answer_input = Qt.QPlainTextEdit(self) self.answer_input.setFont(Qt.QFont('Arial', 20)) self.answer_input.setPlainText(self.answer) self.answer_input.textChanged.connect(self.update_status) self.save_button = Qt.QPushButton('Сохранить', self) self.save_button.setObjectName('Button') self.save_button.setFont(Qt.QFont('Arial', 20)) self.save_button.clicked.connect(lambda: app.send_submission( question_data['rowid'], self.answer_input.toPlainText())) self.status_img = Qt.QLabel(self) self.status_img.setScaledContents(True) self.status_img.setFixedSize(Qt.QSize(50, 50)) self.status_label = Qt.QLabel(self) self.status_label.setFont(Qt.QFont('Arial', 20)) self.update_status() next_button = Qt.QPushButton('Далее', self) next_button.setObjectName('Button') next_button.setFont(Qt.QFont('Arial', 20)) next_button.setAutoDefault(True) next_button.clicked.connect( lambda: app.view_exam_question(next_question_id)) next_button.setFocus() if next_question_id is None: next_button.setDisabled(True) self.lower_layout.addWidget(self.save_button) self.lower_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) self.lower_layout.addWidget(self.status_img) self.lower_layout.addWidget(self.status_label) self.lower_layout.addSpacerItem(Qt.QSpacerItem(10, 0)) self.lower_layout.addStretch(1) self.lower_layout.addWidget(next_button) self.layout.addWidget(statement_label) self.layout.addSpacerItem(Qt.QSpacerItem(0, 20)) self.layout.addWidget(self.answer_input)
def __init__(self, top, parent, svg, init_value=50, init_info=None, id_='', keys=()): super().__init__(parent) self.setProperty('class', 'prop') self.top = top self.width_ = 160 self.height_ = 24 self.keys = keys self.info_rows = [] self.id_ = id_ layout = Qt.QHBoxLayout() self.svg = Svg(self, svg) self.value_container = Qt.QFrame(self) self.value_container.setProperty('class', 'value-container') value_layout = Qt.QVBoxLayout() self.value_crop = Qt.QLabel(self.value_container) self.value_crop.setProperty('class', 'crop') self.value_crop.setFixedHeight(self.height_ - 2) self.value_content = Qt.QLabel(self.value_crop) self.value_content.setProperty('class', 'content') self.value_content.move(0, 0) self.value_content.setFixedSize(self.width_, self.height_ - 2) value_layout.addWidget(self.value_crop) value_layout.setContentsMargins(0, 0, 0, 0) value_layout.setSpacing(0) self.value_container.setLayout(value_layout) self.value_container.setFixedSize(self.width_, self.height_) self.info_container = Qt.QFrame(self) self.info_container.setProperty('class', 'info-container') self.info_layout = Qt.QVBoxLayout() self.refresh_info() self.info_container.setLayout(self.info_layout) layout.setAlignment(Qt.Qt.AlignLeft) layout.addWidget(self.svg) layout.addWidget(self.value_container) layout.addWidget(self.info_container) self.setLayout(layout) self.update_value(init_value) self.update_info(init_info or {})
def create_statusbar(self): self.__location_label = Qt.QLabel(" W999 ") self.__location_label.setAlignment(Qt.Qt.AlignHCenter) self.__location_label.setMinimumSize(self.__location_label.sizeHint()) self.__lock_label = Qt.QLabel(u"") self.__lock_label.setAutoFillBackground(True) self.__lock_label.setAlignment(Qt.Qt.AlignHCenter) self.__lock_label.setMinimumSize(self.__lock_label.sizeHint()) self.statusBar().addWidget(self.__location_label) self.statusBar().addWidget(self.__lock_label)
def kodos_toolbar_logo(toolbar): # hack to move logo to right blanklabel = Qt.QLabel() blanklabel.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Preferred) logolabel = Qt.QLabel("kodos_logo") logolabel.setPixmap(Qt.QPixmap(":/images/kodos_icon.png")) toolbar.addWidget(blanklabel) toolbar.addWidget(logolabel) return logolabel
def __init__(self, app, exam_data, cnt_questions): super().__init__() info_str = ('Продолжительность - ' + str(exam_data['duration']) + ' минут\n' + 'Количество заданий - ' + str(cnt_questions)) back_button = Qt.QPushButton(Qt.QIcon(common.LEFT), '', self) back_button.setObjectName('Flat') back_button.setCursor(Qt.Qt.PointingHandCursor) back_button.setIconSize(Qt.QSize(35, 35)) back_button.setFixedSize(Qt.QSize(55, 55)) back_button.clicked.connect(lambda _: app.display_home_page()) exam_title = Qt.QLabel(exam_data['name'], self) exam_title.setFont(Qt.QFont('Arial', 30)) exam_title.setAlignment(Qt.Qt.AlignCenter) exam_title.setWordWrap(True) info_title = Qt.QLabel('Информация', self) info_title.setFont(Qt.QFont('Arial', 25)) info_label = Qt.QLabel(info_str, self) info_label.setFont(Qt.QFont('Arial', 20)) info_label.setWordWrap(True) start_button = Qt.QPushButton('Начать экзамен', self) start_button.setObjectName('Button') start_button.setFont(Qt.QFont('Arial', 20)) start_button.clicked.connect( lambda: app.start_exam(exam_data['rowid'])) upper_layout = Qt.QHBoxLayout() upper_layout.addWidget(back_button) upper_layout.addWidget(exam_title) info_layout = Qt.QHBoxLayout() info_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) info_layout.addWidget(info_label) button_layout = Qt.QHBoxLayout() button_layout.addWidget(start_button) button_layout.addStretch(1) layout = Qt.QVBoxLayout() layout.addLayout(upper_layout) layout.addSpacerItem(Qt.QSpacerItem(0, 40)) layout.addWidget(info_title) layout.addSpacerItem(Qt.QSpacerItem(0, 20)) layout.addLayout(info_layout) layout.addSpacerItem(Qt.QSpacerItem(0, 30)) layout.addLayout(button_layout) layout.addStretch(1) self.setLayout(layout)
def setup_ui(self) -> None: layout = Qt.QHBoxLayout(self) layout.setObjectName('PipetteToolbar.setup_ui.layout') layout.setContentsMargins(0, 0, 0, 0) self.color_view = ColorView(self) self.color_view.setFixedSize(self.height() // 2, self.height() // 2) layout.addWidget(self.color_view) font = Qt.QFont('Consolas', 9) font.setStyleHint(Qt.QFont.Monospace) self.position = Qt.QLabel(self) self.position.setFont(font) self.position.setTextInteractionFlags(Qt.Qt.TextSelectableByMouse) layout.addWidget(self.position) self.rgb_label = Qt.QLabel(self) self.rgb_label.setText('Rendered (RGB):') layout.addWidget(self.rgb_label) self.rgb_hex = Qt.QLabel(self) self.rgb_hex.setFont(font) self.rgb_hex.setTextInteractionFlags(Qt.Qt.TextSelectableByMouse) layout.addWidget(self.rgb_hex) self.rgb_dec = Qt.QLabel(self) self.rgb_dec.setFont(font) self.rgb_dec.setTextInteractionFlags(Qt.Qt.TextSelectableByMouse) layout.addWidget(self.rgb_dec) self.rgb_norm = Qt.QLabel(self) self.rgb_norm.setFont(font) self.rgb_norm.setTextInteractionFlags(Qt.Qt.TextSelectableByMouse) layout.addWidget(self.rgb_norm) self.src_label = Qt.QLabel(self) layout.addWidget(self.src_label) self.src_hex = Qt.QLabel(self) self.src_hex.setFont(font) self.src_hex.setTextInteractionFlags(Qt.Qt.TextSelectableByMouse) layout.addWidget(self.src_hex) self.src_dec = Qt.QLabel(self) self.src_dec.setFont(font) self.src_dec.setTextInteractionFlags(Qt.Qt.TextSelectableByMouse) layout.addWidget(self.src_dec) self.src_norm = Qt.QLabel(self) self.src_norm.setFont(font) self.src_norm.setTextInteractionFlags(Qt.Qt.TextSelectableByMouse) layout.addWidget(self.src_norm) layout.addStretch()
def __init__(self, app, parent): super().__init__(parent) question_data = parent.question_data question_result = parent.question_result question_style = common.main_question_style(question_result) next_question_id = None if parent.question_number < len(parent.questions_ids): next_question_id = parent.questions_ids[parent.question_number] statement_label = Qt.QLabel(question_data['statement'], self) statement_label.setFont(Qt.QFont('Arial', 20)) statement_label.setWordWrap(True) answer_title = Qt.QLabel('Ответ:', self) answer_title.setFont(Qt.QFont('Arial', 30)) answer_input = Qt.QLineEdit(question_result['answer'], self) answer_input.setFont(Qt.QFont('Arial', 20)) answer_input.setMinimumWidth(500) answer_input.setDisabled(True) answer_input.setStyleSheet('border-width: 2px;' 'border-color: ' + question_style['main_color'] + ';') status_img = Qt.QLabel(self) status_img.setScaledContents(True) status_img.setPixmap(question_style['main_picture']) status_img.setFixedSize(Qt.QSize(50, 50)) next_button = Qt.QPushButton('Далее', self) next_button.setObjectName('Button') next_button.setFont(Qt.QFont('Arial', 20)) next_button.setAutoDefault(True) next_button.clicked.connect( lambda: app.view_exam_question(next_question_id)) next_button.setFocus() if next_question_id is None: next_button.setDisabled(True) self.lower_layout.addWidget(answer_title) self.lower_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) self.lower_layout.addWidget(answer_input) self.lower_layout.addSpacerItem(Qt.QSpacerItem(10, 0)) self.lower_layout.addWidget(status_img) self.lower_layout.addSpacerItem(Qt.QSpacerItem(10, 0)) self.lower_layout.addStretch(1) self.lower_layout.addWidget(next_button) self.layout.addWidget(statement_label) self.layout.addStretch(1)