我们从Python开源项目中,提取了以下42个代码示例,用于说明如何使用PyQt5.QtCore.Qt.AlignHCenter()。
def __init__(self, parent, relativeconfpath): super(TextEditOptionDialog, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose, True) self.setWindowFlags(dialogwindowflags) self.setWindowTitle(relativeconfpath) self.conf = path.join(configlocation, relativeconfpath) with open(self.conf, "r", encoding="utf-8") as configfile: config = configfile.read() self.resize(640, 480) self.layout = QVBoxLayout() self.editor = RegularTextEdit() self.button = QPushButton(_("OK")) self.editor.setPlainText(config) self.editor.setWordWrapMode(QTextOption.NoWrap) self.layout.addWidget(self.editor) self.layout.addWidget(self.button) self.layout.setAlignment(self.button, Qt.AlignHCenter) self.button.clicked.connect(self.accept) self.setLayout(self.layout)
def createIpAndPortFields(self): ipLabel = QLabel('Opponent IP:') ipLabel.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) portLabel = QLabel('Game port:') portLabel.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.ipField = QLineEdit() self.ipField.setInputMask('000.000.000.000; ') self.ipField.setFixedWidth(130) self.ipField.textChanged.connect(self.ipChange) self.portSpinBox = QSpinBox() self.portSpinBox.setRange(1024, 8080) self.portSpinBox.setFixedWidth(80) layout = QGridLayout() layout.addWidget(ipLabel, 0, 0) layout.addWidget(self.ipField, 0, 1) layout.addWidget(portLabel, 1, 0) layout.addWidget(self.portSpinBox, 1, 1) return layout
def createIcons(self): configButton = QListWidgetItem(self.contentsWidget) configButton.setIcon(QIcon(':/images/config.png')) configButton.setText("Configuration") configButton.setTextAlignment(Qt.AlignHCenter) configButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) updateButton = QListWidgetItem(self.contentsWidget) updateButton.setIcon(QIcon(':/images/update.png')) updateButton.setText("Update") updateButton.setTextAlignment(Qt.AlignHCenter) updateButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) queryButton = QListWidgetItem(self.contentsWidget) queryButton.setIcon(QIcon(':/images/query.png')) queryButton.setText("Query") queryButton.setTextAlignment(Qt.AlignHCenter) queryButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) self.contentsWidget.currentItemChanged.connect(self.changePage)
def __init__(self): super(Window, self).__init__() self.setWindowTitle("2D Painting on Native and OpenGL Widgets") helper = Helper() native = Widget(helper, self) openGL = GLWidget(helper, self) nativeLabel = QLabel("Native") nativeLabel.setAlignment(Qt.AlignHCenter) openGLLabel = QLabel("OpenGL") openGLLabel.setAlignment(Qt.AlignHCenter) layout = QGridLayout() layout.addWidget(native, 0, 0) layout.addWidget(openGL, 0, 1) layout.addWidget(nativeLabel, 1, 0) layout.addWidget(openGLLabel, 1, 1) self.setLayout(layout) timer = QTimer(self) timer.timeout.connect(native.animate) timer.timeout.connect(openGL.animate) timer.start(50)
def init_widget(self): self.setWindowTitle("Layout Basic") self.setFixedWidth(640) self.setFixedHeight(480) self.lb_1.setText("Label 1") self.lb_2.setText("Label 2") self.lb_3.setText("Label 3") self.lb_4.setText("Label 4") self.lb_5.setText("Label 5") self.lb_1.setStyleSheet("background-color: yellow") self.lb_2.setStyleSheet("background-color: red") self.lb_3.setStyleSheet("background-color: blue") self.lb_4.setStyleSheet("background-color: pink") self.lb_5.setStyleSheet("background-color: grey") self.layout_1.addWidget(self.lb_1) self.layout_1.addWidget(self.lb_2, alignment=Qt.AlignTop) self.layout_1.addWidget(self.lb_3, alignment=Qt.AlignBottom) self.layout_1.addWidget(self.lb_4, alignment=Qt.AlignVCenter) self.layout_1.addWidget(self.lb_5, alignment=Qt.AlignHCenter)
def initUI(self): """ Initialize the Dialog layout. """ self.setWindowTitle('Installing plugin') self.setFixedSize(500, 140) self.setStyleSheet(""" QDialog { background: #F2F2F2; } """) self.progress = BusyProgressBar(self) self.progress.start() self.message = QLabel('initializing setup', self) self.message.setAlignment(Qt.AlignHCenter) self.message.setWordWrap(True) self.message.setOpenExternalLinks(True) self.layout = QVBoxLayout() self.layout.addWidget(self.progress) self.layout.addWidget(self.message) self.layout.setAlignment(Qt.AlignCenter) self.setLayout(self.layout) self.setModal(True)
def initCategories(self): generalButton = QListWidgetItem(self.categories) generalButton.setIcon(QIcon(':/images/settings-general.png')) generalButton.setText('General') generalButton.setToolTip('General settings') generalButton.setTextAlignment(Qt.AlignHCenter) generalButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) videoButton = QListWidgetItem(self.categories) videoButton.setIcon(QIcon(':/images/settings-video.png')) videoButton.setText('Video') videoButton.setToolTip('Video settings') videoButton.setTextAlignment(Qt.AlignHCenter) videoButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) themeButton = QListWidgetItem(self.categories) themeButton.setIcon(QIcon(':/images/settings-theme.png')) themeButton.setText('Theme') themeButton.setToolTip('Theme settings') themeButton.setTextAlignment(Qt.AlignHCenter) themeButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) logsButton = QListWidgetItem(self.categories) logsButton.setIcon(QIcon(':/images/settings-logs.png')) logsButton.setText('Logs') logsButton.setToolTip('Logging settings') logsButton.setTextAlignment(Qt.AlignHCenter) logsButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) self.categories.currentItemChanged.connect(self.changePage) self.categories.setCurrentRow(0) self.categories.setMaximumWidth(self.categories.sizeHintForColumn(0) + 2) self.setMinimumWidth(650 if sys.platform == 'darwin' else 620) if sys.platform != 'win32': self.adjustSize()
def showTimer(self) -> None: self._timerwidget.show() # noinspection PyArgumentList self.layout().addWidget(self._timerwidget, 1, 0, Qt.AlignHCenter | Qt.AlignTop) self._time.start() self.updateTimer() self._timer.start(1000)
def createTitle(self): title = QLabel(self.bot1.name + ' vs ' + self.bot2.name) font = QFont() font.setBold(True) font.setPointSize(12) title.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) title.setFont(font) return title
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 createLabel(self, text): lbl = QLabel(text) lbl.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) font = QFont() font.setPointSize(12) lbl.setFont(font) return lbl
def createTitleLabel(self, title): titleLabel = QLabel(title) font = QFont() font.setBold(True) font.setPointSize(18) titleLabel.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) titleLabel.setFont(font) return titleLabel
def __init__(self, name, port, parent=None): super(ServerGame, self).__init__(parent) self.qBoard = QMacroBoard(self.onButtonClick) self.statusBar = QLabel() self.statusBar.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.statusBar.hide() self.titleBar = QLabel() self.titleBar.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.titleBar.hide() layout = QVBoxLayout() layout.addWidget(self.titleBar) layout.addWidget(self.qBoard) layout.addWidget(self.statusBar) self.setLayout(layout) self.server = game.players.human.ServerPlayer(name, port) self.opponentConnected = False self.board = None self.last_click = None self.qBoard.updateBoard(game.boards.Macroboard()) self.qBoard.setClickEnabled(False) self.requestThread = QThread() self.requestWorker = RequestHandler(self) self.requestWorker.waitingRequest.connect(self.waitingOpponentMessage) self.requestWorker.requestAccepted.connect(self.moveRequest) self.requestWorker.error.connect(self.serverError) self.requestWorker.moveToThread(self.requestThread) self.requestThread.started.connect(self.requestWorker.run) self.requestWorker.terminated.connect(self.requestThread.quit) self.requestThread.start()
def createTitleLabel(self, title): titleLabel = QLabel(title) titleLabel.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) return titleLabel
def _process_row(self, y, row): cols = self.columnCount() for x, i in enumerate(range(0, len(row), self._width)): block = row[i:i+self._width] item = QTableWidgetItem(codecs.encode(block, 'hex').decode()) item.setBackground(QBrush(QColor('lightgray'))) item.setForeground(QBrush(QColor('black'))) item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) item.setData(Qt.UserRole, block) # store original data if self._read_only: item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) else: item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable) self.setItem(y, x, item) # process remaining, unfilled cells for j in range(x+1, cols): item = QTableWidgetItem() item.setBackground(QBrush(QColor('white'))) item.setFlags(Qt.NoItemFlags) item.setTextAlignment(Qt.AlignHCenter) self.setItem(y, j, item) text = self._bytes_to_ascii(row) item = QTableWidgetItem(text) item.setData(Qt.UserRole, row) # store original data item.setTextAlignment(Qt.AlignLeft| Qt.AlignVCenter) item.setBackground(QBrush(QColor('lightblue'))) item.setForeground(QBrush(QColor('black'))) if self._read_only: item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) else: item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable) self.setItem(y, cols - 1, item)
def textAlign(self, action): if action == self.actionAlignLeft: self.textEdit.setAlignment(Qt.AlignLeft | Qt.AlignAbsolute) elif action == self.actionAlignCenter: self.textEdit.setAlignment(Qt.AlignHCenter) elif action == self.actionAlignRight: self.textEdit.setAlignment(Qt.AlignRight | Qt.AlignAbsolute) elif action == self.actionAlignJustify: self.textEdit.setAlignment(Qt.AlignJustify)
def alignmentChanged(self, alignment): if alignment & Qt.AlignLeft: self.actionAlignLeft.setChecked(True) elif alignment & Qt.AlignHCenter: self.actionAlignCenter.setChecked(True) elif alignment & Qt.AlignRight: self.actionAlignRight.setChecked(True) elif alignment & Qt.AlignJustify: self.actionAlignJustify.setChecked(True)
def createLabel(self, text): lbl = QLabel(text) lbl.setAlignment(Qt.AlignHCenter | Qt.AlignBottom) return lbl
def makeCourseLayout(self): try: if self.pListLayout.count() is not 0: while self.pListLayout.count(): item = self.pListLayout.takeAt(0) wid = item.widget() wid.deleteLater() except Exception as e: print(e) listPos = 0 for course in self.courseList: if len(course) is 0: break courseInfo = course.split(',') courseLabel = QtWidgets.QLabel(courseInfo[0]) startLabel = QtWidgets.QLabel(courseInfo[1]) endLabel = QtWidgets.QLabel(courseInfo[2]) countLabel = QtWidgets.QLabel(courseInfo[5]) courseLabel.setAlignment(Qt.AlignHCenter) startLabel.setAlignment(Qt.AlignHCenter) endLabel.setAlignment(Qt.AlignHCenter) countLabel.setAlignment(Qt.AlignHCenter) button = QtWidgets.QPushButton("??") button.clicked.connect(self.modify_test) self.pListLayout.addWidget(courseLabel, listPos, 0) self.pListLayout.addWidget(startLabel, listPos, 1) self.pListLayout.addWidget(endLabel, listPos, 2) self.pListLayout.addWidget(countLabel, listPos, 3) self.pListLayout.addWidget(button, listPos, 4) listPos += 1 self.ui.show()
def data(self, index: QModelIndex, role=Qt.DisplayRole): if not index.isValid(): return None i = index.row() j = index.column() if role == Qt.DisplayRole and self.display_data: try: if self.proto_view == 0: return self.display_data[i][j] elif self.proto_view == 1: return "{0:x}".format(self.display_data[i][j]) elif self.proto_view == 2: return chr(self.display_data[i][j]) except IndexError: return None elif role == Qt.TextAlignmentRole: if i in self.first_messages: return Qt.AlignHCenter + Qt.AlignBottom else: return Qt.AlignCenter elif role == Qt.BackgroundColorRole: return self.background_colors[i, j] elif role == Qt.FontRole: font = QFont() font.setBold(self.bold_fonts[i, j]) font.setItalic(self.italic_fonts[i, j]) return font elif role == Qt.TextColorRole: return self.text_colors[i, j] elif role == Qt.ToolTipRole: return self.get_tooltip(i, j) else: return None
def initUI(self): """ Initialize the Dialog layout. """ self.setWindowTitle('Checking update') self.setFixedSize(400, 120) self.setStyleSheet(""" QDialog { background: #F2F2F2; } """) ## INIT PROGRESS BAR self.progress = BusyProgressBar(self) self.progress.setAlignment(Qt.AlignHCenter) self.progress.start() ## INITIALIZE UPDATE CHANNEL self.channel = B3App.Instance().settings.value('update_channel') if self.channel not in (UPDATE_CHANNEL_STABLE, UPDATE_CHANNEL_BETA, UPDATE_CHANNEL_DEV): self.channel = getDefaultChannel(b3.__version__) ## INITIALIZE DEFAULT MESSAGE self.message = QLabel('connecting to update channel: %s' % self.channel, self) self.message.setAlignment(Qt.AlignHCenter) self.message.setWordWrap(True) self.message.setOpenExternalLinks(True) self.layout = QVBoxLayout() self.layout.addWidget(self.progress) self.layout.addWidget(self.message) self.layout.setAlignment(Qt.AlignCenter) self.setLayout(self.layout) self.setModal(True)
def _assemble_plot(self, qpainter): qpainter.save() #--- # draw bounding box qpainter.setPen(self._bbox_pen) qpainter.setBrush(self._bbox_brush) qpainter.drawRect(self._bbox_rect) # x-axis qpainter.setFont(self._labelFont) qpainter.setPen(self._axes_tick_pen) qpainter.setBrush(self._axes_tick_brush) for tick_line in self._xaxis_ticks: qpainter.drawLine(tick_line) for i in range(len(self._xaxis_ticks_text)): qpainter.drawText(self._xaxis_ticks_text_rect[i], Qt.AlignVCenter | Qt.AlignHCenter, self._xaxis_ticks_text[i]) # y-axis for tick_line in self._yaxis_ticks: qpainter.drawLine(tick_line) for i in range(len(self._yaxis_ticks_text)): qpainter.drawText(self._yaxis_ticks_text_rect[i], Qt.AlignVCenter | Qt.AlignHCenter, self._yaxis_ticks_text[i]) # x-axis origin qpainter.setPen(self._axes_origin_pen) qpainter.setBrush(self._axes_origin_brush) if self._xaxis_origin_x > self._bbox_x0 and self._xaxis_origin_x < self._bbox_x1: qpainter.drawLine(self._xaxis_origin_line) # y-axis origin if self._yaxis_origin_y > self._bbox_y0 and self._yaxis_origin_y < self._bbox_y1: qpainter.drawLine(self._yaxis_origin_line) # draw plots for plot_key in self._plot_points.keys(): qpainter.setPen(self._plot_pens[plot_key]) qpainter.setBrush(QBrush(Qt.NoBrush)) if self._plot_draw_method[plot_key] == 'line' and len(self._plot_points[plot_key]) > 1: qpainter.drawPolyline(QPolygonF(self._plot_points[plot_key])) else: for plot_point in self._plot_points[plot_key]: qpainter.drawPoint(plot_point) #--- qpainter.restore() # G E T T E R S / S E T T E R S #===========================================================================
def init_ui(self): # v.box box = QVBoxLayout() box.setSpacing(5) box2 = QVBoxLayout() box2.setSpacing(0) l1 = QLabel('Red Discord Bot', self) l1.setFont(QtGui.QFont("Times", 14)) box.addWidget(l1, 0, Qt.AlignTop) box.insertSpacing(1, 10) b1 = QPushButton("Start Red", self) b1.setMinimumWidth(100) box.addWidget(b1, 0, Qt.AlignHCenter) b2 = QPushButton("Start Red Loop", self) b2.setMinimumWidth(100) box.addWidget(b2, 0, Qt.AlignHCenter) box.insertSpacing(4, 10) b3 = QPushButton("Update Red", self) b3.setMinimumWidth(80) box2.addWidget(b3, 0, Qt.AlignHCenter) b4 = QPushButton("Install Requirements", self) b4.setMinimumWidth(120) box2.addWidget(b4, 0, Qt.AlignHCenter) b5 = QPushButton("Maintenance", self) b5.setMinimumWidth(100) box2.addWidget(b5, 0, Qt.AlignHCenter) # b2.setEnabled(False) box.setAlignment(Qt.AlignHCenter) box2.addStretch(5) box.addLayout(box2) self.setLayout(box) # binds b1.clicked.connect(lambda: self.startred(autorestart=False)) b2.clicked.connect(lambda: self.startred(autorestart=True)) b3.clicked.connect(lambda: self.switchwindow(window=UpdateWindow())) b4.clicked.connect(lambda: self.switchwindow(window=RequirementsWindow())) b5.clicked.connect(lambda: self.switchwindow(window=MaintenanceWindow())) # window self.setFixedSize(220, 210) self.setWindowIcon(QtGui.QIcon('red.ico')) self.setWindowTitle('Red Bot') self.show()
def init_ui(self): # v.box box = QVBoxLayout() box.setSpacing(5) box2 = QHBoxLayout() l1 = QLabel('Update', self) l1.setFont(QtGui.QFont("Times", 12)) box.addWidget(l1, 0, Qt.AlignHCenter) # box.insertSpacing(1, 10) l2 = QLabel("Red:", self) box.addWidget(l2, 0, Qt.AlignLeft) self.r1 = QRadioButton("Update Red + Requirements \n(recommended)") self.r1.setChecked(True) box.addWidget(self.r1, 0, Qt.AlignLeft) self.r2 = QRadioButton("Update Red") box.addWidget(self.r2, 0, Qt.AlignLeft) self.r3 = QRadioButton("Update Requirements") box.addWidget(self.r3, 0, Qt.AlignLeft) # box.insertSpacing(1, 10) l3 = QLabel("Others:", self) box.addWidget(l3, 0, Qt.AlignLeft) self.r4 = QRadioButton("Update PIP \n(Might require admin privileges)") box.addWidget(self.r4, 0, Qt.AlignLeft) # box.insertSpacing(1, 10) b1 = QPushButton("OK", self) b1.setMinimumWidth(100) box2.addWidget(b1, 0, Qt.AlignBottom) b2 = QPushButton("Cancel", self) b2.setMinimumWidth(100) box2.addWidget(b2, 0, Qt.AlignBottom) box.setAlignment(Qt.AlignHCenter) box.addLayout(box2) self.setLayout(box) # binds b1.clicked.connect(self.ok_clicked) b2.clicked.connect(self.switchwindow) # window self.setFixedSize(220, 210) self.setWindowIcon(QtGui.QIcon('red.ico')) self.setWindowTitle('Red Bot - Update') self.show()
def init_ui(self): # v.box box = QVBoxLayout() box.setSpacing(5) box2 = QHBoxLayout() l1 = QLabel('Red Requirements', self) l1.setFont(QtGui.QFont("Times", 12)) box.addWidget(l1, 0, Qt.AlignHCenter) # box.insertSpacing(1, 10) l2 = QLabel("Main Requirements", self) box.addWidget(l2, 0, Qt.AlignLeft) self.r1 = QRadioButton("Install basic + audio requirements \n(recommended)") self.r1.setChecked(True) box.addWidget(self.r1, 0, Qt.AlignLeft) self.r2 = QRadioButton("Install basic requirements") box.addWidget(self.r2, 0, Qt.AlignLeft) # box.insertSpacing(1, 10) l3 = QLabel("FFMPEG (required for audio)", self) box.addWidget(l3, 0, Qt.AlignLeft) self.r3 = QRadioButton("Install ffmpeg 32bit") box.addWidget(self.r3, 0, Qt.AlignLeft) self.r4 = QRadioButton("Install ffmpeg 64bit") box.addWidget(self.r4, 0, Qt.AlignLeft) # box.insertSpacing(1, 10) b1 = QPushButton("OK", self) b1.setMinimumWidth(100) box2.addWidget(b1, 0, Qt.AlignBottom) b2 = QPushButton("Cancel", self) b2.setMinimumWidth(100) box2.addWidget(b2, 0, Qt.AlignBottom) box.setAlignment(Qt.AlignHCenter) box.addLayout(box2) self.setLayout(box) # binds b1.clicked.connect(self.ok_clicked) b2.clicked.connect(self.switchwindow) # window self.setFixedSize(220, 210) self.setWindowIcon(QtGui.QIcon('red.ico')) self.setWindowTitle('Red Bot - Requirements') self.show()
def init_ui(self): # v.box box = QVBoxLayout() box.setSpacing(5) box2 = QHBoxLayout() l1 = QLabel('Maintenance', self) l1.setFont(QtGui.QFont("Times", 12)) box.addWidget(l1, 0, Qt.AlignHCenter) # box.insertSpacing(1, 10) l2 = QLabel("Repair:", self) box.addWidget(l2, 0, Qt.AlignLeft) self.r1 = QRadioButton("Repair Red \n(discards code changes, keeps data intact)") self.r1.setChecked(True) box.addWidget(self.r1, 0, Qt.AlignLeft) self.r2 = QRadioButton("Wipe 'data' folder \n(all settings, cogs' data...)") box.addWidget(self.r2, 0, Qt.AlignLeft) self.r3 = QRadioButton("Wipe 'lib' folder \n(all local requirements / local installed python packages)") box.addWidget(self.r3, 0, Qt.AlignLeft) self.r4 = QRadioButton("Factory reset") box.addWidget(self.r4, 0, Qt.AlignLeft) # box.insertSpacing(1, 10) b1 = QPushButton("OK", self) b1.setMaximumWidth(100) box2.addWidget(b1, 0, Qt.AlignBottom) b2 = QPushButton("Cancel", self) b2.setMaximumWidth(100) box2.addWidget(b2, 0, Qt.AlignBottom) box.setAlignment(Qt.AlignHCenter) box.addLayout(box2) self.setLayout(box) # binds b1.clicked.connect(self.ok_clicked) b2.clicked.connect(self.switchwindow) # window self.setFixedSize(320, 210) self.setWindowIcon(QtGui.QIcon('red.ico')) self.setWindowTitle('Red Bot - Maintenance') self.show()
def createTabDesktopTheme(self): self.tabDesktopTheme = QWidget() self.tabDesktopTheme.setObjectName("tabDesktopTheme") self.verticalLayout_4 = QVBoxLayout(self.tabDesktopTheme) self.verticalLayout_4.setObjectName("verticalLayout_4") self.listWidgetDesktopTheme = QListWidget(self.tabDesktopTheme) self.listWidgetDesktopTheme.setObjectName("listWidgetDesktopTheme") self.listWidgetDesktopTheme.setViewMode(QListView.IconMode) self.listWidgetDesktopTheme.setIconSize(QSize(240, 145)) self.listWidgetDesktopTheme.setResizeMode(QListView.Adjust) item = QListWidgetItem(self.listWidgetDesktopTheme) icon = QIcon(QPixmap(":/data/images/air_panel.png").scaled(QSize(240, 145), Qt.IgnoreAspectRatio, Qt.FastTransformation)) item.setSizeHint(QSize(240, 145)) item.setIcon(icon) item.panelText = "air" item = QListWidgetItem(self.listWidgetDesktopTheme) item.setTextAlignment(Qt.AlignHCenter) icon = QIcon(QPixmap(":/data/images/breeze_panel.png").scaled(QSize(240, 145), Qt.IgnoreAspectRatio, Qt.FastTransformation)) item.setSizeHint(QSize(240, 145)) item.setIcon(icon) item.panelText = "default" item = QListWidgetItem(self.listWidgetDesktopTheme) item.setTextAlignment(Qt.AlignHCenter) icon = QIcon(QPixmap(":/data/images/breeze-dark_panel.png").scaled(QSize(240, 145), Qt.IgnoreAspectRatio, Qt.FastTransformation)) item.setSizeHint(QSize(240, 145)) item.setIcon(icon) item.panelText = "breeze-dark" item = QListWidgetItem(self.listWidgetDesktopTheme) item.setTextAlignment(Qt.AlignHCenter) icon = QIcon(QPixmap(":/data/images/midna_panel.png").scaled(QSize(240, 145), Qt.IgnoreAspectRatio, Qt.FastTransformation)) item.setSizeHint(QSize(240, 145)) item.setIcon(icon) item.panelText = "midna" item = QListWidgetItem(self.listWidgetDesktopTheme) item.setTextAlignment(Qt.AlignHCenter) icon = QIcon(QPixmap(":/data/images/midna-dark_panel.png").scaled(QSize(240, 145), Qt.IgnoreAspectRatio, Qt.FastTransformation)) item.setSizeHint(QSize(240, 145)) item.setIcon(icon) item.panelText = "midna_dark" item = QListWidgetItem(self.listWidgetDesktopTheme) item.setTextAlignment(Qt.AlignHCenter) icon = QIcon(QPixmap(":/data/images/oxygen_panel.png").scaled(QSize(240, 145), Qt.IgnoreAspectRatio, Qt.FastTransformation)) item.setSizeHint(QSize(240, 145)) item.setIcon(icon) item.panelText = "oxygen" self.verticalLayout_4.addWidget(self.listWidgetDesktopTheme) self.addTab(self.tabDesktopTheme, self.tr("Desktop Theme"))
def __init__(self, parent, index): super(TimestampDialog, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose, True) self.setWindowFlags(dialogwindowflags) self.setWindowTitle(_("Timestamp")) self.index = index self.timestampdialoglayout = QVBoxLayout() self.groupboxlayout = QHBoxLayout() self.layout_h = QHBoxLayout() self.layout_h.setContentsMargins(1, 1, 1, 1) self.layout_m = QHBoxLayout() self.layout_m.setContentsMargins(1, 1, 1, 1) self.layout_s = QHBoxLayout() self.layout_s.setContentsMargins(1, 1, 1, 1) self.groupbox_h = QGroupBox(_("Hours"), self) self.groupbox_m = QGroupBox(_("Minutes"), self) self.groupbox_s = QGroupBox(_("Seconds"), self) self.spinbox_h = QSpinBox(self) self.spinbox_h.setMinimum(0) self.spinbox_h.setMaximum(99) self.spinbox_m = QSpinBox(self) self.spinbox_m.setMinimum(0) self.spinbox_m.setMaximum(59) self.spinbox_s = QSpinBox(self) self.spinbox_s.setMinimum(0) self.spinbox_s.setMaximum(59) self.layout_h.addWidget(self.spinbox_h) self.layout_m.addWidget(self.spinbox_m) self.layout_s.addWidget(self.spinbox_s) self.groupbox_h.setLayout(self.layout_h) self.groupbox_m.setLayout(self.layout_m) self.groupbox_s.setLayout(self.layout_s) self.groupboxlayout.addWidget(self.groupbox_h) self.groupboxlayout.addWidget(self.groupbox_m) self.groupboxlayout.addWidget(self.groupbox_s) self.acceptbutton = QPushButton(_("OK"), self) self.acceptbutton.clicked.connect(self.clickedAcceptButton) self.timestampdialoglayout.addLayout(self.groupboxlayout) self.timestampdialoglayout.addWidget(self.acceptbutton) self.timestampdialoglayout.setAlignment(self.groupboxlayout, Qt.AlignHCenter) self.timestampdialoglayout.setAlignment(self.acceptbutton, Qt.AlignHCenter) self.setLayout(self.timestampdialoglayout) timestamp = commentmodel.item(commentlistview.selectedIndexes()[0].row(), 0).text() str_h, str_m, str_s = timestamp.split(":") self.spinbox_h.setValue(int(str_h)) self.spinbox_m.setValue(int(str_m)) self.spinbox_s.setValue(int(str_s))
def initUI(self): """ Initialize the Central Widget user interface. """ def __get_top_layout(parent): image = ImageWidget(parent, B3_BANNER) layout = QHBoxLayout() layout.addWidget(image) layout.setAlignment(Qt.AlignTop) layout.setContentsMargins(0, 0, 0, 0) return layout def __get_middle_layout(parent): parent.main_table = MainTable(parent) parent.help_label = HelpLabel(parent.main_table) layout = QVBoxLayout() layout.addWidget(parent.main_table) #layout.addWidget(parent.help_label) layout.setAlignment(Qt.AlignHCenter | Qt.AlignTop) layout.setContentsMargins(0, 2, 0, 0) return layout def __get_bottom_layout(parent): parent.news = MarqueeLabel(parent) parent.news.parseFeed() btn_new = Button(parent=parent, text='Add', shortcut='Ctrl+N') btn_new.clicked.connect(self.parent().new_process_dialog) btn_new.setStatusTip('Add a new B3') btn_new.setVisible(True) btn_quit = Button(parent=parent, text='Quit', shortcut='Ctrl+Q') btn_quit.clicked.connect(B3App.Instance().shutdown) btn_quit.setStatusTip('Shutdown B3') btn_quit.setVisible(True) layout = QHBoxLayout() layout.addWidget(parent.news) layout.addWidget(btn_new) layout.addWidget(btn_quit) layout.setAlignment(Qt.AlignBottom | Qt.AlignRight) layout.setSpacing(10) layout.setContentsMargins(0, 0, 11, GEOMETRY[b3.getPlatform()]['CENTRAL_WIDGET_BOTTOM_LAYOUT_MARGIN_BOTTOM']) return layout main_layout = QVBoxLayout() main_layout.addLayout(__get_top_layout(self)) main_layout.addLayout(__get_middle_layout(self)) main_layout.addLayout(__get_bottom_layout(self)) main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout) self.setFixedSize(614, 512) self.setStyleSheet(""" QWidget, QDialog, QMessageBox { background: #F2F2F2; } """) self.setFocus()
def initUI(self): """ Initialize the Dialog layout. """ self.setWindowTitle(B3_LICENSE) self.setFixedSize(GEOMETRY[b3.getPlatform()]['LICENSE_DIALOG_WIDTH'], GEOMETRY[b3.getPlatform()]['LICENSE_DIALOG_HEIGHT']) self.setStyleSheet(""" QDialog { background: #F2F2F2; } """) def __get_top_layout(parent): message = """ %(COPYRIGHT)s<br/> <br/> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.<br/> <br/> This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.<br/> <br/> You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """ % dict(COPYRIGHT=B3_COPYRIGHT) label = QLabel(message, parent) label.setWordWrap(True) label.setOpenExternalLinks(True) label.setAlignment(Qt.AlignLeft) layout = QHBoxLayout() layout.addWidget(label) layout.setAlignment(Qt.AlignTop) layout.setContentsMargins(0, 0, 0, 0) return layout def __get_bottom_layout(parent): btn_close = Button(parent=parent, text='Close') btn_close.clicked.connect(parent.close) btn_close.setVisible(True) layout = QHBoxLayout() layout.addWidget(btn_close) layout.setAlignment(Qt.AlignHCenter|Qt.AlignTop) layout.setContentsMargins(0, 20, 0, 0) return layout main_layout = QVBoxLayout() main_layout.addLayout(__get_top_layout(self)) main_layout.addLayout(__get_bottom_layout(self)) self.setLayout(main_layout) self.setModal(True)
def initUI(self): """ Initialize the Dialog layout. """ self.setWindowTitle('B3 database update') self.setFixedSize(420, 160) self.setStyleSheet(""" QDialog { background: #F2F2F2; } """) ## INIT CLOSE BUTTON self.btn_close = Button(parent=self, text='Close') self.btn_close.clicked.connect(self.close) self.btn_close.hide() ## INIT UPDATE BUTTON self.btn_update = Button(parent=self, text='Update') self.btn_update.clicked.connect(self.do_update) self.btn_update.show() ## CREATE THE PROGRESS BAR self.progress = ProgressBar(self) self.progress.setAlignment(Qt.AlignHCenter) self.progress.hide() self.progress.setRange(0, 0) self.progress.setValue(-1) ## INIT DISPLAY MESSAGE self.message = QLabel("This tool will update all your B3 databases to version %s.\n" "The update process should take less than 2 minutes and\n" "cannot be interrupted." % b3.__version__, self) def __get_top_layout(parent): parent.layout1 = QVBoxLayout() parent.layout1.addWidget(parent.progress) parent.layout1.addWidget(parent.message) parent.layout1.setAlignment(Qt.AlignTop|Qt.AlignHCenter) parent.layout1.setContentsMargins(0, 0, 0, 0) return parent.layout1 def __get_bottom_layout(parent): parent.layout2 = QHBoxLayout() parent.layout2.addWidget(parent.btn_close) parent.layout2.addWidget(parent.btn_update) parent.layout2.setAlignment(Qt.AlignHCenter) parent.layout2.setSpacing(20 if b3.getPlatform() != 'win32' else 10) parent.layout2.setContentsMargins(0, 10, 0, 0) return parent.layout2 self.setModal(True) self.main_layout = QVBoxLayout() self.main_layout.addLayout(__get_top_layout(self)) self.main_layout.addLayout(__get_bottom_layout(self)) self.main_layout.setAlignment(Qt.AlignCenter) self.setLayout(self.main_layout)
def createTabDesktopTheme(self): self.tabDesktopTheme = QWidget() self.tabDesktopTheme.setObjectName("tabDesktopTheme") self.gridLayout = QGridLayout(self.tabDesktopTheme) self.gridLayout.setObjectName("gridLayout") self.listWidgetDesktopTheme = QListWidget(self.tabDesktopTheme) self.listWidgetDesktopTheme.setViewMode(QListView.IconMode) self.listWidgetDesktopTheme.setResizeMode(QListView.Adjust) self.listWidgetDesktopTheme.setIconSize(QSize(212, 129)) self.gridLayout.addWidget(self.listWidgetDesktopTheme, 0, 0, 1, 1) item = QListWidgetItem(self.listWidgetDesktopTheme) icon = QIcon(":/data/images/air-panel.png") item.setIcon(icon) item.panelText = "air" item = QListWidgetItem(self.listWidgetDesktopTheme) item.setTextAlignment(Qt.AlignHCenter) icon = QIcon(":/data/images/breeze-panel.png") item.setIcon(icon) item.panelText = "default" item = QListWidgetItem(self.listWidgetDesktopTheme) item.setTextAlignment(Qt.AlignHCenter) icon = QIcon(":/data/images/breeze-light-panel.png") item.setIcon(icon) item.panelText = "breeze-light" item = QListWidgetItem(self.listWidgetDesktopTheme) icon = QIcon(":/data/images/breeze-dark-panel.png") item.setIcon(icon) item.panelText = "breeze-dark" item = QListWidgetItem(self.listWidgetDesktopTheme) item.setTextAlignment(Qt.AlignHCenter) icon = QIcon(":/data/images/maia-panel.png") item.setIcon(icon) item.panelText = "maia" item = QListWidgetItem(self.listWidgetDesktopTheme) item.setTextAlignment(Qt.AlignHCenter) icon = QIcon(":/data/images/oxygen-panel.png") item.setIcon(icon) item.panelText = "oxygen" self.addTab(self.tabDesktopTheme, self.tr("Desktop Theme"))