本文整理汇总了Python中spyderlib.qt.QtGui.QInputDialog.getText方法的典型用法代码示例。如果您正苦于以下问题:Python QInputDialog.getText方法的具体用法?Python QInputDialog.getText怎么用?Python QInputDialog.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.qt.QtGui.QInputDialog
的用法示例。
在下文中一共展示了QInputDialog.getText方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rename_file
# 需要导入模块: from spyderlib.qt.QtGui import QInputDialog [as 别名]
# 或者: from spyderlib.qt.QtGui.QInputDialog import getText [as 别名]
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)),
)
示例2: create_new_folder
# 需要导入模块: from spyderlib.qt.QtGui import QInputDialog [as 别名]
# 或者: from spyderlib.qt.QtGui.QInputDialog import getText [as 别名]
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)),
)
示例3: get_arguments
# 需要导入模块: from spyderlib.qt.QtGui import QInputDialog [as 别名]
# 或者: from spyderlib.qt.QtGui.QInputDialog import getText [as 别名]
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
示例4: change_exteditor
# 需要导入模块: from spyderlib.qt.QtGui import QInputDialog [as 别名]
# 或者: from spyderlib.qt.QtGui.QInputDialog import getText [as 别名]
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))
示例5: get_arguments
# 需要导入模块: from spyderlib.qt.QtGui import QInputDialog [as 别名]
# 或者: from spyderlib.qt.QtGui.QInputDialog import getText [as 别名]
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
示例6: edit_filter
# 需要导入模块: from spyderlib.qt.QtGui import QInputDialog [as 别名]
# 或者: from spyderlib.qt.QtGui.QInputDialog import getText [as 别名]
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)
示例7: edit_filter
# 需要导入模块: from spyderlib.qt.QtGui import QInputDialog [as 别名]
# 或者: from spyderlib.qt.QtGui.QInputDialog import getText [as 别名]
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)
示例8: change_format
# 需要导入模块: from spyderlib.qt.QtGui import QInputDialog [as 别名]
# 或者: from spyderlib.qt.QtGui.QInputDialog import getText [as 别名]
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)
示例9: create_new_folder
# 需要导入模块: from spyderlib.qt.QtGui import QInputDialog [as 别名]
# 或者: from spyderlib.qt.QtGui.QInputDialog import getText [as 别名]
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:
示例10: create_client_for_kernel
# 需要导入模块: from spyderlib.qt.QtGui import QInputDialog [as 别名]
# 或者: from spyderlib.qt.QtGui.QInputDialog import getText [as 别名]
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)