本文整理匯總了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_()