我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用PyQt5.QtCore.Qt.RightToLeft()。
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.centralWidget = QWidget() self.setCentralWidget(self.centralWidget) self.createGroupBox() listWidget = QListWidget() for le in MainWindow.listEntries: listWidget.addItem(self.tr(le)) mainLayout = QVBoxLayout() mainLayout.addWidget(self.groupBox) mainLayout.addWidget(listWidget) self.centralWidget.setLayout(mainLayout) exitAction = QAction(self.tr("E&xit"), self, triggered=QApplication.instance().quit) fileMenu = self.menuBar().addMenu(self.tr("&File")) fileMenu.setPalette(QPalette(Qt.red)) fileMenu.addAction(exitAction) self.setWindowTitle(self.tr("Language: %s") % self.tr("English")) self.statusBar().showMessage(self.tr("Internationalization Example")) if self.tr("LTR") == "RTL": self.setLayoutDirection(Qt.RightToLeft)
def optionsAccepted(self, id): if id == self.otherId: #MouseWidget self.page(1).execute() #ThemeWidget self.page(2).execute() #MenuWidget self.page(3).execute() #WallpaperWidget self.page(4).execute() #AvatarWidget self.page(5).execute() p = QProcess() p.startDetached("kquitapp5 plasmashell") p.waitForStarted(2000) p.startDetached("plasmashell") if id == self.sumId: self.setButtonText(QWizard.NextButton, self.tr("Apply Settings")) self.button(QWizard.NextButton).setIcon(QIcon.fromTheme("dialog-ok-apply")) self.summaryVisible.emit() else: self.setButtonText(QWizard.NextButton, self.tr("Next")) self.button(QWizard.NextButton).setIcon(QIcon.fromTheme("arrow-right")) self.button(QWizard.HelpButton).setLayoutDirection(Qt.RightToLeft) #def closeEvent(self, event): # desktop_file = os.path.join(os.environ["HOME"], ".config", "autostart", "kaptan.desktop") # if os.path.exists(desktop_file): # os.remove(desktop_file)
def layoutDirectionChanged(self, index): if index == 0: self.setLayoutDirection(Qt.LeftToRight) else: self.setLayoutDirection(Qt.RightToLeft)
def __init__(self): super().__init__() self.setWindowTitle(self.tr("Kaptan Desktop")) self.setWindowIcon(QIcon.fromTheme("kaptan")) self.setMinimumSize(850, 600) self.setMaximumSize(950, 720) #x = (QDesktopWidget().screen().width() - self.width())/2 #y = (QDesktopWidget().screen().height() - self.height())/2 #self.move(x, y) self.setPixmap(QWizard.LogoPixmap, QPixmap(":/data/images/logo.svg")) self.setWizardStyle(QWizard.ModernStyle) #self.setButtonText(QWizard.NextButton, self.tr("Next")) #self.button(QWizard.NextButton).setIcon(QIcon.fromTheme("arrow-right")) #self.button(QWizard.NextButton).setLayoutDirection(Qt.RightToLeft) self.setButtonText(QWizard.CancelButton, self.tr("Cancel")) self.button(QWizard.CancelButton).setIcon(QIcon.fromTheme("dialog-cancel")) self.setOption(QWizard.NoCancelButtonOnLastPage, True) self.setOption(QWizard.CancelButtonOnLeft, False) #self.setOption(QWizard.HaveHelpButton, True) self.setButtonText(QWizard.BackButton, self.tr("Back")) self.setOption(QWizard.NoBackButtonOnLastPage, True) self.setOption(QWizard.NoBackButtonOnStartPage, True) self.button(QWizard.BackButton).setIcon(QIcon.fromTheme("arrow-left")) self.setButtonText(QWizard.FinishButton, self.tr("Finish")) self.button(QWizard.FinishButton).setIcon(QIcon.fromTheme("dialog-ok-apply")) self.addPage(WelcomeWidget(self)) self.addPage(MouseWidget(self)) self.addPage(ThemeWidget(self)) self.addPage(MenuWidget(self)) self.addPage(WallpaperWidget(self)) self.addPage(AvatarWidget(self)) #self.addPage(PMWidget()) FIXME self.sumId = self.addPage(SummaryWidget(self)) self.otherId = self.addPage(OtherWidget(self)) self.currentIdChanged.connect(self.optionsAccepted) self.button(QWizard.FinishButton).clicked.connect(self.close)
def __init__(self): super().__init__() self.setWindowTitle(self.tr("Kaptan Desktop")) self.setWindowIcon(QIcon.fromTheme("kaptan-icon")) self.setMinimumSize(850, 600) self.setMaximumSize(950, 620) x = (QDesktopWidget().screen().width() - self.width())/2 y = (QDesktopWidget().screen().height() - self.height())/2 self.move(x, y) self.setPixmap(QWizard.LogoPixmap, QPixmap(":/data/images/kaptan.png")) self.setButtonText(QWizard.NextButton, self.tr("Next")) self.button(QWizard.NextButton).setIcon(QIcon.fromTheme("arrow-right")) self.button(QWizard.NextButton).setLayoutDirection(Qt.RightToLeft) self.setButtonText(QWizard.CancelButton, self.tr("Cancel")) self.button(QWizard.CancelButton).setIcon(QIcon.fromTheme("dialog-cancel")) self.setOption(QWizard.NoCancelButtonOnLastPage, True) self.setOption(QWizard.CancelButtonOnLeft, True) self.setButtonText(QWizard.BackButton, self.tr("Back")) self.setOption(QWizard.NoBackButtonOnLastPage, True) self.setOption(QWizard.NoBackButtonOnStartPage, True) self.button(QWizard.BackButton).setIcon(QIcon.fromTheme("arrow-left")) self.setButtonText(QWizard.FinishButton, self.tr("Finish")) self.button(QWizard.FinishButton).setIcon(QIcon.fromTheme("dialog-ok-apply")) self.addPage(WelcomeWidget(self)) self.addPage(MouseWidget(self)) self.addPage(ThemeWidget(self)) self.addPage(MenuWidget(self)) self.addPage(WallpaperWidget(self)) self.addPage(AvatarWidget(self)) #self.addPage(PMWidget()) FIXME self.sumId = self.addPage(SummaryWidget(self)) self.otherId = self.addPage(OtherWidget(self)) self.currentIdChanged.connect(self.optionsAccepted) self.button(QWizard.FinishButton).clicked.connect(self.close)