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


Python QApplication.installTranslator方法代码示例

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


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

示例1: main

# 需要导入模块: from PySide2.QtWidgets import QApplication [as 别名]
# 或者: from PySide2.QtWidgets.QApplication import installTranslator [as 别名]
def main():

    if parser.lang:
        sys_locale = parser.lang[0]
    else:
        sys_locale = QtCore.QLocale.system().name()
    translator = QtCore.QTranslator()

    #load intern dialogs translations
    qtTranslator = QtCore.QTranslator()
    qtTranslator.load("qt_" + sys_locale, QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath))

    #load translations files
    translations_path = os.path.join(os.getenv("PINGUINO_LIB"), "multilanguage")
    trasnlations = os.path.exists(translations_path)

    if trasnlations and (os.getenv("PINGUINO_MODE") == "NORMAL"):
        translations_file = "pinguino_" + sys_locale

        if translations_file + ".qm" in os.listdir(translations_path):
            translator.load(os.path.join(os.getenv("PINGUINO_LIB"), "multilanguage", "pinguino_{}.qm".format(sys_locale)))

        elif "_" in sys_locale:
            sys_locale = sys_locale[:sys_locale.find("_")]
            translations_file = "pinguino_" + sys_locale
            if translations_file + ".qm" in os.listdir(translations_path):
                translator.load(os.path.join(os.getenv("PINGUINO_LIB"), "multilanguage", "pinguino_{}.qm".format(sys_locale)))

    app = QApplication(sys.argv)

    #Splash (pinguino\qtgui\resources\art)
    #pixmap = QPixmap(":/logo/art/splash.png")
    pixmap = QPixmap("pinguino/qtgui/resources/art/splash.png")
    #pixmap = QPixmap("pinguino/qtgui/resources/art/pinguino_logo_background_blue-256x256.png")
    #pixmap = QPixmap(760, 256)
    #pixmap.fill(QtGui.QColor("#4d4d4d"))
    # keep the splash screen above all the other windows on the desktop
    splash = QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint)

    splash.show()
    splash.setStyleSheet("""
        font-family: inherit;
        font-weight: normal;
        font-size: 11pt;
        """)

    # update the splash screen with messages
    def splash_write(msg):
        if not splash is None:
            splash.showMessage("\t" + msg, color=QtGui.QColor("#4d4d4d"), alignment=QtCore.Qt.AlignBottom)

    splash_write(NAME + " " + MAJOR)
    app.processEvents()

    app.installTranslator(qtTranslator)
    if trasnlations:
        app.installTranslator(translator)

    frame = PinguinoIDE(splash_write=splash_write)
    frame.show()

    if not splash is None:
        splash.finish(frame)

    app.exec_()
开发者ID:PinguinoIDE,项目名称:pinguino-ide,代码行数:67,代码来源:pinguino.py


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