我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt5.QtCore.Qt.AlignCenter()。
def __init__(self, ebeveyn=None): super(Son, self).__init__(ebeveyn) self.e = ebeveyn self.kapanacak_mi =False kutu = QGridLayout() self.setLayout(kutu) milis_logo = QLabel() milis_logo.setAlignment(Qt.AlignCenter) milis_logo.setPixmap(QPixmap("./resimler/milis-logo.svg")) kutu.addWidget(milis_logo,0,0,1,2) self.veda_label = QLabel() self.veda_label.setAlignment(Qt.AlignCenter) self.veda_label.setWordWrap(True) kutu.addWidget(self.veda_label,1,0,1,2) self.denemeye_devam = QRadioButton() self.denemeye_devam.setIcon(QIcon("./resimler/cik.svg")) self.denemeye_devam.setIconSize(QSize(50,50)) self.denemeye_devam.toggled.connect(self.degisti) kutu.addWidget(self.denemeye_devam,2,0,1,1) self.kapat = QRadioButton() self.kapat.setIcon(QIcon("./resimler/yeniden-baslat.svg")) self.kapat.setIconSize(QSize(50,50)) self.kapat.toggled.connect(self.degisti) kutu.addWidget(self.kapat,2,1,1,1) self.denemeye_devam.setChecked(True)
def fontValuePixmap(font): f = QFont(font) img = QImage(16, 16, QImage.Format_ARGB32_Premultiplied) img.fill(0) p = QPainter(img) p.setRenderHint(QPainter.TextAntialiasing, True) p.setRenderHint(QPainter.Antialiasing, True) f.setPointSize(13) p.setFont(f) t = QTextOption() t.setAlignment(Qt.AlignCenter) p.drawText(QRectF(0, 0, 16, 16), 'A', t) p.end() return QPixmap.fromImage(img)
def layout(self): """ """ main_layout = QW.QVBoxLayout(self) form_layout = QW.QFormLayout() version = pkg_resources.require("pytc-gui")[0].version name_label = QW.QLabel("pytc: GUI") name_font = name_label.font() name_font.setPointSize(20) name_label.setFont(name_font) name_label.setAlignment(Qt.AlignCenter) version_label = QW.QLabel("Version " + version) version_font = version_label.font() version_font.setPointSize(14) version_label.setFont(version_font) version_label.setAlignment(Qt.AlignCenter) author_info = QW.QLabel("Hiranmayi Duvvuri, Mike Harms") author_font = author_info.font() author_font.setPointSize(10) author_info.setFont(author_font) OK_button = QW.QPushButton("OK", self) OK_button.clicked.connect(self.close) main_layout.addWidget(name_label) main_layout.addWidget(version_label) main_layout.addWidget(author_info) main_layout.addWidget(OK_button) self.setWindowTitle("About")
def _makewidget(val, center=False): """ Small helper function that builds a TableWidgetItem and sets up the font the way we want""" out = QtWidgets.QTableWidgetItem(str(val)) out.setFlags(Qt.ItemIsEnabled) out.setFont(monospace) if(center): out.setTextAlignment(Qt.AlignCenter) return out
def initUI(self): self.ui = Ui_Home() self.ui.setupUi(self) self.setGeometry( QStyle.alignedRect( Qt.LeftToRight, Qt.AlignCenter, self.size(), qApp.desktop().availableGeometry() ) ) self.show() self.ui.searchButton.clicked.connect(self.onSearch) self.ui.searchTextbox.returnPressed.connect(self.onSearch) self.ui.torrentList.selectionModel().selectionChanged.connect(self.onTorrentSelect) self.ui.torrentInfoMagnetLink.linkActivated.connect(self.onLinkClick) self.ui.torrentInfoTorrentLink.linkActivated.connect(self.onLinkClick)
def __init__(self, parent, f=Qt.WindowCloseButtonHint): super(DirectDownload, self).__init__(parent, f) self.parent = parent self.setWindowTitle('Download Progress') self.setWindowModality(Qt.ApplicationModal) self.setMinimumWidth(485) self.setContentsMargins(20, 20, 20, 20) layout = QVBoxLayout() self.progress_label = QLabel(alignment=Qt.AlignCenter) self.progress = QProgressBar(self.parent) self.progress.setMinimum(0) self.progress.setMaximum(100) layout.addWidget(self.progress_label) layout.addWidget(self.progress) self.setLayout(layout)
def writeCommentListViewContents(comments, seconds=False): commentmodel.clear() for comment in comments: if not seconds: timestamp = QStandardItem(comment[0]) else: timestamp = QStandardItem(secondsToTimestamp(comment[0])) timestamp.setEditable(False) timestamp.setTextAlignment(Qt.AlignRight|Qt.AlignVCenter) commenttype = QStandardItem(comment[1]) commenttype.setEditable(False) commenttype.setTextAlignment(Qt.AlignCenter) commentmodel.appendRow([timestamp, commenttype, QStandardItem(comment[2])]) commentlistview.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch) resizeCommentListViewToContents()
def __init__(self, parent=None): """Display a dialog that shows application information.""" super(AboutDialog, self).__init__(parent) self.setWindowTitle('About') help_icon = pkg_resources.resource_filename('{{ cookiecutter.package_name }}.images', 'ic_help_black_48dp_1x.png') self.setWindowIcon(QIcon(help_icon)) self.resize(300, 200) author = QLabel('{{ cookiecutter.full_name }}') author.setAlignment(Qt.AlignCenter) icons = QLabel('Material design icons created by Google') icons.setAlignment(Qt.AlignCenter) github = QLabel('GitHub: {{ cookiecutter.github_username }}') github.setAlignment(Qt.AlignCenter) self.layout = QVBoxLayout() self.layout.setAlignment(Qt.AlignVCenter) self.layout.addWidget(author) self.layout.addWidget(icons) self.layout.addWidget(github) self.setLayout(self.layout)
def __init__(self, ebeveyn=None): super(Konum, self).__init__(ebeveyn) self.e = ebeveyn kutu = QGridLayout() kutu.setAlignment(Qt.AlignCenter) self.setLayout(kutu) self.bigli_label = QLabel() kutu.addWidget(self.bigli_label,0,0,1,2) self.harita = HaritaWidget(self) kutu.addWidget(self.harita,1,0,1,2) self.bolge_label = QLabel() kutu.addWidget(self.bolge_label,2,0,1,1) self.sehir_label = QLabel() kutu.addWidget(self.sehir_label,2,1,1,1) self.bolge_combo = QComboBox() self.bolge_combo.currentTextChanged.connect(self.sehir_combo_doldur) kutu.addWidget(self.bolge_combo,3,0,1,1) self.sehir_combo = QComboBox() self.sehir_combo.currentTextChanged.connect(self.sehir_combo_degisti) kutu.addWidget(self.sehir_combo,3,1,1,1) self.bolge_combo_doldur() self.bolge_combo.setCurrentText("Europe") self.sehir_combo.setCurrentText("Istanbul")
def __init__(self, parent, slider: VideoSlider): super(VideoSliderWidget, self).__init__(parent) self.parent = parent self.slider = slider self.loaderEffect = OpacityEffect() self.loaderEffect.setEnabled(False) self.setGraphicsEffect(self.loaderEffect) self.setContentsMargins(0, 0, 0, 0) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.layout().setStackingMode(QStackedLayout.StackAll) self.genlabel = QLabel(self.parent) self.genlabel.setContentsMargins(0, 0, 0, 14) self.genlabel.setPixmap(QPixmap(':/images/generating-thumbs.png')) self.genlabel.setAlignment(Qt.AlignCenter) self.genlabel.hide() sliderLayout = QGridLayout() sliderLayout.setContentsMargins(0, 0, 0, 0) sliderLayout.setSpacing(0) sliderLayout.addWidget(self.slider, 0, 0) sliderLayout.addWidget(self.genlabel, 0, 0) sliderWidget = QWidget(self.parent) sliderWidget.setLayout(sliderLayout) self.addWidget(sliderWidget)
def __init__(self, parent=None, flags=Qt.Dialog | Qt.FramelessWindowHint): super(VCProgressBar, self).__init__(parent, flags) self.parent = parent self.setWindowModality(Qt.ApplicationModal) self.setStyleSheet('QDialog { border: 2px solid #000; }') self._progress = QProgressBar(self) self._progress.setRange(0, 0) self._progress.setTextVisible(False) self._progress.setStyle(QStyleFactory.create('Fusion')) self._label = QLabel(self) self._label.setAlignment(Qt.AlignCenter) layout = QGridLayout() layout.addWidget(self._progress, 0, 0) layout.addWidget(self._label, 0, 0) self._timerprefix = QLabel('<b>Elapsed time:</b>', self) self._timerprefix.setObjectName('progresstimer') self._timervalue = QLabel(self) self._timervalue.setObjectName('progresstimer') timerlayout = QHBoxLayout() timerlayout.addWidget(self._timerprefix) timerlayout.addWidget(self._timervalue) self._timerwidget = QWidget(self) self._timerwidget.setLayout(timerlayout) self._timerwidget.hide() self._time = QTime() self._timer = QTimer(self) self._timer.timeout.connect(self.updateTimer) self.setLayout(layout) self.setFixedWidth(550)
def paint( self, painter: QPainter, option: QStyleOptionGraphicsItem, widget: QWidget): super().paint(painter, option, widget) painter.setPen(const.HeroNamePen) painter.setRenderHint(QPainter.Antialiasing) painter.drawText( QRectF( -self.width / 2 - 15, -self.offsetY - 14, self.width + 30, 14), Qt.AlignCenter, self.name)
def setAbilityButtonStyle(self): for i, (label, button) in enumerate(self.abilityButtons): label.setStyleSheet(const.AbilityLabelStyle) label.setAlignment(Qt.AlignCenter) if button.isEnabled(): button.setStyleSheet( const.AbilityButtonCommonStyle + const.AbilityButtonEnabledStyleList[i]) else: button.setStyleSheet( const.AbilityButtonCommonStyle + const.AbilityButtonDisabledStyle)
def __init__(self, path, parent=None): """Initialize the close page's configuration group.""" super(CloseTomb, self).__init__(parent) self.path = path layout = QVBoxLayout() close_group = QGroupBox('Close Tomb') close_layout = QVBoxLayout() self.close_all_button = QPushButton('Close All Tombs') self.close_all_button.setFixedWidth(200) self.force_close_button = QPushButton('Force Close Tombs') self.force_close_button.setFixedWidth(200) close_layout.addWidget(self.close_all_button, alignment=Qt.AlignCenter) close_layout.addWidget(self.force_close_button, alignment=Qt.AlignCenter) close_group.setLayout(close_layout) layout.addWidget(close_group) layout.addStretch(1) self.setLayout(layout) self.close_all_button.clicked.connect(lambda: wrapper.close_tombs(self.path)) self.force_close_button.clicked.connect(lambda: wrapper.slam_tombs(self.path))
def __init__(self, path, parent=None): """Initialize the list page's configuration group.""" super(ListTomb, self).__init__(parent) self.path = path layout = QVBoxLayout() list_group = QGroupBox('Active Tombs') list_layout = QVBoxLayout() self.tomb_list = QListWidget() self.update_list_button = QPushButton('Update') self.update_list_button.setFixedWidth(200) list_layout.addWidget(self.tomb_list) list_layout.addWidget(self.update_list_button, alignment=Qt.AlignCenter) list_group.setLayout(list_layout) layout.addWidget(list_group) self.setLayout(layout) self.update_list_button.clicked.connect(self.update_list_items)
def __init__(self, parent=None): super(self.__class__, self).__init__() self.parent = parent font = QFont() font.setPointSize(16) model = QStringListModel() model.setStringList(wordlist) completer = Completer() completer.setModel(model) self.setFont(font) self.setCompleter(completer) self.setAlignment(Qt.AlignCenter) #self.setPlaceholderText("Enter invite code")
def __init__(self, curse: CurseAPI): super().__init__() self.curse = curse self.setWindowTitle(translate("title.settings")) self.layout = QVBoxLayout(self) mmc_box = QGroupBox(translate("label.mmc.location")) mmc_layout = QHBoxLayout() mmc_box.setLayout(mmc_layout) self.mmcDir = QLineEdit(self.curse.baseDir) self.mmcDir.setReadOnly(True) self.mmcDir.setMinimumWidth(250) mmc_layout.addWidget(self.mmcDir, 0, Qt.AlignLeft) self.mmcEb = makeIconButton(self, "edit", translate("tooltip.mmc.change")) self.mmcEb.clicked.connect(partial(self.browse_clicked)) mmc_layout.addWidget(self.mmcEb, 0, Qt.AlignRight) self.layout.addWidget(mmc_box) analytics_box = QGroupBox(translate("label.analytics")) analytics_layout = QHBoxLayout() analytics_box.setLayout(analytics_layout) self.analyticsToggle = QCheckBox() self.analyticsToggle.setChecked(self.curse.db["analytics"]) self.analyticsToggle.setToolTip(translate("tooltip.toggle.analytics")) self.analyticsToggle.stateChanged.connect(self.analytics_toggle) analytics_layout.addWidget(self.analyticsToggle, 1, Qt.AlignCenter) self.layout.addWidget(analytics_box) self.show()
def __init__(self, refresh_signal, conflict_tags_message_dict, case_data_manager, *args, **kwargs): super().__init__(*args, **kwargs) self.refresh_signal = refresh_signal self.case_data_manager = case_data_manager ui_dir_path = os.path.dirname(__file__) ui_file_path = os.path.join(ui_dir_path, "conflict_tag.ui") uic.loadUi(ui_file_path, self) self.setWindowTitle("conflict tag") self.conflict_tags_message_dict = conflict_tags_message_dict self.set_conflict_tags_table_widget() config = Config() image = QImage(os.path.join(config.images, 'notice.png')) result = image.scaled(40, 40) self.notice_image_label.setPixmap(QPixmap.fromImage(result)) self.notice_image_label.setAlignment(Qt.AlignCenter) self.notice_text_label.setText( '?????????\n' '1???????????????????????????????\n' '2???????????????') # todo ?????? self.conflict_tags_submit_button.clicked.connect(self.conflict_tags_submit) self.button_style(self.conflict_tags_submit_button) self.cancel_submit_button.clicked.connect(self.cancel_submit) self.button_style(self.cancel_submit_button)
def __init__(self, parent=None): super().__init__() self.parent = parent self.setWindowTitle(self.tr("System Installation")) self.setLayout(QVBoxLayout()) self.slide_widget = SlideWidget() self.layout().addWidget(self.slide_widget) self.progress = QProgressBar() self.layout().addWidget(self.progress) self.desc_label = QLabel() self.desc_label.setAlignment(Qt.AlignCenter) self.layout().addWidget(self.desc_label) self.addSlides()
def __init__(self): super(MainWindow, self).__init__() self.setupUi(self) XmlSyntaxHighlighter(self.schemaView.document()) XmlSyntaxHighlighter(self.instanceEdit.document()) self.schemaSelection.addItem("Contact Schema") self.schemaSelection.addItem("Recipe Schema") self.schemaSelection.addItem("Order Schema") self.instanceSelection.addItem("Valid Contact Instance") self.instanceSelection.addItem("Invalid Contact Instance") self.schemaSelection.currentIndexChanged.connect(self.schemaSelected) self.instanceSelection.currentIndexChanged.connect(self.instanceSelected) self.validateButton.clicked.connect(self.validate) self.instanceEdit.textChanged.connect(self.textChanged) self.validationStatus.setAlignment(Qt.AlignCenter | Qt.AlignVCenter) self.schemaSelected(0) self.instanceSelected(0)
def paint(self, painter, event, elapsed): painter.fillRect(event.rect(), self.background) painter.translate(100, 100) painter.save() painter.setBrush(self.circleBrush) painter.setPen(self.circlePen) painter.rotate(elapsed * 0.030) r = elapsed / 1000.0 n = 30 for i in range(n): painter.rotate(30) radius = 0 + 120.0*((i+r)/n) circleRadius = 1 + ((i+r)/n)*20 painter.drawEllipse(QRectF(radius, -circleRadius, circleRadius*2, circleRadius*2)) painter.restore() painter.setPen(self.textPen) painter.setFont(self.textFont) painter.drawText(QRect(-50, -50, 100, 100), Qt.AlignCenter, "Qt")
def __init__(self, parent = None): super(DropArea, self).__init__(parent) self.setMinimumSize(200, 200) self.setFrameStyle(QFrame.Sunken | QFrame.StyledPanel) self.setAlignment(Qt.AlignCenter) self.setAcceptDrops(True) self.setAutoFillBackground(True) self.clear()
def __init__(self): super(Screenshot, self).__init__() self.screenshotLabel = QLabel() self.screenshotLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.screenshotLabel.setAlignment(Qt.AlignCenter) self.screenshotLabel.setMinimumSize(240, 160) self.createOptionsGroupBox() self.createButtonsLayout() mainLayout = QVBoxLayout() mainLayout.addWidget(self.screenshotLabel) mainLayout.addWidget(self.optionsGroupBox) mainLayout.addLayout(self.buttonsLayout) self.setLayout(mainLayout) self.shootScreen() self.delaySpinBox.setValue(5) self.setWindowTitle("Screenshot") self.resize(300, 200)
def make_button(self, filename, tooltip, alignment=Qt.AlignCenter): """ Description: Creates a QLabel which will contain an image and will simulate a button. No associated text will be shown. Arguments: 1. filename: The filename of the icon/image to show 2. tooltip: Some text to show as a tooltip to the image 3. alignment: Alignment of the button (center by default) Returns: The created QLabel button """ global STANDARDCELLCSS, IMGDIR filepath = '%s%s%s' % (IMGDIR, filename, '.png') icon = QImage(filepath) image = QLabel() image.setToolTip('<span style="color:#B9B900">%s</span>' % (tooltip)) image.setStyleSheet(STANDARDCELLCSS) image.setPixmap(QPixmap.fromImage(icon)) image.setAlignment(alignment) return image
def __init__(self): super().__init__() self.opened_image_path = None self.opened_image = None self.processed_image = None self.image_view = QLabel() self.image_view.setStyleSheet('QLabel { background-color : black; }') self.image_view.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) self.image_view.setAlignment(Qt.AlignCenter) self.combo_box = QComboBox() self.combo_box.addItems(tag_types) for i in range(len(tag_types)): self.combo_box.setItemData(i, QColor(*(ImageProcess.TAG_COLOR_LIST[i])), Qt.ForegroundRole) self.tag_edit = QLineEdit() self.title_edit = QLineEdit() self.desc_edit = QLineEdit() self.setup_ui()
def initUI(self): """ Initialize the Help label user interface. """ self.setText('drop your configuration(s) file here') self.setFixedSize(594, GEOMETRY[b3.getPlatform()]['MAIN_TABLE_HEIGHT']) self.setAlignment(Qt.AlignCenter) self.setVisible(len(B3App.Instance().processes) == 0) self.setAcceptDrops(True) self.setStyleSheet(""" QLabel { background: transparent; font-size: 20px; font-style: italic; color: #CCCCCC; } """) ############################################# EVENT HANDLERS #######################################################
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 initUI(self): """ Initialize the STDOutDialog layout. """ self.setWindowTitle('%s console' % self.process.name) self.setMinimumSize(800, 300) self.setStyleSheet(""" QDialog { background: #F2F2F2; } """) self.stdout = STDOutText(self) layout = QVBoxLayout(self) layout.addWidget(self.stdout) layout.setAlignment(Qt.AlignCenter) self.setLayout(layout) self.setModal(False) self.hide()
def make_tab4(self, parent): tab4 = QWidget(parent) tab4.inpos = {} tab4.inwells = {} tab4.in_c = 1 tab4.outpos = {} tab4.outwells = {} tab4.out_c = 1 tab4.layout = QGridLayout(tab4) tab4.layout.setVerticalSpacing(20) tab4.layout.setAlignment(Qt.AlignTop | Qt.AlignCenter) tab4.add_inwell_but = QPushButton("New Injection Well", tab4) tab4.add_inwell_but.clicked.connect(self.make_inwell) tab4.add_outwell_but = QPushButton("New Producer Well", tab4) tab4.add_outwell_but.clicked.connect(self.make_outwell) tab4.layout.addWidget(tab4.add_inwell_but, 1, 1) tab4.layout.addWidget(tab4.add_outwell_but, 2, 1) return tab4
def drawCellHeaderText(self, painter, rect): xMin, yMin, width, height = rect metrics = QFontMetrics(headerFont) minOffset = painter.pen().width() painter.setFont(headerFont) painter.setPen(cellMetricsTextColor) name = metrics.elidedText( self.glyph.name, Qt.ElideRight, width - 2) painter.drawText( 1, 0, width - 2, height - minOffset, Qt.TextSingleLine | Qt.AlignCenter | Qt.AlignBottom, name)
def set_automated_stocks(self): file_list = ["../data/sell_list.txt", "../data/buy_list.txt"] automated_stocks = [] try: for file in file_list: # utf-8? ??? ??? # cp949 ???? ????? encoding ?? with open(file, 'rt', encoding='utf-8') as f: stocks_list = f.readlines() automated_stocks += stocks_list except Exception as e: print(e) e.msg = "set_automated_stocks() ??" self.show_dialog('Critical', e) return # ??? ?? ?? cnt = len(automated_stocks) self.automatedStocksTable.setRowCount(cnt) # ???? ?? for i in range(cnt): stocks = automated_stocks[i].split(';') for j in range(len(stocks)): if j == 1: name = self.kiwoom.get_master_code_name(stocks[j].rstrip()) item = QTableWidgetItem(name) else: item = QTableWidgetItem(stocks[j].rstrip()) item.setTextAlignment(Qt.AlignVCenter | Qt.AlignCenter) self.automatedStocksTable.setItem(i, j, item) self.automatedStocksTable.resizeRowsToContents()
def __init__(self,parent): super(MyBar,self).__init__() self.parent = parent self.layout = QHBoxLayout() self.layout.setContentsMargins(0,5,10,0) self.title = QLabel("MyoSEMG") self.m_DragPosition = self.parent.pos() self.pushButtonClose = QPushButton("") self.pushButtonClose.setObjectName("pushButtonClose") self.pushButtonClose.clicked.connect(self.btn_close_clicked) self.pushButtonMinimize = QPushButton("") self.pushButtonMinimize.setObjectName("pushButtonMinimize") self.pushButtonMinimize.clicked.connect(self.btn_min_clicked) self.pushButtonMaximize = QPushButton("") self.pushButtonMaximize.setObjectName("pushButtonMaximize") self.pushButtonMaximize.clicked.connect(self.btn_max_clicked) self.title.setFixedHeight(14) self.title.setAlignment(Qt.AlignCenter) self.layout.addWidget(self.title) self.layout.addWidget(self.pushButtonMinimize) self.layout.addWidget(self.pushButtonMaximize) self.layout.addWidget(self.pushButtonClose) self.windowstyle = load_windowstyle() self.setStyleSheet(self.windowstyle) self.setLayout(self.layout) self.start = QPoint(0,0) self.pressing = False self.maxNormal = True
def __init__(self, parent=None, *args, **kwargs): super(WaitDialog, self).__init__(parent) self.label = QLabel(self) self.label.setAlignment(Qt.AlignCenter) self.setFixedSize(551, 401) self.setWindowOpacity(0.5) # set transparent self.setWindowFlags(Qt.Dialog | Qt.CustomizeWindowHint | Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground) # background transparent self.setContentsMargins(0, 0, 0, 0) config = Config() self.movie = QMovie(os.path.join(config.images, 'wait.gif')) self.label.setMovie(self.movie) self.movie.start()
def __init__(self, parent=None): super().__init__() self.parent = parent self.setWindowTitle(self.tr("Finish")) self.setLayout(QVBoxLayout()) titleText = QLabel() self.layout().addWidget(titleText) titleText.setAlignment(Qt.AlignCenter) titleText.setText(self.tr("<h1>All of the process is completed.</h1>")) descText = QLabel() descText.setWordWrap(True) descText.setAlignment(Qt.AlignCenter) descText.setText(self.tr("Lime GNU/Linux, has been installed successfully to your system.\nTo use the newly installed system " "you can restart or you can continue to use Lime GNU/Linux Live system.")) self.layout().addWidget(descText) hlayout = QHBoxLayout() self.layout().addLayout(hlayout) hlayout.addItem(QSpacerItem(40, 20, QSizePolicy.Preferred, QSizePolicy.Preferred)) restartButton = CustomButton() restartButton.setFlat(True) restartButton.setIcon(QIcon(":/images/restart.svg")) restartButton.setIconSize(QSize(128, 128)) restartButton.setFixedSize(130, 130) hlayout.addWidget(restartButton) hlayout.addItem(QSpacerItem(40, 20, QSizePolicy.Preferred, QSizePolicy.Preferred)) restartButton.clicked.connect(self.systemRestart)
def paintEvent(self, event): painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) for index in range(self._stick_count): if self.item_index >= index +1: painter.setPen(self.active_color) painter.setBrush(self.active_color) painter.drawRect(56+(index*100), 24, 76, 6) else: painter.setPen(self.passive_color) painter.setBrush(self.passive_color) painter.drawRect(56+(index*100), 24, 76, 6) for index in range(self._item_count): if self.item_index >= index: painter.setPen(self.active_color) painter.setBrush(self.active_color) painter.drawEllipse(32 + (index * 100), 16, 24, 24) painter.setPen(Qt.black) painter.drawText(32 + (index * 100), 16, 24, 84, Qt.AlignCenter | Qt.TextWordWrap | Qt.TextDontClip, self.parent.widget(index).windowTitle()) else: painter.setPen(self.passive_color) painter.setBrush(self.passive_color) painter.drawEllipse(32+(index*100), 16, 24, 24) painter.setPen(Qt.black) painter.drawText(32+(index*100), 16, 24, 84, Qt.AlignCenter | Qt.TextWordWrap | Qt.TextDontClip, self.parent.widget(index).windowTitle())
def createLabel(self, text): label = QLabel(text) label.setAlignment(Qt.AlignCenter) label.setMargin(2) label.setFrameStyle(QFrame.Box | QFrame.Sunken) return label
def rescale(self): fm = QFontMetricsF(self._font, self) maxRect = fm.boundingRect(QRectF(self.rect()), Qt.AlignCenter, str(self._maximum)) xscale = float(self.width())/maxRect.width() yscale = float(self.height())/maxRect.height() self._scale = min(xscale, yscale)
def paintEvent(self, event): super(TetrixBoard, self).paintEvent(event) painter = QPainter(self) rect = self.contentsRect() if self.isPaused: painter.drawText(rect, Qt.AlignCenter, "Pause") return boardTop = rect.bottom() - TetrixBoard.BoardHeight * self.squareHeight() for i in range(TetrixBoard.BoardHeight): for j in range(TetrixBoard.BoardWidth): shape = self.shapeAt(j, TetrixBoard.BoardHeight - i - 1) if shape != NoShape: self.drawSquare(painter, rect.left() + j * self.squareWidth(), boardTop + i * self.squareHeight(), shape) if self.curPiece.shape() != NoShape: for i in range(4): x = self.curX + self.curPiece.x(i) y = self.curY - self.curPiece.y(i) self.drawSquare(painter, rect.left() + x * self.squareWidth(), boardTop + (TetrixBoard.BoardHeight - y - 1) * self.squareHeight(), self.curPiece.shape())
def createPreviewGroupBox(self): self.previewGroupBox = QGroupBox("Preview") self.calendar = QCalendarWidget() self.calendar.setMinimumDate(QDate(1900, 1, 1)) self.calendar.setMaximumDate(QDate(3000, 1, 1)) self.calendar.setGridVisible(True) self.calendar.currentPageChanged.connect(self.reformatCalendarPage) self.previewLayout = QGridLayout() self.previewLayout.addWidget(self.calendar, 0, 0, Qt.AlignCenter) self.previewGroupBox.setLayout(self.previewLayout)
def alignmentChanged(self, index): if index == 0: self.alignmentLineEdit.setAlignment(Qt.AlignLeft) elif index == 1: self.alignmentLineEdit.setAlignment(Qt.AlignCenter) elif index == 2: self.alignmentLineEdit.setAlignment(Qt.AlignRight)
def createHeaderLabel(self, text): label = QLabel("<b>%s</b>" % text) label.setAlignment(Qt.AlignCenter) return label
def __init__(self, parent=None): super(MoviePlayer, self).__init__(parent) self.movie = QMovie(self) self.movie.setCacheMode(QMovie.CacheAll) self.movieLabel = QLabel("No movie loaded") self.movieLabel.setAlignment(Qt.AlignCenter) self.movieLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) self.movieLabel.setBackgroundRole(QPalette.Dark) self.movieLabel.setAutoFillBackground(True) self.currentMovieDirectory = '' self.createControls() self.createButtons() self.movie.frameChanged.connect(self.updateFrameSlider) self.movie.stateChanged.connect(self.updateButtons) self.fitCheckBox.clicked.connect(self.fitToWindow) self.frameSlider.valueChanged.connect(self.goToFrame) self.speedSpinBox.valueChanged.connect(self.movie.setSpeed) mainLayout = QVBoxLayout() mainLayout.addWidget(self.movieLabel) mainLayout.addLayout(self.controlsLayout) mainLayout.addLayout(self.buttonsLayout) self.setLayout(mainLayout) self.updateFrameSlider() self.updateButtons() self.setWindowTitle("Movie Player") self.resize(400, 400)
def __init__(self): super(MainWindow, self).__init__() widget = QWidget() self.setCentralWidget(widget) topFiller = QWidget() topFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.infoLabel = QLabel( "<i>Choose a menu option, or right-click to invoke a context menu</i>", alignment=Qt.AlignCenter) self.infoLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken) bottomFiller = QWidget() bottomFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) vbox = QVBoxLayout() vbox.setContentsMargins(5, 5, 5, 5) vbox.addWidget(topFiller) vbox.addWidget(self.infoLabel) vbox.addWidget(bottomFiller) widget.setLayout(vbox) self.createActions() self.createMenus() message = "A context menu is available by right-clicking" self.statusBar().showMessage(message) self.setWindowTitle("Menus") self.setMinimumSize(160,160) self.resize(480,320)