本文整理汇总了Python中spyderlib.utils.qthelpers.translate函数的典型用法代码示例。如果您正苦于以下问题:Python translate函数的具体用法?Python translate怎么用?Python translate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了translate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: show_docstring
def show_docstring(self, text, call=False):
"""Show docstring or arguments"""
if not self.calltips:
return
text = unicode(text) # Useful only for ExternalShellBase
if (self.docviewer is not None) and \
(self.docviewer.dockwidget.isVisible()):
# DocViewer widget exists and is visible
self.docviewer.refresh(text)
self.setFocus() # if docviewer was not at top level, raising it to
# top will automatically give it focus because of
# the visibility_changed signal, so we must give
# focus back to shell
if call:
# Display argument list if this is function call
iscallable = self.iscallable(text)
if iscallable is not None:
if iscallable:
arglist = self.get_arglist(text)
if arglist:
self.show_calltip(translate("PythonShellWidget",
"Arguments"),
arglist, '#129625')
else: # docviewer is not visible
doc = self.get__doc__(text)
if doc is not None:
self.show_calltip(translate("PythonShellWidget",
"Documentation"), doc)
开发者ID:Brainsciences,项目名称:luminoso,代码行数:30,代码来源:shell.py
示例2: get_toolbar_buttons
def get_toolbar_buttons(self):
if self.run_button is None:
self.run_button = create_toolbutton(self, get_icon('run.png'),
translate('ExternalShellBase', "Run"),
tip=translate('ExternalShellBase',
"Run again this program"),
triggered=self.start)
if self.kill_button is None:
self.kill_button = create_toolbutton(self, get_icon('kill.png'),
translate('ExternalShellBase', "Kill"),
tip=translate('ExternalShellBase',
"Kills the current process, "
"causing it to exit immediately"))
buttons = [self.run_button, self.kill_button]
if self.options_button is None:
options = self.get_options_menu()
if options:
self.options_button = create_toolbutton(self,
text=self.tr("Options"),
icon=get_icon('tooloptions.png'))
self.options_button.setPopupMode(QToolButton.InstantPopup)
menu = QMenu(self)
add_actions(menu, options)
self.options_button.setMenu(menu)
if self.options_button is not None:
buttons.insert(1, self.options_button)
return buttons
开发者ID:cheesinglee,项目名称:spyder,代码行数:27,代码来源:__init__.py
示例3: setup_context_menu
def setup_context_menu(self):
"""Setup shell context menu"""
self.menu = QMenu(self)
self.cut_action = create_action(self,
translate("ShellBaseWidget", "Cut"),
shortcut=keybinding('Cut'),
icon=get_icon('editcut.png'),
triggered=self.cut)
self.copy_action = create_action(self,
translate("ShellBaseWidget", "Copy"),
shortcut=keybinding('Copy'),
icon=get_icon('editcopy.png'),
triggered=self.copy)
paste_action = create_action(self,
translate("ShellBaseWidget", "Paste"),
shortcut=keybinding('Paste'),
icon=get_icon('editpaste.png'),
triggered=self.paste)
save_action = create_action(self,
translate("ShellBaseWidget",
"Save history log..."),
icon=get_icon('filesave.png'),
tip=translate("ShellBaseWidget",
"Save current history log (i.e. all "
"inputs and outputs) in a text file"),
triggered=self.save_historylog)
add_actions(self.menu, (self.cut_action, self.copy_action,
paste_action, None, save_action) )
开发者ID:Brainsciences,项目名称:luminoso,代码行数:28,代码来源:shell.py
示例4: insert_item
def insert_item(self):
"""Insert item"""
index = self.currentIndex()
if not index.isValid():
row = self.model.rowCount()
else:
row = index.row()
data = self.model.get_data()
if isinstance(data, list):
key = row
data.insert(row, '')
elif isinstance(data, dict):
key, valid = QInputDialog.getText(self,
translate("DictEditor", 'Insert'),
translate("DictEditor", 'Key:'),
QLineEdit.Normal)
if valid and not key.isEmpty():
key = try_to_eval(unicode(key))
else:
return
else:
return
value, valid = QInputDialog.getText(self,
translate("DictEditor", 'Insert'),
translate("DictEditor", 'Value:'),
QLineEdit.Normal)
if valid and not value.isEmpty():
self.new_value(key, try_to_eval(unicode(value)))
开发者ID:cheesinglee,项目名称:spyder,代码行数:28,代码来源:dicteditor.py
示例5: start
def start(self):
filename = unicode(self.filecombo.currentText())
self.process = QProcess(self)
self.process.setProcessChannelMode(QProcess.SeparateChannels)
self.process.setWorkingDirectory(osp.dirname(filename))
self.connect(self.process, SIGNAL("readyReadStandardOutput()"),
self.read_output)
self.connect(self.process, SIGNAL("readyReadStandardError()"),
lambda: self.read_output(error=True))
self.connect(self.process, SIGNAL("finished(int,QProcess::ExitStatus)"),
self.finished)
self.connect(self.stop_button, SIGNAL("clicked()"),
self.process.kill)
self.output = ''
self.error_output = ''
p_args = [osp.basename(filename)]
self.process.start(PYLINT_PATH, p_args)
running = self.process.waitForStarted()
self.set_running_state(running)
if not running:
QMessageBox.critical(self, translate('Pylint', "Error"),
translate('Pylint', "Process failed to start"))
开发者ID:Brainsciences,项目名称:luminoso,代码行数:25,代码来源:pylintgui.py
示例6: set_user_env
def set_user_env(reg):
"""Set HKCU (current user) environment variables"""
reg = listdict2envdict(reg)
types = dict()
key = OpenKey(HKEY_CURRENT_USER, "Environment")
for name in reg:
try:
_, types[name] = QueryValueEx(key, name)
except WindowsError:
types[name] = REG_EXPAND_SZ
key = OpenKey(HKEY_CURRENT_USER, "Environment", 0, KEY_SET_VALUE)
for name in reg:
SetValueEx(key, name, 0, types[name], reg[name])
try:
from win32gui import SendMessageTimeout
from win32con import HWND_BROADCAST, WM_SETTINGCHANGE, SMTO_ABORTIFHUNG
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "Environment", SMTO_ABORTIFHUNG, 5000)
except ImportError:
QMessageBox.warning(
self,
translate("WinUserEnvDialog", "Warning"),
translate(
"WinUserEnvDialog",
"Module <b>pywin32 was not found</b>.<br>"
"Please restart this Windows <i>session</i> "
"(not the computer) for changes to take effect.",
),
)
开发者ID:cheesinglee,项目名称:spyder,代码行数:29,代码来源:environ.py
示例7: start
def start(self):
self.datelabel.setText('Profiling, please wait...')
filename = unicode(self.filecombo.currentText())
self.process = QProcess(self)
self.process.setProcessChannelMode(QProcess.SeparateChannels)
self.process.setWorkingDirectory(os.path.dirname(filename))
self.connect(self.process, SIGNAL("readyReadStandardOutput()"),
self.read_output)
self.connect(self.process, SIGNAL("readyReadStandardError()"),
lambda: self.read_output(error=True))
self.connect(self.process, SIGNAL("finished(int,QProcess::ExitStatus)"),
self.finished)
self.connect(self.stop_button, SIGNAL("clicked()"),
self.process.kill)
self.output = ''
self.error_output = ''
p_args = [os.path.basename(filename)]
# FIXME: Use the system path to 'python' as opposed to hardwired
p_args = ['-m', PROFILER_PATH, '-o', self.DATAPATH, os.path.basename(filename)]
self.process.start('python', p_args)
running = self.process.waitForStarted()
self.set_running_state(running)
if not running:
QMessageBox.critical(self, translate('Profiler', "Error"),
translate('Profiler', "Process failed to start"))
开发者ID:sjara,项目名称:spyder-profiler,代码行数:29,代码来源:profilergui.py
示例8: __init__
def __init__(self, parent):
PluginWidget.__init__(self, parent)
# Read-only editor
self.editor = QsciEditor(self)
self.editor.setup_editor(linenumbers=False, language='py',
code_folding=True)
self.connect(self.editor, SIGNAL("focus_changed()"),
lambda: self.emit(SIGNAL("focus_changed()")))
self.editor.setReadOnly(True)
self.editor.set_font( get_font(self.ID) )
self.editor.toggle_wrap_mode( CONF.get(self.ID, 'wrap') )
# Add entries to read-only editor context-menu
font_action = create_action(self, translate("Editor", "&Font..."), None,
'font.png',
translate("Editor", "Set font style"),
triggered=self.change_font)
wrap_action = create_action(self, translate("Editor", "Wrap lines"),
toggled=self.toggle_wrap_mode)
wrap_action.setChecked( CONF.get(self.ID, 'wrap') )
self.editor.readonly_menu.addSeparator()
add_actions(self.editor.readonly_menu, (font_action, wrap_action))
# Find/replace widget
self.find_widget = FindReplace(self)
self.find_widget.set_editor(self.editor)
self.find_widget.hide()
开发者ID:Brainsciences,项目名称:luminoso,代码行数:28,代码来源:__init__.py
示例9: _set_step
def _set_step(self,step):
"""Proceed to a given step"""
new_tab = self.tab_widget.currentIndex() + step
assert new_tab < self.tab_widget.count() and new_tab >= 0
if new_tab == self.tab_widget.count()-1:
try:
self.table_widget.open_data(self._get_plain_text(),
self.text_widget.get_col_sep(),
self.text_widget.get_row_sep(),
self.text_widget.trnsp_box.isChecked(),
self.text_widget.get_skiprows(),
self.text_widget.get_comments())
self.done_btn.setEnabled(True)
self.done_btn.setDefault(True)
self.fwd_btn.setEnabled(False)
self.back_btn.setEnabled(True)
except (SyntaxError, AssertionError), error:
QMessageBox.critical(self,
translate("ImportWizard", "Import wizard"),
translate("ImportWizard",
"<b>Unable to proceed to next step</b>"
"<br><br>Please check your entries."
"<br><br>Error message:<br>%2") \
.arg(str(error)))
return
开发者ID:cheesinglee,项目名称:spyder,代码行数:25,代码来源:importwizard.py
示例10: __init__
def __init__(self, parent, data, readonly=False, title="",
names=False, truncate=True, minmax=False,
inplace=False, collvalue=True):
BaseTableView.__init__(self, parent)
self.dictfilter = None
self.readonly = readonly or isinstance(data, tuple)
self.model = None
self.delegate = None
DictModelClass = ReadOnlyDictModel if self.readonly else DictModel
self.model = DictModelClass(self, data, title, names=names,
truncate=truncate, minmax=minmax,
collvalue=collvalue)
self.setModel(self.model)
self.delegate = DictDelegate(self, inplace=inplace)
self.setItemDelegate(self.delegate)
self.setup_table()
self.menu = self.setup_menu(truncate, minmax, inplace, collvalue)
self.copy_action = create_action(self,
translate("DictEditor", "Copy"),
icon=get_icon('editcopy.png'),
triggered=self.copy)
self.paste_action = create_action(self,
translate("DictEditor", "Paste"),
icon=get_icon('editpaste.png'),
triggered=self.paste)
self.menu.insertAction(self.remove_action, self.copy_action)
self.menu.insertAction(self.remove_action, self.paste_action)
self.empty_ws_menu = QMenu(self)
self.empty_ws_menu.addAction(self.paste_action)
开发者ID:Brainsciences,项目名称:luminoso,代码行数:31,代码来源:dicteditor.py
示例11: select_file
def select_file(self):
self.emit(SIGNAL('redirect_stdio(bool)'), False)
filename = QFileDialog.getOpenFileName(self,
translate('Pylint', "Select Python script"), os.getcwdu(),
translate('Pylint', "Python scripts")+" (*.py ; *.pyw)")
self.emit(SIGNAL('redirect_stdio(bool)'), False)
if filename:
self.analyze(filename)
开发者ID:Brainsciences,项目名称:luminoso,代码行数:8,代码来源:pylintgui.py
示例12: get_plugin_actions
def get_plugin_actions(self):
"""Setup actions"""
# Font
font_action = create_action(self, translate('Explorer', "&Font..."),
None, 'font.png',
translate("Explorer", "Set font style"),
triggered=self.change_font)
self.treewidget.common_actions.append(font_action)
return (None, None)
开发者ID:cheesinglee,项目名称:spyder,代码行数:9,代码来源:explorer.py
示例13: __prepare_plot
def __prepare_plot(self):
try:
from matplotlib import rcParams
rcParams['backend'] = 'Qt4agg'
return True
except ImportError:
QMessageBox.warning(self, translate("DictEditor", "Import error"),
translate("DictEditor",
"Please install <b>matplotlib</b>."))
开发者ID:Brainsciences,项目名称:luminoso,代码行数:9,代码来源:dicteditor.py
示例14: get_arguments
def get_arguments(self):
arguments, valid = QInputDialog.getText(self,
translate('ExternalShellBase', 'Arguments'),
translate('ExternalShellBase',
'Command line arguments:'),
QLineEdit.Normal, self.arguments)
if valid:
self.arguments = unicode(arguments)
return valid
开发者ID:cheesinglee,项目名称:spyder,代码行数:9,代码来源:__init__.py
示例15: __prepare_plot
def __prepare_plot(self):
try:
from spyderlib import mpl_patch
mpl_patch.set_backend("Qt4Agg")
mpl_patch.apply()
return True
except ImportError:
QMessageBox.warning(self, translate("DictEditor", "Import error"),
translate("DictEditor",
"Please install <b>matplotlib</b>."))
开发者ID:cheesinglee,项目名称:spyder,代码行数:10,代码来源:dicteditor.py
示例16: imshow_item
def imshow_item(self):
"""Imshow item"""
index = self.currentIndex()
if self.__prepare_plot():
key = self.model.get_key(index)
try:
self.imshow(key)
except ValueError, error:
QMessageBox.critical(self, translate("DictEditor", "Plot"),
translate("DictEditor", "<b>Unable to show image.</b>"
"<br><br>Error message:<br>%1").arg(str(error)))
开发者ID:cheesinglee,项目名称:spyder,代码行数:11,代码来源:dicteditor.py
示例17: edit_filter
def edit_filter(self):
"""Edit name filters"""
filters, valid = QInputDialog.getText(self,
translate('Explorer', 'Edit filename filters'),
translate('Explorer', 'Name filters:'),
QLineEdit.Normal,
", ".join(self.name_filters))
if valid:
filters = [f.strip() for f in unicode(filters).split(',')]
self.parent_widget.emit(SIGNAL('option_changed'),
'name_filters', filters)
self.set_name_filters(filters)
开发者ID:Brainsciences,项目名称:luminoso,代码行数:12,代码来源:explorer.py
示例18: toggle_more_options
def toggle_more_options(self, state):
for layout in self.more_widgets:
for index in range(layout.count()):
layout.itemAt(index).widget().setVisible(state)
if state:
icon_name = 'options_less.png'
tip = translate('FindInFiles', 'Hide advanced options')
else:
icon_name = 'options_more.png'
tip = translate('FindInFiles', 'Show advanced options')
self.more_options.setIcon(get_icon(icon_name))
self.more_options.setToolTip(tip)
开发者ID:cheesinglee,项目名称:spyder,代码行数:12,代码来源:findinfiles.py
示例19: refresh
def refresh(self):
title = translate('Pylint', 'Results for ')+self.filename
self.set_title(title)
self.clear()
self.data = {}
# Populating tree
results = ((translate('Pylint', 'Convention'),
get_icon('convention.png'), self.results['C:']),
(translate('Pylint', 'Refactor'),
get_icon('refactor.png'), self.results['R:']),
(translate('Pylint', 'Warning'),
get_icon('warning.png'), self.results['W:']),
(translate('Pylint', 'Error'),
get_icon('error.png'), self.results['E:']))
for title, icon, messages in results:
title += ' (%d message%s)' % (len(messages),
's' if len(messages)>1 else '')
title_item = QTreeWidgetItem(self, [title])
title_item.setIcon(0, icon)
if not messages:
title_item.setDisabled(True)
modules = {}
for module, lineno, message in messages:
basename = osp.splitext(osp.basename(self.filename))[0]
if not module.startswith(basename):
# Pylint bug
i_base = module.find(basename)
module = module[i_base:]
dirname = osp.dirname(self.filename)
if module.startswith('.'):
modname = osp.join(dirname, module)
else:
modname = osp.join(dirname, *module.split('.'))
if osp.isdir(modname):
modname = osp.join(modname, '__init__')
for ext in ('.py', '.pyw'):
if osp.isfile(modname+ext):
modname = modname + ext
break
if osp.isdir(self.filename):
parent = modules.get(modname)
if parent is None:
item = QTreeWidgetItem(title_item, [module])
item.setIcon(0, get_icon('py.png'))
modules[modname] = item
parent = item
else:
parent = title_item
msg_item = QTreeWidgetItem(parent,
["%d : %s" % (lineno, message)])
msg_item.setIcon(0, get_icon('arrow.png'))
self.data[msg_item] = (modname, lineno)
开发者ID:cheesinglee,项目名称:spyder,代码行数:52,代码来源:pylintgui.py
示例20: set_running_state
def set_running_state(self, state=True):
self.set_buttons_runnning_state(state)
self.shell.setReadOnly(not state)
if state:
self.state_label.setText(translate('ExternalShellBase',
"<span style=\'color: #44AA44\'><b>Running...</b></span>"))
self.t0 = time()
self.connect(self.timer, SIGNAL("timeout()"), self.show_time)
self.timer.start(1000)
else:
self.state_label.setText(translate('ExternalShellBase',
'Terminated.'))
self.disconnect(self.timer, SIGNAL("timeout()"), self.show_time)
开发者ID:cheesinglee,项目名称:spyder,代码行数:13,代码来源:__init__.py
注:本文中的spyderlib.utils.qthelpers.translate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论