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


Python QCoreApplication.translate方法代码示例

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


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

示例1: __init__

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.setWindowTitle(QCoreApplication.translate("SettingsDialogPythonConsole", "Settings Python Console"))
        self.parent = parent
        self.setupUi(self)

        self.listPath = []
        self.lineEdit.setReadOnly(True)

        self.restoreSettings()
        self.initialCheck()

        self.addAPIpath.setIcon(QIcon(":/images/themes/default/symbologyAdd.svg"))
        self.addAPIpath.setToolTip(QCoreApplication.translate("PythonConsole", "Add API path"))
        self.removeAPIpath.setIcon(QIcon(":/images/themes/default/symbologyRemove.svg"))
        self.removeAPIpath.setToolTip(QCoreApplication.translate("PythonConsole", "Remove API path"))

        self.preloadAPI.stateChanged.connect(self.initialCheck)
        self.addAPIpath.clicked.connect(self.loadAPIFile)
        self.removeAPIpath.clicked.connect(self.removeAPI)
        self.compileAPIs.clicked.connect(self._prepareAPI)

        self.resetFontColor.setIcon(QIcon(":/images/themes/default/console/iconResetColorConsole.png"))
        self.resetFontColor.setIconSize(QSize(18, 18))
        self.resetFontColorEditor.setIcon(QIcon(":/images/themes/default/console/iconResetColorConsole.png"))
        self.resetFontColorEditor.setIconSize(QSize(18, 18))
        self.resetFontColor.clicked.connect(self._resetFontColor)
        self.resetFontColorEditor.clicked.connect(self._resetFontColorEditor)
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:30,代码来源:console_settings.py

示例2: startServerPlugin

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
def startServerPlugin(packageName):
    """ initialize the plugin """
    global server_plugins, server_active_plugins, serverIface

    if packageName in server_active_plugins:
        return False
    if packageName not in sys.modules:
        return False

    package = sys.modules[packageName]

    errMsg = QCoreApplication.translate("Python", "Couldn't load server plugin %s") % packageName

    # create an instance of the plugin
    try:
        server_plugins[packageName] = package.serverClassFactory(serverIface)
    except:
        _unloadPluginModules(packageName)
        msg = (
            QCoreApplication.translate("Python", "%s due to an error when calling its serverClassFactory() method")
            % errMsg
        )
        showException(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2], msg)
        return False

    # add to active plugins
    server_active_plugins.append(packageName)
    return True
开发者ID:dwadler,项目名称:QGIS,代码行数:30,代码来源:utils.py

示例3: saveAsScriptFile

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
    def saveAsScriptFile(self, index=None):
        tabWidget = self.tabEditorWidget.currentWidget()
        if not index:
            index = self.tabEditorWidget.currentIndex()
        if not tabWidget.path:
            fileName = self.tabEditorWidget.tabText(index) + '.py'
            folder = self.settings.value("pythonConsole/lastDirPath", QDir.home())
            pathFileName = os.path.join(folder, fileName)
            fileNone = True
        else:
            pathFileName = tabWidget.path
            fileNone = False
        saveAsFileTr = QCoreApplication.translate("PythonConsole", "Save File As")
        filename = QFileDialog.getSaveFileName(self,
                                               saveAsFileTr,
                                               pathFileName, "Script file (*.py)")
        if filename:
            try:
                tabWidget.save(filename)
            except (IOError, OSError) as error:
                msgText = QCoreApplication.translate('PythonConsole',
                                                     'The file <b>{0}</b> could not be saved. Error: {1}').format(tabWidget.path,
                                                                                                                  error.strerror)
                self.callWidgetMessageBarEditor(msgText, 2, False)
                if fileNone:
                    tabWidget.path = None
                else:
                    tabWidget.path = pathFileName
                return

            if not fileNone:
                self.updateTabListScript(pathFileName, action='remove')
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:34,代码来源:console.py

示例4: removeDir

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
def removeDir(path):
    result = ""
    if not QFile(path).exists():
        result = QCoreApplication.translate("QgsPluginInstaller", "Nothing to remove! Plugin directory doesn't exist:") + "\n" + path
    elif QFile(path).remove():  # if it is only link, just remove it without resolving.
        pass
    else:
        fltr = QDir.Dirs | QDir.Files | QDir.Hidden
        iterator = QDirIterator(path, fltr, QDirIterator.Subdirectories)
        while iterator.hasNext():
            item = iterator.next()
            if QFile(item).remove():
                pass
        fltr = QDir.Dirs | QDir.Hidden
        iterator = QDirIterator(path, fltr, QDirIterator.Subdirectories)
        while iterator.hasNext():
            item = iterator.next()
            if QDir().rmpath(item):
                pass
    if QFile(path).exists():
        result = QCoreApplication.translate("QgsPluginInstaller", "Failed to remove the directory:") + "\n" + path + "\n" + QCoreApplication.translate("QgsPluginInstaller", "Check permissions or remove it manually")
    # restore plugin directory if removed by QDir().rmpath()
    pluginDir = qgis.utils.home_plugin_path
    if not QDir(pluginDir).exists():
        QDir().mkpath(pluginDir)
    return result
开发者ID:chaosui,项目名称:QGIS,代码行数:28,代码来源:installer_data.py

示例5: initGui

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
    def initGui(self):
        """startup"""

        # run
        run_icon = QIcon('%s/%s' % (self.context.ppath,
                                    'images/MetaSearch.png'))
        self.action_run = QAction(run_icon, 'MetaSearch',
                                  self.iface.mainWindow())
        self.action_run.setWhatsThis(QCoreApplication.translate('MetaSearch',
                                                                'MetaSearch plugin'))
        self.action_run.setStatusTip(QCoreApplication.translate('MetaSearch',
                                                                'Search Metadata Catalogues'))

        self.action_run.triggered.connect(self.run)

        self.iface.addWebToolBarIcon(self.action_run)
        self.iface.addPluginToWebMenu(self.web_menu, self.action_run)

        # help
        help_icon = QIcon('%s/%s' % (self.context.ppath, 'images/help.png'))
        self.action_help = QAction(help_icon, 'Help', self.iface.mainWindow())
        self.action_help.setWhatsThis(QCoreApplication.translate('MetaSearch',
                                                                 'MetaSearch plugin help'))
        self.action_help.setStatusTip(QCoreApplication.translate('MetaSearch',
                                                                 'Get Help on MetaSearch'))
        self.action_help.triggered.connect(self.help)

        self.iface.addPluginToWebMenu(self.web_menu, self.action_help)

        # prefab the dialog but not open it yet
        self.dialog = MetaSearchDialog(self.iface)
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:33,代码来源:plugin.py

示例6: switchToolMode

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
    def switchToolMode(self):
        self.setCommandViewerEnabled(not self.batchCheck.isChecked())
        self.progressBar.setVisible(self.batchCheck.isChecked())
        self.formatLabel.setVisible(self.batchCheck.isChecked())
        self.formatCombo.setVisible(self.batchCheck.isChecked())

        self.inSelector.setType(self.inSelector.FILE if self.batchCheck.isChecked() else self.inSelector.FILE_LAYER)
        self.outSelector.clear()

        if self.batchCheck.isChecked():
            self.inFileLabel = self.label.text()
            self.outFileLabel = self.label_1.text()
            self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory"))
            self.label_1.setText(QCoreApplication.translate("GdalTools", "&Output directory"))

            self.inSelector.selectClicked.disconnect(self.fillInputFile)
            self.outSelector.selectClicked.disconnect(self.fillOutputFile)

            self.inSelector.selectClicked.connect(self. fillInputDir)
            self.outSelector.selectClicked.connect(self.fillOutputDir)
        else:
            self.label.setText(self.inFileLabel)
            self.label_1.setText(self.outFileLabel)

            self.inSelector.selectClicked.disconnect(self.fillInputDir)
            self.outSelector.selectClicked.disconnect(self.fillOutputDir)

            self.inSelector.selectClicked.connect(self.fillInputFile)
            self.outSelector.selectClicked.connect(self.fillOutputFile)
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:31,代码来源:doFillNodata.py

示例7: initGui

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
    def initGui(self):
        """startup"""

        # run
        run_icon = QIcon("%s/%s" % (self.context.ppath, "images/MetaSearch.png"))
        self.action_run = QAction(run_icon, "MetaSearch", self.iface.mainWindow())
        self.action_run.setWhatsThis(QCoreApplication.translate("MetaSearch", "MetaSearch plugin"))
        self.action_run.setStatusTip(QCoreApplication.translate("MetaSearch", "Search Metadata Catalogues"))

        self.action_run.triggered.connect(self.run)

        self.iface.addWebToolBarIcon(self.action_run)
        self.iface.addPluginToWebMenu(self.web_menu, self.action_run)

        # help
        help_icon = QgsApplication.getThemeIcon("/mActionHelpContents.svg")
        self.action_help = QAction(help_icon, "Help", self.iface.mainWindow())
        self.action_help.setWhatsThis(QCoreApplication.translate("MetaSearch", "MetaSearch plugin help"))
        self.action_help.setStatusTip(QCoreApplication.translate("MetaSearch", "Get Help on MetaSearch"))
        self.action_help.triggered.connect(self.help)

        self.iface.addPluginToWebMenu(self.web_menu, self.action_help)

        # prefab the dialog but not open it yet
        self.dialog = MetaSearchDialog(self.iface)
开发者ID:dwadler,项目名称:QGIS,代码行数:27,代码来源:plugin.py

示例8: defineCharacteristicsFromFile

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
    def defineCharacteristicsFromFile(self):
        lines = open(self.descriptionFile)
        line = lines.readline().strip('\n').strip()
        self.name = line
        self.i18n_name = QCoreApplication.translate("TAUDEMAlgorithm", line)
        line = lines.readline().strip('\n').strip()
        self.cmdName = line
        line = lines.readline().strip('\n').strip()
        self.group = line
        self.i18n_group = QCoreApplication.translate("TAUDEMAlgorithm", line)

        line = lines.readline().strip('\n').strip()
        while line != '':
            try:
                line = line.strip('\n').strip()
                if line.startswith('Parameter'):
                    param = getParameterFromString(line)
                    self.addParameter(param)
                else:
                    self.addOutput(getOutputFromString(line))
                line = lines.readline().strip('\n').strip()
            except Exception as e:
                ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
                                       self.tr('Could not load TauDEM algorithm: %s\n%s' % (self.descriptionFile, line)))
                raise e
        lines.close()
开发者ID:Clayton-Davis,项目名称:QGIS,代码行数:28,代码来源:TauDEMAlgorithm.py

示例9: open_stack_dialog

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
def open_stack_dialog(type, value, tb, msg, pop_error=True):
    if pop_error:
        iface.messageBar().popWidget()

    if msg is None:
        msg = QCoreApplication.translate("Python", "An error has occurred while executing Python code:")

    # TODO Move this to a template HTML file
    txt = u"""<font color="red"><b>{msg}</b></font>
<br>
<h3>{main_error}</h3>
<pre>
{error}
</pre>
<br>
<b>{version_label}</b> {num}
<br>
<b>{qgis_label}</b> {qversion} {qgisrelease}, {devversion}
<br>
<h4>{pypath_label}</h4>
<ul>
{pypath}
</ul>"""

    error = ""
    lst = traceback.format_exception(type, value, tb)
    for s in lst:
        error += s.decode("utf-8", "replace") if hasattr(s, "decode") else s
    error = error.replace("\n", "<br>")

    main_error = lst[-1].decode("utf-8", "replace") if hasattr(lst[-1], "decode") else lst[-1]

    version_label = QCoreApplication.translate("Python", "Python version:")
    qgis_label = QCoreApplication.translate("Python", "QGIS version:")
    pypath_label = QCoreApplication.translate("Python", "Python Path:")
    txt = txt.format(
        msg=msg,
        main_error=main_error,
        error=error,
        version_label=version_label,
        num=sys.version,
        qgis_label=qgis_label,
        qversion=QGis.QGIS_VERSION,
        qgisrelease=QGis.QGIS_RELEASE_NAME,
        devversion=QGis.QGIS_DEV_VERSION,
        pypath_label=pypath_label,
        pypath=u"".join(u"<li>{}</li>".format(path) for path in sys.path),
    )

    txt = txt.replace("  ", "&nbsp; ")  # preserve whitespaces for nicer output

    dlg = QgsMessageOutput.createMessageOutput()
    dlg.setTitle(msg)
    dlg.setMessage(txt, QgsMessageOutput.MessageHtml)
    dlg.showMessage()
开发者ID:dwadler,项目名称:QGIS,代码行数:57,代码来源:utils.py

示例10: runLAStools

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
 def runLAStools(commands, progress):
     loglines = []
     commandline = " ".join(commands)
     loglines.append(QCoreApplication.translate("LAStoolsUtils", "LAStools command line"))
     loglines.append(commandline)
     loglines.append(QCoreApplication.translate("LAStoolsUtils", "LAStools console output"))
     proc = subprocess.Popen(commandline, shell=True, stdout=subprocess.PIPE, stdin=open(os.devnull),
                             stderr=subprocess.STDOUT, universal_newlines=False).stdout
     for line in iter(proc.readline, ""):
         loglines.append(line)
         progress.setConsoleInfo(line)
     ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:14,代码来源:LAStoolsUtils.py

示例11: onError

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
    def onError(self, error):
        if error == QProcess.FailedToStart:
            msg = QCoreApplication.translate("GdalTools", "The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.")
        elif error == QProcess.Crashed:
            msg = QCoreApplication.translate("GdalTools", "The process crashed some time after starting successfully.")
        else:
            msg = QCoreApplication.translate("GdalTools", "An unknown error occurred.")

        QErrorMessage(self).showMessage(msg)
        QApplication.processEvents()  # give the user chance to see the message

        self.stop()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:14,代码来源:dialogBase.py

示例12: showException

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
def showException(type, value, tb, msg, messagebar=False):
    if msg is None:
        msg = QCoreApplication.translate("Python", "An error has occurred while executing Python code:")

    logmessage = ""
    for s in traceback.format_exception(type, value, tb):
        logmessage += s.decode("utf-8", "replace") if hasattr(s, "decode") else s

    title = QCoreApplication.translate("Python", "Python error")
    QgsMessageLog.logMessage(logmessage, title)

    try:
        blockingdialog = QApplication.instance().activeModalWidget()
        window = QApplication.instance().activeWindow()
    except:
        blockingdialog = QApplication.activeModalWidget()
        window = QApplication.activeWindow()

    # Still show the normal blocking dialog in this case for now.
    if blockingdialog or not window or not messagebar or not iface:
        open_stack_dialog(type, value, tb, msg)
        return

    bar = iface.messageBar()

    # If it's not the main window see if we can find a message bar to report the error in
    if not window.objectName() == "QgisApp":
        widgets = window.findChildren(QgsMessageBar)
        if widgets:
            # Grab the first message bar for now
            bar = widgets[0]

    item = bar.currentItem()
    if item and item.property("Error") == msg:
        # Return of we already have a message with the same error message
        return

    widget = bar.createMessage(
        title, msg + " " + QCoreApplication.translate("Python", "See message log (Python Error) for more details.")
    )
    widget.setProperty("Error", msg)
    stackbutton = QPushButton(
        QCoreApplication.translate("Python", "Stack trace"),
        pressed=functools.partial(open_stack_dialog, type, value, tb, msg),
    )
    button = QPushButton(QCoreApplication.translate("Python", "View message log"), pressed=show_message_log)
    widget.layout().addWidget(stackbutton)
    widget.layout().addWidget(button)
    bar.pushWidget(widget, QgsMessageBar.WARNING)
开发者ID:dwadler,项目名称:QGIS,代码行数:51,代码来源:utils.py

示例13: _preparationFinished

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
 def _preparationFinished(self):
     self._clearLexer()
     if os.path.exists(self._pap_file):
         os.remove(self._pap_file)
     self.ui.label.setText(QCoreApplication.translate("PythonConsole", "Saving prepared file..."))
     prepd = self._api.savePrepared(unicode(self._pap_file))
     rslt = self.trUtf8("Error")
     if prepd:
         rslt = QCoreApplication.translate("PythonConsole", "Saved")
     self.ui.label.setText(u'{0} {1}'.format(self.ui.label.text(), rslt))
     self._api = None
     self.ui.progressBar.setVisible(False)
     self.ui.buttonBox.button(QDialogButtonBox.Cancel).setText(
         QCoreApplication.translate("PythonConsole", "Done"))
     self.adjustSize()
开发者ID:chaosui,项目名称:QGIS,代码行数:17,代码来源:console_compile_apis.py

示例14: close

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
 def close(self):
     if self.msg:
         dlg = MessageDialog()
         dlg.setTitle(QCoreApplication.translate('MessageBarProgress', 'Problem executing algorithm'))
         dlg.setMessage("<br>".join(self.msg))
         dlg.exec_()
     iface.messageBar().clearWidgets()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:9,代码来源:MessageBarProgress.py

示例15: executeSaga

# 需要导入模块: from PyQt.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt.QtCore.QCoreApplication import translate [as 别名]
def executeSaga(progress):
    if isWindows():
        command = ['cmd.exe', '/C ', sagaBatchJobFilename()]
    else:
        os.chmod(sagaBatchJobFilename(), stat.S_IEXEC
                 | stat.S_IREAD | stat.S_IWRITE)
        command = [sagaBatchJobFilename()]
    loglines = []
    loglines.append(QCoreApplication.translate('SagaUtils', 'SAGA execution console output'))
    proc = subprocess.Popen(
        command,
        shell=True,
        stdout=subprocess.PIPE,
        stdin=open(os.devnull),
        stderr=subprocess.STDOUT,
        universal_newlines=True,
    ).stdout
    try:
        for line in iter(proc.readline, ''):
            if '%' in line:
                s = ''.join([x for x in line if x.isdigit()])
                try:
                    progress.setPercentage(int(s))
                except:
                    pass
            else:
                line = line.strip()
                if line != '/' and line != '-' and line != '\\' and line != '|':
                    loglines.append(line)
                    progress.setConsoleInfo(line)
    except:
        pass
    if ProcessingConfig.getSetting(SAGA_LOG_CONSOLE):
        ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:36,代码来源:SagaUtils.py


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