當前位置: 首頁>>代碼示例>>Python>>正文


Python QLocale.system方法代碼示例

本文整理匯總了Python中PyQt5.QtCore.QLocale.system方法的典型用法代碼示例。如果您正苦於以下問題:Python QLocale.system方法的具體用法?Python QLocale.system怎麽用?Python QLocale.system使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtCore.QLocale的用法示例。


在下文中一共展示了QLocale.system方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: UItranslations

# 需要導入模塊: from PyQt5.QtCore import QLocale [as 別名]
# 或者: from PyQt5.QtCore.QLocale import system [as 別名]
def UItranslations(self):
        """ Get list of available ui translations
        """
        # iterate over resource file to find available translations
        fltr = QDir.Dirs | QDir.Files | QDir.Hidden
        iterator = QDirIterator(':', fltr, QDirIterator.Subdirectories)
        while iterator.hasNext():
            filePath = iterator.next()
            if '/translations/ts/' in filePath:
                fileName  = os.path.basename(str(filePath[1:]))
                locale = fileName.replace('lector_','').replace('.qm', '')
                if locale:
                    self.ui.cbLang.addItem(locale)
        locale = settings.get('ui:lang')
        if not locale:
            locale = QLocale.system().name()
        currentIndex = self.ui.cbLang.findText(locale)
        if currentIndex <= -1:
            currentIndex = self.ui.cbLang.findText('en_GB')
        self.ui.cbLang.setCurrentIndex(currentIndex) 
開發者ID:zdenop,項目名稱:lector,代碼行數:22,代碼來源:settingsdialog.py

示例2: load

# 需要導入模塊: from PyQt5.QtCore import QLocale [as 別名]
# 或者: from PyQt5.QtCore.QLocale import system [as 別名]
def load(self, *args, default_path=None):
        """
        Loads a Python (or other supported) file from the file system or
        extracts a Python script from a hex file.
        """
        # Get all supported extensions from the different modes
        extensions = ["py"]
        for mode_name, mode in self.modes.items():
            if mode.file_extensions:
                extensions += mode.file_extensions
        extensions = set([e.lower() for e in extensions])
        extensions = "*.{} *.{}".format(
            " *.".join(extensions), " *.".join(extensions).upper()
        )
        folder = self.get_dialog_directory(default_path)
        allow_previous = not bool(default_path)
        path = self._view.get_load_path(
            folder, extensions, allow_previous=allow_previous
        )
        if path:
            self.current_path = os.path.dirname(os.path.abspath(path))
            self._load(path) 
開發者ID:mu-editor,項目名稱:mu,代碼行數:24,代碼來源:logic.py

示例3: get_default_locale

# 需要導入模塊: from PyQt5.QtCore import QLocale [as 別名]
# 或者: from PyQt5.QtCore.QLocale import system [as 別名]
def get_default_locale():
    return QLocale.system() 
開發者ID:Bertrand256,項目名稱:dash-masternode-tool,代碼行數:4,代碼來源:app_utils.py

示例4: getDictionaryPath

# 需要導入模塊: from PyQt5.QtCore import QLocale [as 別名]
# 或者: from PyQt5.QtCore.QLocale import system [as 別名]
def getDictionaryPath(self):
        dicPath = os.path.join(Resources.SPELL_DICT_PATH, QLocale.system().name())
        if self.dictionaryExists(dicPath):
            return dicPath
        return '' 
開發者ID:raelgc,項目名稱:scudcloud,代碼行數:7,代碼來源:speller.py

示例5: get_locale_language

# 需要導入模塊: from PyQt5.QtCore import QLocale [as 別名]
# 或者: from PyQt5.QtCore.QLocale import system [as 別名]
def get_locale_language():
    return QLocale.system().name()[:2].lower() 
開發者ID:Scille,項目名稱:parsec-cloud,代碼行數:4,代碼來源:desktop.py

示例6: getLang

# 需要導入模塊: from PyQt5.QtCore import QLocale [as 別名]
# 或者: from PyQt5.QtCore.QLocale import system [as 別名]
def getLang(cls):
        """根據配置文件讀取語言配置,如果沒有找到當前係統配置
        :return:
        """
        config = Config.current()
        Language.lang = config["general.language"]

        if not Language.lang.strip():
            # import locale
            # lang,country=locale.getdefaultlocale()
            Language.lang = QLocale.system().name()  # 語言_國家”形式形成的字符串,比如zh_CN。
            # QLocale.languageToString(QLocale.system().language()) #語言英文名稱,比如English,Chinese
            # QLocale.system().nativeLanguageName() #語言自身的寫法比如:中文(簡體)
        return Language.lang 
開發者ID:hustlei,項目名稱:QssStylesheetEditor,代碼行數:16,代碼來源:language.py

示例7: setTrans

# 需要導入模塊: from PyQt5.QtCore import QLocale [as 別名]
# 或者: from PyQt5.QtCore.QLocale import system [as 別名]
def setTrans(cls):
        """根據配置文件(如果沒有就根據當前係統語言)設置當前語言包
        """
        langs = Language.getLangs()
        lang = Language.getLang()
        qmfile = None
        for l in langs:
            if lang in (l["lang"], l["lang"].replace("-", "_")):
                qmfile = l["qmfile"]
                break
        if qmfile is None:
            lang = "en"
        try:
            if lang == "en":
                # qApp.removeTranslator(self.qmfile)
                # qApp.removeTranslator(self.trans_sys)
                pass
            else:
                transdir = os.path.dirname(__file__)
                if os.path.exists(os.path.join(transdir, qmfile)):
                    Language.trans.load(qmfile, transdir)
                    QApplication.installTranslator(Language.trans)
        except Exception as Argument:
            print(Argument)

        systransdir = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
        try:
            if Language.systrans.load("qt_" + QLocale(lang).name(), systransdir):
                QApplication.installTranslator(Language.systrans)
            if Language.systrans.load("qscintilla_" + QLocale(lang).name(), systransdir):
                QApplication.installTranslator(Language.systrans)
        except Exception:
            Language.systrans.load("qt_" + QLocale.system().name(), systransdir)
            QApplication.installTranslator(Language.systrans) 
開發者ID:hustlei,項目名稱:QssStylesheetEditor,代碼行數:36,代碼來源:language.py

示例8: get_admin_file_path

# 需要導入模塊: from PyQt5.QtCore import QLocale [as 別名]
# 或者: from PyQt5.QtCore.QLocale import system [as 別名]
def get_admin_file_path(filename):
    """
    Given an admin related filename, this function will attempt to get the
    most relevant version of this file (the default location is the application
    data directory, although a file of the same name in the same directory as
    the application itself takes preference). If this file isn't found, an
    empty one is created in the default location.
    """
    # App location depends on being interpreted by normal Python or bundled
    app_path = sys.executable if getattr(sys, "frozen", False) else sys.argv[0]
    app_dir = os.path.dirname(os.path.abspath(app_path))
    # The os x bundled application is placed 3 levels deep in the .app folder
    if platform.system() == "Darwin" and getattr(sys, "frozen", False):
        app_dir = os.path.dirname(os.path.dirname(os.path.dirname(app_dir)))
    file_path = os.path.join(app_dir, filename)
    if not os.path.exists(file_path):
        file_path = os.path.join(DATA_DIR, filename)
        if not os.path.exists(file_path):
            try:
                with open(file_path, "w") as f:
                    logger.debug("Creating admin file: {}".format(file_path))
                    json.dump({}, f)
            except FileNotFoundError:
                logger.error(
                    "Unable to create admin file: {}".format(file_path)
                )
    return file_path 
開發者ID:mu-editor,項目名稱:mu,代碼行數:29,代碼來源:logic.py

示例9: show_help

# 需要導入模塊: from PyQt5.QtCore import QLocale [as 別名]
# 或者: from PyQt5.QtCore.QLocale import system [as 別名]
def show_help(self):
        """
        Display browser based help about Mu.
        """
        language_code = QLocale.system().name()[:2]
        major_version = ".".join(__version__.split(".")[:2])
        url = "https://codewith.mu/{}/help/{}".format(
            language_code, major_version
        )
        logger.info("Showing help at %r.", url)
        webbrowser.open_new(url) 
開發者ID:mu-editor,項目名稱:mu,代碼行數:13,代碼來源:logic.py


注:本文中的PyQt5.QtCore.QLocale.system方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。