本文整理汇总了Python中spyderlib.qt.QtGui.QInputDialog类的典型用法代码示例。如果您正苦于以下问题:Python QInputDialog类的具体用法?Python QInputDialog怎么用?Python QInputDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QInputDialog类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: rename_file
def rename_file(self, fname):
"""Rename file"""
path, valid = QInputDialog.getText(self, _("Rename"), _("New name:"), QLineEdit.Normal, osp.basename(fname))
if valid:
path = osp.join(osp.dirname(fname), to_text_string(path))
if path == fname:
return
if osp.exists(path):
if (
QMessageBox.warning(
self,
_("Rename"),
_("Do you really want to rename <b>%s</b> and " "overwrite the existing file <b>%s</b>?")
% (osp.basename(fname), osp.basename(path)),
QMessageBox.Yes | QMessageBox.No,
)
== QMessageBox.No
):
return
try:
misc.rename_file(fname, path)
self.parent_widget.renamed.emit(fname, path)
return path
except EnvironmentError as error:
QMessageBox.critical(
self,
_("Rename"),
_("<b>Unable to rename file <i>%s</i></b>" "<br><br>Error message:<br>%s")
% (osp.basename(fname), to_text_string(error)),
)
开发者ID:sonofeft,项目名称:spyder,代码行数:30,代码来源:explorer.py
示例2: create_new_folder
def create_new_folder(self, current_path, title, subtitle, is_package):
"""Create new folder"""
if current_path is None:
current_path = ""
if osp.isfile(current_path):
current_path = osp.dirname(current_path)
name, valid = QInputDialog.getText(self, title, subtitle, QLineEdit.Normal, "")
if valid:
dirname = osp.join(current_path, to_text_string(name))
try:
os.mkdir(dirname)
except EnvironmentError as error:
QMessageBox.critical(
self,
title,
_("<b>Unable " "to create folder <i>%s</i></b>" "<br><br>Error message:<br>%s")
% (dirname, to_text_string(error)),
)
finally:
if is_package:
fname = osp.join(dirname, "__init__.py")
try:
with open(fname, "wb") as f:
f.write(to_binary_string("#"))
return dirname
except EnvironmentError as error:
QMessageBox.critical(
self,
title,
_("<b>Unable " "to create file <i>%s</i></b>" "<br><br>Error message:<br>%s")
% (fname, to_text_string(error)),
)
开发者ID:sonofeft,项目名称:spyder,代码行数:32,代码来源:explorer.py
示例3: edit_parameters
def edit_parameters(self):
allaxes = self.canvas.figure.get_axes()
if len(allaxes) == 1:
axes = allaxes[0]
elif len(allaxes) > 1:
titles = []
for axes in allaxes:
title = axes.get_title()
ylabel = axes.get_ylabel()
if title:
text = title
if ylabel:
text += ": "+ylabel
text += " (%s)"
elif ylabel:
text = ylabel+" (%s)"
else:
text = "%s"
titles.append(text % repr(axes))
item, ok = QInputDialog.getItem(self, 'Customize',
'Select axes:', titles,
0, False)
if ok:
axes = allaxes[titles.index(unicode(item))]
else:
return
else:
return
figure_edit(axes, self)
开发者ID:jromang,项目名称:retina-old,代码行数:29,代码来源:mpl_patch.py
示例4: get_arguments
def get_arguments(self):
arguments, valid = QInputDialog.getText(
self, _("Arguments"), _("Command line arguments:"), QLineEdit.Normal, self.arguments
)
if valid:
self.arguments = to_text_string(arguments)
return valid
开发者ID:gyenney,项目名称:Tools,代码行数:7,代码来源:baseshell.py
示例5: change_history_depth
def change_history_depth(self):
"Change history max entries" ""
depth, valid = QInputDialog.getInteger(
self, _("History"), _("Maximum entries"), self.get_option("max_entries"), 10, 10000
)
if valid:
self.set_option("max_entries", depth)
开发者ID:ymarfoq,项目名称:outilACVDesagregation,代码行数:7,代码来源:history.py
示例6: change_exteditor
def change_exteditor(self):
"""Change external editor path"""
path, valid = QInputDialog.getText(self, _('External editor'),
_('External editor executable path:'),
QLineEdit.Normal,
self.get_option('external_editor/path'))
if valid:
self.set_option('external_editor/path', to_text_string(path))
开发者ID:Micseb,项目名称:spyder,代码行数:8,代码来源:console.py
示例7: change_max_line_count
def change_max_line_count(self):
"Change maximum line count" ""
mlc, valid = QInputDialog.getInteger(
self, _("Buffer"), _("Maximum line count"), self.get_option("max_line_count"), 0, 1000000
)
if valid:
self.shell.setMaximumBlockCount(mlc)
self.set_option("max_line_count", mlc)
开发者ID:gyenney,项目名称:Tools,代码行数:8,代码来源:console.py
示例8: get_arguments
def get_arguments(self):
arguments, valid = QInputDialog.getText(self, _('Arguments'),
_('Command line arguments:'),
QLineEdit.Normal,
self.arguments)
if valid:
self.arguments = unicode(arguments)
return valid
开发者ID:jromang,项目名称:retina-old,代码行数:8,代码来源:baseshell.py
示例9: edit_filter
def edit_filter(self):
"""Edit name filters"""
filters, valid = QInputDialog.getText(
self, _("Edit filename filters"), _("Name filters:"), QLineEdit.Normal, ", ".join(self.name_filters)
)
if valid:
filters = [f.strip() for f in to_text_string(filters).split(",")]
self.parent_widget.sig_option_changed.emit("name_filters", filters)
self.set_name_filters(filters)
开发者ID:sonofeft,项目名称:spyder,代码行数:9,代码来源:explorer.py
示例10: edit_filter
def edit_filter(self):
"""Edit name filters"""
filters, valid = QInputDialog.getText(self, _('Edit filename filters'),
_('Name filters:'),
QLineEdit.Normal,
", ".join(self.name_filters))
if valid:
filters = [f.strip() for f in unicode(filters).split(',')]
self.parent_widget.sig_option_changed.emit('name_filters', filters)
self.set_name_filters(filters)
开发者ID:jromang,项目名称:retina-old,代码行数:10,代码来源:explorer.py
示例11: change_format
def change_format(self):
"""Change display format"""
format, valid = QInputDialog.getText(
self, _("Format"), _("Float formatting"), QLineEdit.Normal, self.dataModel.get_format()
)
if valid:
format = str(format)
try:
format % 1.1
except:
QMessageBox.critical(self, _("Error"), _("Format (%s) is incorrect") % format)
return
self.dataModel.set_format(format)
开发者ID:arvindchari88,项目名称:newGitTest,代码行数:13,代码来源:dataframeeditor.py
示例12: create_new_folder
def create_new_folder(self, current_path, title, subtitle, is_package):
"""Create new folder"""
if current_path is None:
current_path = ''
if osp.isfile(current_path):
current_path = osp.dirname(current_path)
name, valid = QInputDialog.getText(self, title, subtitle,
QLineEdit.Normal, "")
if valid:
dirname = osp.join(current_path, unicode(name))
try:
os.mkdir(dirname)
except EnvironmentError, error:
QMessageBox.critical(self, title,
_("<b>Unable "
"to create folder <i>%s</i></b>"
"<br><br>Error message:<br>%s"
) % (dirname, unicode(error)))
finally:
开发者ID:jromang,项目名称:retina-old,代码行数:19,代码来源:explorer.py
示例13: import_data
def import_data(self, filenames=None):
"""Import data from text file"""
title = _("Import data")
if filenames is None:
if self.filename is None:
basedir = getcwd()
else:
basedir = osp.dirname(self.filename)
filenames, _selfilter = getopenfilenames(self, title, basedir,
iofunctions.load_filters)
if not filenames:
return
elif is_text_string(filenames):
filenames = [filenames]
for filename in filenames:
self.filename = to_text_string(filename)
ext = osp.splitext(self.filename)[1].lower()
if ext not in iofunctions.load_funcs:
buttons = QMessageBox.Yes | QMessageBox.Cancel
answer = QMessageBox.question(self, title,
_("<b>Unsupported file extension '%s'</b><br><br>"
"Would you like to import it anyway "
"(by selecting a known file format)?"
) % ext, buttons)
if answer == QMessageBox.Cancel:
return
formats = list(iofunctions.load_extensions.keys())
item, ok = QInputDialog.getItem(self, title,
_('Open file as:'),
formats, 0, False)
if ok:
ext = iofunctions.load_extensions[to_text_string(item)]
else:
return
load_func = iofunctions.load_funcs[ext]
# 'import_wizard' (self.setup_io)
if is_text_string(load_func):
# Import data with import wizard
error_message = None
try:
text, _encoding = encoding.read(self.filename)
if self.is_internal_shell:
self.editor.import_from_string(text)
else:
base_name = osp.basename(self.filename)
editor = ImportWizard(self, text, title=base_name,
varname=fix_reference_name(base_name))
if editor.exec_():
var_name, clip_data = editor.get_data()
monitor_set_global(self._get_sock(),
var_name, clip_data)
except Exception as error:
error_message = str(error)
else:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
QApplication.processEvents()
if self.is_internal_shell:
namespace, error_message = load_func(self.filename)
interpreter = self.shellwidget.interpreter
for key in list(namespace.keys()):
new_key = fix_reference_name(key,
blacklist=list(interpreter.namespace.keys()))
if new_key != key:
namespace[new_key] = namespace.pop(key)
if error_message is None:
interpreter.namespace.update(namespace)
else:
error_message = monitor_load_globals(self._get_sock(),
self.filename, ext)
QApplication.restoreOverrideCursor()
QApplication.processEvents()
if error_message is not None:
QMessageBox.critical(self, title,
_("<b>Unable to load '%s'</b>"
"<br><br>Error message:<br>%s"
) % (self.filename, error_message))
self.refresh_table()
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:82,代码来源:namespacebrowser.py
示例14: create_client_for_kernel
def create_client_for_kernel(self):
"""Create a client connected to an existing kernel"""
example = _("(for example: kernel-3764.json, or simply 3764)")
while True:
cf, valid = QInputDialog.getText(self, _('IPython'),
_('Provide an IPython kernel connection file:')+\
'\n'+example,
QLineEdit.Normal)
if valid:
cf = str(cf)
match = re.match('(kernel-|^)([a-fA-F0-9-]+)(.json|$)', cf)
if match is not None:
kernel_num = match.groups()[1]
if kernel_num:
cf = 'kernel-%s.json' % kernel_num
break
else:
return
# Generating the client name and setting kernel_widget_id
match = re.match('^kernel-([a-fA-F0-9-]+).json', cf)
count = 0
kernel_widget_id = None
while True:
client_name = match.groups()[0]
if '-' in client_name: # Avoid long names
client_name = client_name.split('-')[0]
client_name = client_name + '/' + chr(65+count)
for cl in self.get_clients():
if cl.name == client_name:
kernel_widget_id = cl.kernel_widget_id
break
else:
break
count += 1
# Trying to get kernel_widget_id from the currently opened kernels if
# the previous procedure fails. This could happen when the first
# client connected to a kernel is closed but the kernel is left open
# and you try to connect new clients to it
if kernel_widget_id is None:
for sw in self.extconsole.shellwidgets:
if sw.connection_file == cf:
kernel_widget_id = id(sw)
# Verifying if the kernel exists
try:
find_connection_file(cf, profile='default')
except (IOError, UnboundLocalError):
QMessageBox.critical(self, _('IPython'),
_("Unable to connect to IPython <b>%s") % cf)
return
# Verifying if frontend and kernel have compatible versions
if not self.kernel_and_frontend_match(cf):
QMessageBox.critical(self,
_("Mismatch between kernel and frontend"),
_("Your IPython frontend and kernel versions "
"are <b>incompatible!!</b>"
"<br><br>"
"We're sorry but we can't create an IPython "
"console for you."
), QMessageBox.Ok)
return
# Creating the client
client = IPythonClient(self, history_filename='history.py',
connection_file=cf,
kernel_widget_id=kernel_widget_id,
menu_actions=self.menu_actions)
self.add_tab(client, name=client.get_name())
self.register_client(client, client_name)
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:72,代码来源:ipythonconsole.py
注:本文中的spyderlib.qt.QtGui.QInputDialog类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论