• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python translate.tr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中translate.tr函数的典型用法代码示例。如果您正苦于以下问题:Python tr函数的具体用法?Python tr怎么用?Python tr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: DialogToParametersUpdate

    def DialogToParametersUpdate(self):

        # update all parameters from dialog widget
        for header_or_param in {"header", "param"}:

            listParam = self.query.param
            if header_or_param == "header":
                listParam = self.query.header

            for paramName in self.widgetParam[header_or_param].keys():

                # widget linked to this parameter
                widget = self.widgetParam[header_or_param][paramName]
                param = listParam[paramName]

                [type_widget, type_options, name] = splitParamNameAndType(paramName)

                # update value param

                # print "DEBUG query_param TYPE = " + type_widget

                if type_widget == "text":
                    param["value"] = widget.text()

                elif type_widget == "date":
                    param["value"] = widget.lineEdit().text()

                elif type_widget == "select":
                    param["value"] = widget.currentText()

                # selected item : try to read the attribute of a selected item on map
                elif type_widget == "selected_item":

                    print "DEBUG query_param "
                    currentLayer = self.iface.mapCanvas().currentLayer()
                    if not type(currentLayer) is QgsVectorLayer:
                        self.errorMessage = tr(u"Select a vector layer !")
                        continue
                    if currentLayer.selectedFeatureCount() != 1:
                        self.errorMessage = tr(u"Select just one feature on map !")
                        continue
                    currentFeature = currentLayer.selectedFeatures()[0]

                    # standard attribute :
                    if type_options != "geom":

                        if currentFeature.fields().indexFromName(type_options) == -1:
                            self.errorMessage = tr(u"This feature does not have such an attribute : ") + type_options
                            continue
                        param["value"] = unicode(currentFeature.attribute(type_options))

                    # geom attribut :
                    else:
                        param["value"] = (
                            "ST_GeomFromEWKT('SRID="
                            + str(currentLayer.crs().postgisSrid())
                            + ";"
                            + currentFeature.geometry().exportToWkt()
                            + "')"
                        )
开发者ID:hchristol,项目名称:SharedSqlQueries,代码行数:60,代码来源:query_param.py


示例2: __init__

 def __init__(self, parent=None):
     QListWidget.__init__(self, parent)
     self.setWindowTitle(tr("Saved Sessions"))
     self.setWindowFlags(Qt.Dialog)
     hideAction = QAction(self)
     hideAction.setShortcuts(["Esc", "Ctrl+W"])
     hideAction.triggered.connect(self.hide)
     self.addAction(hideAction)
     self.sessionList = QListWidget(self)
     self.sessionList.itemActivated.connect(self.loadSession)
     self.setCentralWidget(self.sessionList)
     self.toolBar = QToolBar(self)
     self.toolBar.setMovable(False)
     self.toolBar.setContextMenuPolicy(Qt.CustomContextMenu)
     self.addToolBar(Qt.BottomToolBarArea, self.toolBar)
     self.loadButton = QPushButton(tr("&Load"), self)
     self.loadButton.clicked.connect(lambda: self.loadSession(self.sessionList.currentItem()))
     self.toolBar.addWidget(self.loadButton)
     self.saveButton = QPushButton(tr("&Save"), self)
     self.saveButton.clicked.connect(saveSessionManually)
     self.saveButton.clicked.connect(self.refresh)
     self.toolBar.addWidget(self.saveButton)
     deleteAction = QAction(self)
     deleteAction.setShortcut("Del")
     deleteAction.triggered.connect(self.delete)
     self.addAction(deleteAction)
开发者ID:ismlsmile,项目名称:nimbus,代码行数:26,代码来源:session.py


示例3: RecordingOptionsMenuHandler

    def RecordingOptionsMenuHandler(self, controller, data):
        log("in RecordingOptionsMenuHandler")
        try:
            rec=data[0]
            idx=data[1]
        except:
            return

        log("Got idx: %s rec %s" % (repr(idx), repr(rec).encode("ascii","replace")))
        if idx==0 or idx==1:
            fn=lambda : ETV.PlayRecording(rec,idx==1)
            self.inEyeTV = 1
            newCon=PyeTVWaitController.alloc().initWithStartup_exitCond_(fn,self.ReturnToFrontRow)
            ret=controller.stack().pushController_(newCon)
            return ret
        if idx==2:
            return self.ConfirmDeleteRecordingDialog(controller, rec)
        if idx==3:
            if self.AppRunning("ComSkipper"):
                os.system("/usr/bin/killall ComSkipper &")
                self.CurrentOptionsMenu.ds.menu.items[3].layer.setTitle_(tr("ComSkipper                     [Off]")) # deep magic
            else:
                os.system("/Library/Application\ Support/ETVComskip/ComSkipper.app/Contents/MacOS/ComSkipper &")
                self.CurrentOptionsMenu.ds.menu.items[3].layer.setTitle_(tr("ComSkipper                      [On]")) # deep magic
            #time.sleep(0.5)

        if idx==4:
            log("/Library/Application\ Support/ETVComskip/MarkCommercials.app/Contents/MacOS/MarkCommercials --log %s &" % rec.rec.unique_ID.get())
            os.system("/Library/Application\ Support/ETVComskip/MarkCommercials.app/Contents/MacOS/MarkCommercials --log %s &" % rec.rec.unique_ID.get())

        # if we return true, we'll pop the controller and back up past the option dialog
        return False
开发者ID:bruno1505,项目名称:pyetv,代码行数:32,代码来源:PyeTV.py


示例4: check_asserts

    def check_asserts(self):
        """ Are there asserts at the end of the source code ? """
        self.nb_asserts = 0
        defined_funs = set()
        funcalls = set()
        for node in self.AST.body:
            #print("node: {}".format(node))
            if isinstance(node, ast.Assert):
                #print("assert found: {}".format(node))
                call_visit = FunCallsVisitor()
                call_visit.visit(node)
                self.nb_asserts += 1
                funcalls.update(call_visit.funcalls)
            elif isinstance(node, ast.FunctionDef):
                defined_funs.add(node.name)

        #print("defined funs = {}".format(defined_funs))
        #print("funcalls = {}".format(funcalls))

        self.report.nb_defined_funs = len(defined_funs)
        
        missing = defined_funs.difference(funcalls)

        if missing:
            self.report.add_convention_error('warning', tr('Missing tests')
                                             , details="\n" + tr('Untested functions: ')
                                             + "{}".format(missing) + "\n")
        elif defined_funs:
            # all the functions are tested at least once
            self.report.add_convention_error('run', tr('All functions tested'), details="==> " + tr("All functions tested (good)"))

        return True
开发者ID:fredokun,项目名称:MrPython,代码行数:32,代码来源:StudentRunner.py


示例5: execute

    def execute(self, locals):
        """ Run the file : customized parsing for checking rules,
            compile and execute """
        # Compile the code and get the AST from it, which will be used for all
        # the conventions checkings that need to be done

        try:
            self.AST = ast.parse(self.source, self.filename)
        # Handle the different kinds of compilation errors
        except IndentationError as err:
            self.report.add_compilation_error('error', tr("Bad indentation"), err.lineno, err.offset)
            return False
        except SyntaxError as err:
            self.report.add_compilation_error('error', tr("Syntax error"), err.lineno, err.offset, details=err.text)
            return False
        except Exception as err:
            typ, exc, tb = sys.exc_info()
            self.report.add_compilation_error('error', str(typ), err.lineno, err.offset, details=str(err))
            return False

        # No parsing error here

        # perform the local checks
        ret_val = True
        if not self.check_rules(self.report):
            ret_val = False
            self.run(locals) # we still run the code even if there is a convention error
        else:
            ret_val = self.run(locals) # Run the code if it passed all the convention tests
            if ret_val:
                self.report.nb_passed_tests = self.nb_asserts

        return ret_val
开发者ID:fredokun,项目名称:MrPython,代码行数:33,代码来源:StudentRunner.py


示例6: toggleWindows

 def toggleWindows(self):
     hidden = False
     for window in browser.windows:
         window.setVisible(not window.isVisible())
     try:
         if not browser.windows[0].isVisible():
             self.showMessage(tr("All windows hidden"), tr("Click again to restore."))
     except: pass
开发者ID:ismlsmile,项目名称:nimbus,代码行数:8,代码来源:tray_icon.py


示例7: change_mode

 def change_mode(self, event=None):
     """ Swap the python mode : full python or student """
     if self.mode == "student":
         self.mode = "full"
     else:
         self.mode = "student"
     self.icon_widget.switch_icon_mode(self.mode)
     self.console.change_mode(tr(self.mode))
     self.status_bar.change_mode(tr(self.mode))
开发者ID:fredokun,项目名称:MrPython,代码行数:9,代码来源:Application.py


示例8: SelectProfile

def SelectProfile (parent, profiles):
	items = []
	for prof in profiles:
		items.append( prof['name'].decode('ascii') )
	idx = SelectItem(parent, tr('#Select profile'), tr('#Name'), items)
	if idx == None:
		return None
	else:
		return profiles[idx]
开发者ID:aixp,项目名称:rops,代码行数:9,代码来源:ide_gtk2.py


示例9: find

 def find(self):
     find = QInputDialog.getText(self, tr("Find"), tr("Search for:"), QLineEdit.Normal, self.text)
     if find[1]:
         self.text = find[0]
     else:
         self.text = ""
     if self.findFlag:
         self.sourceView.find(self.text, self.findFlag)
     else:
         self.sourceView.find(self.text)
开发者ID:ismlsmile,项目名称:nimbus,代码行数:10,代码来源:view_source_dialog.py


示例10: __init__

    def __init__(self, parent=None):
        super(ClearHistoryDialog, self).__init__(parent)

        self.setWindowFlags(Qt.Dialog)

        self.setWindowTitle(tr("Clear Data"))

        closeWindowAction = QAction(self)
        closeWindowAction.setShortcuts(["Esc", "Ctrl+W", "Ctrl+Shift+Del"])
        closeWindowAction.triggered.connect(self.close)
        self.addAction(closeWindowAction)

        self.layout = QVBoxLayout()
        self.setLayout(self.layout)
        label = QLabel(tr("What to clear:"), self)
        self.layout.addWidget(label)
        self.dataType = QComboBox(self)
        self.dataType.addItem(tr("History"))
        self.dataType.addItem(tr("Cookies"))
        self.dataType.addItem(tr("Memory Caches"))
        self.dataType.addItem(tr("Persistent Storage"))
        self.dataType.addItem(tr("Everything"))
        self.layout.addWidget(self.dataType)
        self.toolBar = QToolBar(self)
        self.toolBar.setStyleSheet(common.blank_toolbar)
        self.toolBar.setMovable(False)
        self.toolBar.setContextMenuPolicy(Qt.CustomContextMenu)
        self.layout.addWidget(self.toolBar)
        self.clearHistoryButton = QPushButton(tr("Clear"), self)
        self.clearHistoryButton.clicked.connect(self.clearHistory)
        self.toolBar.addWidget(self.clearHistoryButton)
        self.closeButton = QPushButton(tr("Close"), self)
        self.closeButton.clicked.connect(self.close)
        self.toolBar.addWidget(self.closeButton)
开发者ID:ismlsmile,项目名称:nimbus,代码行数:34,代码来源:clear_history_dialog.py


示例11: about

 def about(self):
     try: parent = browser.activeWindow()
     except:
         parent = self.widget
         self.widget.show()
     QMessageBox.about(parent, tr("About %s") % (common.app_name,),\
                       "<h3>" + common.app_name + " " +\
                       common.app_version +\
                       "</h3>" +\
                       tr("A Qt-based web browser made in Python.<br><br>%s is provided to you free of charge, with no promises of security or stability. By using this software, you agree not to sue me for anything that goes wrong with it.") % (common.app_name,))
     self.widget.hide()
开发者ID:ismlsmile,项目名称:nimbus,代码行数:11,代码来源:tray_icon.py


示例12: populateChannelData

    def populateChannelData(self, layer, asset):
        log("in populateChannelData")

        currentTitle=""
        nextDesc=""
        nextTime=""
        nextTitle=""
        currentDesc=""

        recording,data=asset.channel.GetProgramInfo()
        log("%s, %s" % (str(recording).encode("ascii","replace"),str(data).encode("ascii","replace")))
        if not data:
            return
        if not recording and not data.has_key('currentShow'):
            return
        if recording:
            c=ETV.RecordingChannelName()
            log("Got recording, channel name %s" % c)
            if c is None:
                return
            currentTitle=tr("Now Recording!")
            currentDesc=(tr("Currently recording channel %s.  Program info is not available.") % c)

        try:
            currentShow=data['currentShow']
            currentTitle += currentShow['title'] 
            if currentShow.has_key('shortDescription'):
                currentDesc += currentShow['shortDescription'] + " "
            currentDesc += currentShow['startTime'].strftime("%I:%M") + "-" + currentShow['endTime'].strftime("%I:%M%p") 
        except:
            pass
        try:
            nextShow=data['nextShow']
            nextTitle = nextShow['title']
            nextTime = nextShow['startTime'].strftime("%I:%M%p") + "-" + nextShow['endTime'].strftime("%I:%M%p")
            nextDesc = nextShow['shortDescription']
        except:
            pass

        layer.setTitle_(currentTitle)
        layer.setSummary_(currentDesc)
        labels=[
            tr("Next"),
            tr("Episode"),
            tr("Time")
            ]
        data=[
            nextTitle,
            nextDesc,
            nextTime
            ]
        layer.setMetadata_withLabels_(data,labels)
开发者ID:bruno1505,项目名称:pyetv,代码行数:52,代码来源:PyeTVMetaData.py


示例13: _exec_or_eval

    def _exec_or_eval(self, mode, code, globs, locs):
        assert mode=='exec' or mode=='eval'

        try:
            if mode=='exec':
                result = exec(code, globs, locs)
            elif mode=='eval':
                result = eval(code, globs, locs)
        except TypeError as err:
            a, b, tb = sys.exc_info()
            filename, lineno, file_type, line = traceback.extract_tb(tb)[-1]
            err_str = self._extract_error_details(err)
            self.report.add_execution_error('error', tr("Type error"), lineno, details=str(err))
            return (False, None)
        except NameError as err:
            a, b, tb = sys.exc_info() # Get the traceback object
            # Extract the information for the traceback corresponding to the error
            # inside the source code : [0] refers to the result = exec(code)
            # traceback, [1] refers to the last error inside code
            filename, lineno, file_type, line = traceback.extract_tb(tb)[-1]
            err_str = self._extract_error_details(err)
            self.report.add_execution_error('error', tr("Name error (unitialized variable?)"), lineno, details=err_str)
            return (False, None)
        except ZeroDivisionError:
            a, b, tb = sys.exc_info()
            filename, lineno, file_type, line = traceback.extract_tb(tb)[-1]
            self.report.add_execution_error('error', tr("Division by zero"), lineno if mode=='exec' else None)
            return (False, None)
        except AssertionError:
            a, b, tb = sys.exc_info()
            lineno=None
            traceb = traceback.extract_tb(tb)
            if len(traceb) > 1:
                filename, lineno, file_type, line = traceb[-1]
            self.report.add_execution_error('error', tr("Assertion error (failed test?)"), lineno)
            return (True, None)
        except Exception as err:
            a, b, tb = sys.exc_info() # Get the traceback object
            # Extract the information for the traceback corresponding to the error
            # inside the source code : [0] refers to the result = exec(code)
            # traceback, [1] refers to the last error inside code
            lineno=None
            traceb = traceback.extract_tb(tb)
            if len(traceb) > 1:
                filename, lineno, file_type, line = traceb[-1]
            self.report.add_execution_error('error', a.__name__, lineno, details=str(err))
            return (False, None)
        finally:
            self.running = False

        return (True, result)
开发者ID:fredokun,项目名称:MrPython,代码行数:51,代码来源:StudentRunner.py


示例14: __init__

    def __init__(self, parent=None):
        super(SearchEditor, self).__init__(parent)
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.Popup)
        self.parent = parent
        self.setWindowTitle(tr('Search Editor'))
        self.styleSheet = "QMainWindow { background: palette(window); border: 1px solid palette(dark); }"
        self.setStyleSheet(self.styleSheet)
        try: self.setWindowIcon(common.app_icon)
        except: pass

        closeWindowAction = QAction(self)
        closeWindowAction.setShortcuts(["Ctrl+W", "Ctrl+Shift+K"])
        closeWindowAction.triggered.connect(self.close)
        self.addAction(closeWindowAction)

        self.entryBar = QToolBar(self)
        self.entryBar.setIconSize(QSize(16, 16))
        self.entryBar.setStyleSheet(common.blank_toolbar)
        self.entryBar.setContextMenuPolicy(Qt.CustomContextMenu)
        self.entryBar.setMovable(False)
        self.addToolBar(self.entryBar)

        eLabel = QLabel(" " + tr('New expression:'), self)
        self.entryBar.addWidget(eLabel)
        self.expEntry = custom_widgets.LineEdit(self)
        self.expEntry.returnPressed.connect(self.addSearch)
        self.entryBar.addWidget(self.expEntry)
        self.addSearchButton = QToolButton(self)
        self.addSearchButton.setText(tr("Add"))
        self.addSearchButton.setIcon(common.complete_icon("list-add"))
        self.addSearchButton.clicked.connect(self.addSearch)
        self.entryBar.addWidget(self.addSearchButton)

        self.engineList = QListWidget(self)
        self.engineList.setAlternatingRowColors(True)
        self.engineList.itemClicked.connect(self.applySearch)
        self.engineList.itemActivated.connect(self.applySearch)
        self.engineList.itemActivated.connect(self.close)
        self.setCentralWidget(self.engineList)

        self.takeSearchAction = QAction(self)
        self.takeSearchAction.triggered.connect(self.takeSearch)
        self.takeSearchAction.setShortcut("Del")
        self.addAction(self.takeSearchAction)

        self.hideAction = QAction(self)
        self.hideAction.triggered.connect(self.hide)
        self.hideAction.setShortcut("Esc")
        self.addAction(self.hideAction)

        self.reload_()
开发者ID:ismlsmile,项目名称:nimbus,代码行数:51,代码来源:search_manager.py


示例15: __str__

    def __str__(self):
        s = ""
        if self.severity == 'warning':
            s = "{}{}".format(tr("Warning"),
                              tr(": line {}\n").format(self.line) if self.line else "")
            s = s + self.error_details()
        elif self.severity == 'error':
            s = "{}{}".format(tr("Error"),
                              tr(": line {}\n").format(self.line) if self.line else "")
            s = s + self.error_details()
        else:
            s = self.details

        return s
开发者ID:fredokun,项目名称:MrPython,代码行数:14,代码来源:RunReport.py


示例16: injectCustomParameters

def injectCustomParameters(param, sql):

    # split sql to extract parameters
    exploded = sql.split(TAG)
    count = 0
    finalSql=""

    for block in exploded:

        if (count % 2) == 1:
            # parameter sql block
            [paramName, value] = readParamter(block)

            # parameter for this block
            p = param[paramName]
            if "value" in p:
                finalSql += p["value"]
            else:
                # no value set : use default value
                finalSql += p["default"]

        else:
            # other sql block
            finalSql += block

        count += 1

    if count != 0 and (count % 2) != 1:
        exc = SyntaxError()
        exc.text = tr(u"Wrong Number of " + TAG)
        raise exc


    return finalSql
开发者ID:hchristol,项目名称:SharedSqlQueries,代码行数:34,代码来源:customSqlQuery.py


示例17: do_open

	def do_open (self, fileName, prof):
		# assert not modified

		try:
			encodedText = util.readFile(fileName)
		except Exception, e:
			self.msg_set( tr('#File read error') + ': ' + exMsg(e) )
开发者ID:aixp,项目名称:rops,代码行数:7,代码来源:ide_gtk2.py


示例18: __init__

 def __init__(self, *args, **kwargs):
     super(BatteryAction, self).__init__(*args, **kwargs)
     self.setToolTip(tr("Power"))
     if system.battery:
         self.updateLife()
         self.timer.timeout.connect(self.updateLife)
         if not self.timer.isActive():
             self.timer.start(5000)
     elif system.is_on_ac():
         self.setIcon(complete_icon("charging"))
         self.setText(tr("AC"))
         self.setToolTip(tr("System is running on AC power"))
     else:
         self.setIcon(complete_icon("dialog-warning"))
         self.setText(tr("N/A"))
         self.setToolTip(tr("Battery not detected"))
开发者ID:ismlsmile,项目名称:nimbus,代码行数:16,代码来源:custom_widgets.py


示例19: run

    def run(self, locals):
        """ Run the code, add the execution errors to the rapport, if any """
        locals = install_locals(locals)
        code = None
        try:
            code = compile(self.source, self.filename, 'exec')
        except SyntaxError as err:
            self.report.add_compilation_error('error', tr("Syntax error"), err.lineno, err.offset, details=str(err))
            return False
        except Exception as err:
            typ, exc, tb = sys.exc_info()
            self.report.add_compilation_error('error', str(typ), err.lineno, err.offset, details=str(err))

            return False

        (ok, result) = self._exec_or_eval('exec', code, locals, locals)
        #if not ok:
        #    return False

        # if no error get the output
        sys.stdout.seek(0)
        result = sys.stdout.read()
        self.report.set_output(result)

        return ok
开发者ID:fredokun,项目名称:MrPython,代码行数:25,代码来源:StudentRunner.py


示例20: ParametersToDialogUpdate

    def ParametersToDialogUpdate(self):
        query = self.query
        self.labelQueryName.setText(query.name)

        # index for param, header param separated from other param
        self.widgetParam = {"header": {}, "param": {}}

        for header_or_param in {"header", "param"}:

            listParam = self.query.param
            if header_or_param == "header":
                listParam = self.query.header

            def sort_param(key):
                return listParam[key]["order"]

            for paramName in sorted(listParam, key=sort_param):  # in listParam:

                # ignore hidden header parameters
                if header_or_param == "header":
                    if paramName in HIDDEN_HEADER_VALUE:
                        continue

                value = listParam[paramName]
                # add param to dialog and index its widget
                self.widgetParam[header_or_param][paramName] = self.addParam(tr(paramName), value)

        # adjust dialog size
        self.setFixedHeight(40 + self.gridLayoutHeader.rowCount() * 25)
开发者ID:hchristol,项目名称:SharedSqlQueries,代码行数:29,代码来源:query_param.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python translate.translate函数代码示例发布时间:2022-05-27
下一篇:
Python translate._函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap