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


Python QCoreApplication.translate方法代码示例

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


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

示例1: read

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
 def read(self, fileName):
     self.state = PluginState.Invalid
     self.hasError = False
     self.dependencies = []
     specFile = QFile(fileName)
     if not specFile.exists():
         msg = QCoreApplication.translate(None, "File does not exist: {name}")
         return self.__reportError(msg.format(name=specFile.fileName()))
     if not specFile.open(QIODevice.ReadOnly):
         msg = QCoreApplication.translate(None, "Could not open file for read: {name}")
         return self.__reportError(msg.format(name=specFile.fileName()))
     fileInfo = QFileInfo(specFile)
     self.location = fileInfo.absolutePath()
     self.filePath = fileInfo.absoluteFilePath()
     reader = QXmlStreamReader(specFile)
     while not reader.atEnd():
         reader.readNext()
         tokenType = reader.tokenType()
         if tokenType is QXmlStreamReader.StartElement:
             self.__readPluginSpec(reader)
         else:
             pass
     if reader.hasError():
         msg = QCoreApplication.translate(None, "Error parsing file {0}: {1}, at line {2}, column {3}")
         return self.__reportError(msg.format(specFile.fileName(), reader.errorString(),
                                              reader.lineNumber(), reader.columnNumber()))
     self.state = PluginState.Read
     return True
开发者ID:nichollyn,项目名称:libspark,代码行数:30,代码来源:pluginspec.py

示例2: resolveDependencies

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
    def resolveDependencies(self, specs):
        if self.hasError:
            return False
        if self.state is PluginState.Resolved:
            # Go back, so we just re-resolve the dependencies.
            self.state = PluginState.Read
        if self.state is not PluginState.Read:
            self.errorString = QCoreApplication.translate(None, "Resolving dependencies failed because state != Read")
            self.hasError = True
            return False
        resolvedDependencies = []
        for dependency in self.dependencies:
            found = None
            for spec in specs:
                if spec.provides(dependency.name, dependency.version):
                    found = spec
                    spec.private.addProvidesForPlugin(self.pluginSpec)
                    break
            if not found:
                self.hasError = True
                if self.errorString:
                    self.errorString += "\n"
                msg = QCoreApplication.translate(None, "Could not resolve dependency {0}({1})")
                self.errorString += msg.format(dependency.name, dependency.version)
                continue
            resolvedDependencies.append(found)
        if self.hasError:
            return False

        self.dependencySpecs = resolvedDependencies
        self.state = PluginState.Resolved
        return True
开发者ID:nichollyn,项目名称:libspark,代码行数:34,代码来源:pluginspec.py

示例3: formatUptime

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
 def formatUptime(time):
     s = ''
     loc = QLocale()
     if time.days > 0:
         d = QCoreApplication.translate('ifmon', 'days') if time.days > 1 \
                 else QCoreApplication.translate('ifmon', 'day')
         s = '%s %s, ' % (loc.toString(time.days), d)
     mm, ss = divmod(time.seconds, 60)
     hh, mm = divmod(mm, 60)
     def padded(d):
         if d < 10:
             return loc.toString(0) + loc.toString(d)
         else:
             return loc.toString(d)
     s += '%s:%s:%s' % (padded(hh), padded(mm), padded(ss))
     return s
开发者ID:marchon,项目名称:ifmon,代码行数:18,代码来源:tablemodel.py

示例4: __init__

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
 def __init__(self, parent=None):
     super(BandwidthTableModel, self).__init__(parent)
     self.header = [
         QCoreApplication.translate('ifmon', 'Booted at'),
         QCoreApplication.translate('ifmon', 'Uptime'),
         QCoreApplication.translate('ifmon', 'Recieved'),
         QCoreApplication.translate('ifmon', 'Transmitted'),
         QCoreApplication.translate('ifmon', 'Total')
     ]
     for settings in Settings.select():
         self.settings = settings
         break
     else:
         now = datetime.now()
         start = datetime(year=now.year, month=now.month, day=1)
         self.settings = Settings(start=start)
     self.populateData()
开发者ID:marchon,项目名称:ifmon,代码行数:19,代码来源:tablemodel.py

示例5: checkForUnknownOption

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
 def checkForUnknownOption(self):
     if '-' not in self.currentArg:
         return False
     self.lastError = QCoreApplication.translate(None,
                                                 "Unknown option '{name}'"
                                                 .format(self.currentArg))
     self.hasError = True
     return True
开发者ID:nichollyn,项目名称:libspark,代码行数:10,代码来源:optionsparser.py

示例6: initializeExtensions

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
 def initializeExtensions(self):
     if self.hasError:
         return False
     if self.state is not PluginState.Initialized:
         if self.state is PluginState.Running:
             return True
         self.errorString = QCoreApplication.translate(None,
                                                       "Cannot perform extensionsInitialized "
                                                       "because state != Initialized")
         self.hasError = True
         return False
     if not self.plugin:
         self.errorString = QCoreApplication.translate(None,
                                                       "Internal error: have no plugin instance "
                                                       " perform extensionInitialized")
         self.hasError = True
         return False
     self.plugin.extensionsInitialized()
     self.state = PluginState.Running
     return True
开发者ID:nichollyn,项目名称:libspark,代码行数:22,代码来源:pluginspec.py

示例7: nextToken

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
 def nextToken(self, tokenType=TokenType.OptionalToken):
     if self.nextTokenIndex == self.argsLength:
         if tokenType is TokenType.RequiredToken:
             self.hasError = True
             self.lastError = QCoreApplication.translate(None,
                                                         "The option {arg} requires an argument"
                                                             .format(arg=self.currentArg))
         return False
     self.currentArg = self.args[self.nextTokenIndex]
     self.nextTokenIndex += 1
     return True
开发者ID:nichollyn,项目名称:libspark,代码行数:13,代码来源:optionsparser.py

示例8: loadLibrary

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
 def loadLibrary(self):
     if self.hasError:
         return False
     if self.state is not PluginState.Resolved:
         if self.state is PluginState.Loaded:
             return True
         self.errorString = QCoreApplication.translate(None, "Loading the library failed because state != Resolved")
         self.hasError = True
         return False
     pluginPath = QDir.toNativeSeparators(self.location)
     pluginClass = pluginloader.loadIPlugin(pluginPath, self.name + "." + self.mainClass)
     if not pluginClass:
         self.hasError = True
         self.errorString = QCoreApplication.translate(None,
                                                       "Plugin is not valid (does not derive from IPlugin")
         return False
     self.state = PluginState.Loaded
     self.plugin = pluginClass(self.manager)
     self.plugin.private.pluginSpec = self.pluginSpec
     return True
开发者ID:nichollyn,项目名称:libspark,代码行数:22,代码来源:pluginspec.py

示例9: main

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
def main():
    app = QApplication(sys.argv)
    if not ei.initialized:
        msg = QCoreApplication.translate(
            pkginfo.package_name,
            "Dependencies of '{0}' are not ready. \n\n".format(pkginfo.package_name) +
            "Test 'initialized' value in '_easy_import_' to find the reason.")
        QMessageBox.warning(None, pkginfo.package_name, msg)
        return sys.exit(app.exec_())

    window = MyMain()

    obj1 = IComboEntry("Entry without text")

    obj2 = Aggregate()
    combo_entry2 = IComboEntry("Entry with text2")
    combo_entry2.setObjectName("Combo Entry 2")
    obj2.add(combo_entry2)
    itext2 = IText2("This is a text for label 2")
    itext2.setObjectName("IText 2 (IText2)")
    obj2.add(itext2)

    obj3 = Aggregate()
    combo_entry3 = IComboEntry("Entry with text 1 and text 2")
    combo_entry3.setObjectName("Combo Entry 3")
    obj3.add(combo_entry3)
    itext31 = IText1("I love PySide!")
    itext31.setObjectName("IText 3 - 1 (IText1)")
    obj3.add(itext31)
    itext32 = IText2("There are software companies...")
    itext32.setObjectName("IText 3 - 2 (IText2)")
    obj3.add(itext32)

    obj4 = Aggregate()
    combo_entry4 = IComboEntry("Entry with text 1 and text 3")
    combo_entry4.setObjectName("Combo Entry 4")
    obj4.add(combo_entry4)
    itext41 = IText1("Some text written here.")
    itext41.setObjectName("IText 4 - 1 (IText1)")
    obj4.add(itext41)
    itext42 = IText3("I'm a troll.")
    itext42.setObjectName("IText 4 -2 (IText3")
    obj4.add(itext42)

    # the API takes IComboEntries, so we convert them to it
    # the MyMain objects takes the ownership of the whole aggregations
    window.add(aggregation.query(obj1, IComboEntry))
    window.add(aggregation.query(obj2, IComboEntry))
    window.add(aggregation.query(obj3, IComboEntry))
    window.add(aggregation.query(obj4, IComboEntry))
    window.show()

    app.exec_()
开发者ID:nichollyn,项目名称:libspark,代码行数:55,代码来源:main.py

示例10: initializePlugin

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
 def initializePlugin(self):
     if self.hasError:
         return False
     if self.state is not PluginState.Loaded:
         if self.state is PluginState.Initialized:
             return True
         self.errorString = QCoreApplication.translate(None,
                                                       "Initializing the plugin failed because state != Loaded")
         self.hasError = True
         return False
     if not self.plugin:
         self.errorString = QCoreApplication.translate(None,
                                                       "Internal error: have no plugin instance to initialize")
         self.hasError = True
         return False
     initialized, error = self.plugin.initialize(self.arguments)
     if not initialized:
         self.errorString = QCoreApplication.translate(None,
                                                       "Plugin initialization failed: {err}".format(err=error))
         self.hasError = True
         return False
     self.state = PluginState.Initialized
     return True
开发者ID:nichollyn,项目名称:libspark,代码行数:25,代码来源:pluginspec.py

示例11: checkForTestOption

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
    def checkForTestOption(self):
        if self.currentArg != OptionsParser.TEST_OPTION:
            return False
        if self.nextToken(TokenType.RequiredToken):
            spec = self.pmPrivate.pluginByName(self.currentArg)
            if not spec:
                self.lastError = QCoreApplication.translate(None,
                                                            "The plugin '{name}' doest not exist."
                                                            .format(self.currentArg))
                self.hasError = True
            else:
                self.pmPrivate.testSpecs.append(spec)

        return True
开发者ID:nichollyn,项目名称:libspark,代码行数:16,代码来源:optionsparser.py

示例12: checkForNoLoadOption

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
    def checkForNoLoadOption(self):
        if self.currentArg != OptionsParser.NO_LOAD_OPTION:
            return False
        if self.nextToken(TokenType.RequiredToken):
            spec = self.pmPrivate.pluginByName(self.currentArg)
            if not spec:
                self.lastError = QCoreApplication.translate(None,
                                                            "The plugin '{name}' does not exist."
                                                            .format(name=self.currentArg))
                self.hasError = True
            else:
                self.pmPrivate.disablePluginIndirectly(spec)
                self.isDependencyRefreshNeeded = True

        return True
开发者ID:nichollyn,项目名称:libspark,代码行数:17,代码来源:optionsparser.py

示例13: testTranslateWithNoneDisambiguation

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
 def testTranslateWithNoneDisambiguation(self):
     value = 'String here'
     obj = QCoreApplication.translate('context', value, None, QCoreApplication.UnicodeUTF8)
     self.assertTrue(isinstance(obj, py3k.unicode))
     self.assertEqual(obj, value)
开发者ID:Hasimir,项目名称:PySide,代码行数:7,代码来源:translation_test.py

示例14: __readPluginSpec

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
    def __readPluginSpec(self, reader):
        element = reader.name()
        if element != "plugin":
            msg = QCoreApplication.translate(None, "Expected element '{name}' as top level element")
            reader.raiseError(msg.format(name=PLUGIN))
            return
        self.name = reader.attributes().value(PLUGIN_NAME)
        if not self.name:
            reader.raiseError(PluginSpecPrivate.__msgAttributeMissing(PLUGIN, PLUGIN_NAME))
            return
        self.version = reader.attributes().value(PLUGIN_VERSION)
        if not self.version:
            reader.raiseError(PluginSpecPrivate.__msgAttributeMissing(PLUGIN, PLUGIN_VERSION))
            return
        if not PluginSpecPrivate.isValidVersion(self.version):
            reader.raiseError(PluginSpecPrivate.__msgInvalidFormat(PLUGIN_VERSION))
            return
        self.compatVersion = reader.attributes().value(PLUGIN_COMPATVERSION)
        if self.compatVersion and not PluginSpecPrivate.isValidVersion(self.compatVersion):
            reader.raiseError(PluginSpecPrivate.__msgInvalidFormat(PLUGIN_COMPATVERSION))
            return
        elif not self.compatVersion:
            self.compatVersion = self.version

        experimentalString = reader.attributes().value(PLUGIN_EXPERIMENTAL)
        self.experimental = (experimentalString.lower() == "true".lower())
        if experimentalString and not self.experimental and not experimentalString.lower() == "false".lower():
            reader.raiseError(PluginSpecPrivate.__msgInvalidFormat(PLUGIN_EXPERIMENTAL))
            return
        self.enabled = not self.experimental
        while not reader.atEnd():
            reader.readNext()
            tokenType = reader.tokenType()
            if tokenType is QXmlStreamReader.StartElement:
                element = reader.name()
                if element == PLUGIN_MAINCLASS:
                    self.mainClass = reader.readElementText().strip()
                elif element == VENDOR:
                    self.vendor = reader.readElementText().strip()
                elif element == COPYRIGHT:
                    self.copyright = reader.readElementText().strip()
                elif element == LICENSE:
                    self.license = reader.readElementText().strip()
                elif element == DESCRIPTION:
                    self.description = reader.readElementText().strip()
                elif element == URL:
                    self.url = reader.readElementText().strip()
                elif element == CATEGORY:
                    self.category = reader.readElementText().strip()
                elif element == DEPENDENCYLIST:
                    self.__readDependencies(reader)
                elif element == ARGUMENTLIST:
                    self.__readArgumentDescriptions(reader)
                else:
                    reader.raiseError(PluginSpecPrivate.__msgInvalidElement(self.name))
            elif (tokenType is QXmlStreamReader.EndDocument
                  or tokenType is QXmlStreamReader.Comment
                  or tokenType is QXmlStreamReader.EndElement
                  or tokenType is QXmlStreamReader.Characters):
                pass
            else:
                reader.raiseError(PluginSpecPrivate.__msgUnexpectedToken())
开发者ID:nichollyn,项目名称:libspark,代码行数:64,代码来源:pluginspec.py

示例15: __msgUnexpectedToken

# 需要导入模块: from PySide.QtCore import QCoreApplication [as 别名]
# 或者: from PySide.QtCore.QCoreApplication import translate [as 别名]
 def __msgUnexpectedToken():
     return QCoreApplication.translate(None, "Unexpected token")
开发者ID:nichollyn,项目名称:libspark,代码行数:4,代码来源:pluginspec.py


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