当前位置: 首页>>代码示例>>Python>>正文


Python Ui_MainWindow.retranslateUi方法代码示例

本文整理汇总了Python中ui_mainwindow.Ui_MainWindow.retranslateUi方法的典型用法代码示例。如果您正苦于以下问题:Python Ui_MainWindow.retranslateUi方法的具体用法?Python Ui_MainWindow.retranslateUi怎么用?Python Ui_MainWindow.retranslateUi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ui_mainwindow.Ui_MainWindow的用法示例。


在下文中一共展示了Ui_MainWindow.retranslateUi方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: retranslateUi

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import retranslateUi [as 别名]
 def retranslateUi(self, MainWindow):
     Ui_MainWindow.retranslateUi(self, MainWindow)
     MainWindow.setWindowTitle(self.tr("MainWindow").arg("PySPA"))
开发者ID:andreas-koukorinis,项目名称:PySPA,代码行数:5,代码来源:mainwindow.py

示例2: MainWindow

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import retranslateUi [as 别名]
class MainWindow(QtGui.QMainWindow):
    def __init__(self, parent = None, flags = 0):
        super(MainWindow, self).__init__(parent, QtCore.Qt.WindowFlags(flags))
        self.languages = QtGui.QMenu()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.fillLanguages()
        self.retranslate()

    def changeEvent(self, event):
        if event.type() == QtCore.QEvent.LanguageChange:
            # all designed forms have a retranslateUi() method
            self.ui.retranslateUi(self)
            # retranslate other widgets which weren't added in the designer
            self.retranslate()
        super(MainWindow, self).changeEvent(event)

    @QtCore.pyqtSlot(QtGui.QAction)
    def setLanguage(self, action):
        Application.setLanguage(action.data())

    def fillLanguages(self):
        self.languages = self.menuBar().addMenu("")
        # make a group of language actions
        actions = QtGui.QActionGroup(self)
        actions.triggered.connect(self.setLanguage)
        system = QtCore.QLocale.system()
        default = None
        for lang in Application.availableLanguages():
            # figure out nice names for locales
            locale = QtCore.QLocale(lang)
            language = QtCore.QLocale.languageToString(locale.language())
            country = QtCore.QLocale.countryToString(locale.country())
            name = "%s (%s)" % (language, country)
            # create an action
            action = self.languages.addAction(name)
            action.setData(lang)
            action.setCheckable(True)
            if lang == system.name():
                # language match the current system
                action.setChecked(True)
                Application.setLanguage(lang)
                default = lang
            actions.addAction(action)
        if default is None:
            # no exact match found, try language only
            for lang in Application.availableLanguages():
                locale = QtCore.QLocale(lang)
                if locale.language() == system.language():
                    # at least a language match
                    for action in actions.actions():
                        if lang == action.data():
                            # use first entry of this language
                            action.setChecked(True)
                            Application.setLanguage(lang)
                            default = lang
                            break
                    if default is not None:
                        break
        return default

    def retranslate(self):
        self.languages.setTitle(self.tr("Language"))
开发者ID:AlexDoul,项目名称:PyQt4,代码行数:65,代码来源:lang.py


注:本文中的ui_mainwindow.Ui_MainWindow.retranslateUi方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。