本文整理汇总了Python中qtpy.QtWidgets.QInputDialog类的典型用法代码示例。如果您正苦于以下问题:Python QInputDialog类的具体用法?Python QInputDialog怎么用?Python QInputDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QInputDialog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: validate_password
def validate_password(self):
"""
If the widget is ```passwordProtected```, this method will propmt
the user for the correct password.
Returns
-------
bool
True in case the password was correct of if the widget is not
password protected.
"""
if not self._password_protected:
return True
pwd, ok = QInputDialog().getText(None, "Authentication", "Please enter your password:",
QLineEdit.Password, "")
pwd = str(pwd)
if not ok or pwd == "":
return False
sha = hashlib.sha256()
sha.update(pwd.encode())
pwd_encrypted = sha.hexdigest()
if pwd_encrypted != self._protected_password:
msg = QMessageBox()
msg.setIcon(QMessageBox.Critical)
msg.setText("Invalid password.")
msg.setWindowTitle("Error")
msg.setStandardButtons(QMessageBox.Ok)
msg.setDefaultButton(QMessageBox.Ok)
msg.setEscapeButton(QMessageBox.Ok)
msg.exec_()
return False
return True
开发者ID:slaclab,项目名称:pydm,代码行数:34,代码来源:pushbutton.py
示例2: 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:ShenggaoZhu,项目名称:spyder,代码行数:25,代码来源:explorer.py
示例3: set_umr_namelist
def set_umr_namelist(self):
"""Set UMR excluded modules name list"""
arguments, valid = QInputDialog.getText(self, _('UMR'),
_("Set the list of excluded modules as "
"this: <i>numpy, scipy</i>"),
QLineEdit.Normal,
", ".join(self.get_option('umr/namelist')))
if valid:
arguments = to_text_string(arguments)
if arguments:
namelist = arguments.replace(' ', '').split(',')
fixed_namelist = [module_name for module_name in namelist
if programs.is_module_installed(module_name)]
invalid = ", ".join(set(namelist)-set(fixed_namelist))
if invalid:
QMessageBox.warning(self, _('UMR'),
_("The following modules are not "
"installed on your machine:\n%s"
) % invalid, QMessageBox.Ok)
QMessageBox.information(self, _('UMR'),
_("Please note that these changes will "
"be applied only to new Python/IPython "
"consoles"), QMessageBox.Ok)
else:
fixed_namelist = []
self.set_option('umr/namelist', fixed_namelist)
开发者ID:jitseniesen,项目名称:spyder,代码行数:26,代码来源:maininterpreter.py
示例4: 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:ShenggaoZhu,项目名称:spyder,代码行数:32,代码来源:explorer.py
示例5: change_history_depth
def change_history_depth(self):
"Change history max entries" ""
depth, valid = QInputDialog.getInt(
self, _("History"), _("Maximum entries"), self.get_option("max_entries"), 10, 10000
)
if valid:
self.set_option("max_entries", depth)
开发者ID:silentquasar,项目名称:spyder,代码行数:7,代码来源:history.py
示例6: change_format
def change_format(self):
"""
Ask user for display format for floats and use it.
This function also checks whether the format is valid and emits
`sig_option_changed`.
"""
format, valid = QInputDialog.getText(self, _('Format'),
_("Float formatting"),
QLineEdit.Normal,
self.dataModel.get_format())
if valid:
format = str(format)
try:
format % 1.1
except:
msg = _("Format ({}) is incorrect").format(format)
QMessageBox.critical(self, _("Error"), msg)
return
if not format.startswith('%'):
msg = _("Format ({}) should start with '%'").format(format)
QMessageBox.critical(self, _("Error"), msg)
return
self.dataModel.set_format(format)
self.sig_option_changed.emit('dataframe_format', format)
开发者ID:rlaverde,项目名称:spyder,代码行数:25,代码来源:dataframeeditor.py
示例7: 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:burrbull,项目名称:spyder,代码行数:8,代码来源:plugin.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 = to_text_string(arguments)
return valid
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:8,代码来源:baseshell.py
示例9: 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:ChunHungLiu,项目名称:spyder,代码行数:8,代码来源:history.py
示例10: 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:jitseniesen,项目名称:spyder,代码行数:8,代码来源:console.py
示例11: add_other_dialog
def add_other_dialog(self):
"""
A QAction callback. Start a dialog to choose a name of a function except a peak or a background. The new
function is added to the browser.
"""
selected_name = QInputDialog.getItem(self.canvas, 'Fit', 'Select function', self.other_names, 0, False)
if selected_name[1]:
self.add_other_requested.emit(selected_name[0])
开发者ID:mantidproject,项目名称:mantid,代码行数:8,代码来源:interactive_tool.py
示例12: change_max_line_count
def change_max_line_count(self):
"Change maximum line count"""
mlc, valid = QInputDialog.getInt(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:burrbull,项目名称:spyder,代码行数:9,代码来源:plugin.py
示例13: 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:ShenggaoZhu,项目名称:spyder,代码行数:10,代码来源:explorer.py
示例14: add_peak_dialog
def add_peak_dialog(self):
"""
A QAction callback. Start a dialog to choose a peak function name. After that the tool will expect the user
to click on the canvas to where the peak should be placed.
"""
selected_name = QInputDialog.getItem(self.canvas, 'Fit', 'Select peak function', self.peak_names,
self.peak_names.index(self.current_peak_type), False)
if selected_name[1]:
self.peak_type_changed.emit(selected_name[0])
self.mouse_state.transition_to('add_peak')
开发者ID:mantidproject,项目名称:mantid,代码行数:10,代码来源:interactive_tool.py
示例15: add_background_dialog
def add_background_dialog(self):
"""
A QAction callback. Start a dialog to choose a background function name. The new function is added to the
browser.
"""
current_index = self.background_names.index(self.default_background)
if current_index < 0:
current_index = 0
selected_name = QInputDialog.getItem(self.canvas, 'Fit', 'Select background function', self.background_names,
current_index, False)
if selected_name[1]:
self.add_background_requested.emit(selected_name[0])
开发者ID:mantidproject,项目名称:mantid,代码行数:12,代码来源:interactive_tool.py
示例16: insert_node
def insert_node(self):
index = self.currentIndex()
parentnode = index.internalPointer() or self.model().root
key, b = QInputDialog.getText(
self, "Insert Json node", "Insert key for new node:")
if not b:
return
node = JsonNode(key)
parentnode.add(node)
row = parentnode.index(node)
self.model().beginInsertRows(index, row, row)
self.model().endInsertRows()
开发者ID:MrLeeh,项目名称:jsonwatchqt,代码行数:13,代码来源:objectexplorer.py
示例17: change_format
def change_format(self):
"""Change display format"""
format, valid = QInputDialog.getText(
self, _("Format"), _("Float formatting"), QLineEdit.Normal, self.model.get_format()
)
if valid:
format = str(format)
try:
format % 1.1
except:
QMessageBox.critical(self, _("Error"), _("Format (%s) is incorrect") % format)
return
self.model.set_format(format)
开发者ID:jitseniesen,项目名称:spyder,代码行数:13,代码来源:arrayeditor.py
示例18: edit_key
def edit_key(self):
index = self.currentIndex()
if index.isValid():
node = index.internalPointer()
key, b = QInputDialog.getText(
self, "Edit Json item", "Insert new key for item:",
text=node.key
)
if not b:
return
node.key = key
try: # PyQt5
self.model().dataChanged.emit(index, index, [Qt.DisplayRole])
except TypeError: # PyQt4, PySide
self.model().dataChanged.emit(index, index)
开发者ID:MrLeeh,项目名称:jsonwatchqt,代码行数:18,代码来源:objectexplorer.py
示例19: insert_item
def insert_item(self):
index = self.currentIndex()
if index.isValid():
node = index.internalPointer()
else:
node = self.model().root
key, b = QInputDialog.getText(
self, "Insert Json item", "Insert key for new item:")
if not b:
return
item = JsonItem(key)
node.add(item)
row = node.index(item)
self.model().beginInsertRows(index, row, row)
self.model().endInsertRows()
开发者ID:MrLeeh,项目名称:jsonwatchqt,代码行数:19,代码来源:objectexplorer.py
示例20: _add_fittable_model
def _add_fittable_model(self, model_type):
if issubclass(model_type, models.Polynomial1D):
text, ok = QInputDialog.getInt(self, 'Polynomial1D',
'Enter Polynomial1D degree:')
# User decided not to create a model after all
if not ok:
return
model = model_type(int(text))
else:
model = model_type()
# Grab any user-defined regions so we may initialize parameters only
# for the selected data.
mask = self.hub.region_mask
spec = self._get_selected_plot_data_item().data_item.spectrum
# Initialize the parameters
model = initialize(model, spec.spectral_axis[mask], spec.flux[mask])
self._add_model(model)
开发者ID:nmearl,项目名称:specviz,代码行数:21,代码来源:model_editor.py
注:本文中的qtpy.QtWidgets.QInputDialog类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论