本文整理汇总了Python中qtpy.QtWidgets.QMessageBox.information方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.information方法的具体用法?Python QMessageBox.information怎么用?Python QMessageBox.information使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QMessageBox
的用法示例。
在下文中一共展示了QMessageBox.information方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_register_new_loader
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
def save_register_new_loader(self, filename):
"""
Save and register new loader file to specutils loader directory.
If a loader with the current name already exists it will be
deleted.
Parameters
----------
filename: str
Loader filename. If filename does not end in ".py", ".py" will be appended
to the end of the string.
"""
filename = "{}.py".format(filename) if not filename.endswith(".py") else filename
string = self.as_new_loader()
with open(filename, 'w') as f:
f.write(string)
# If a loader by this name exists, delete it
if self.new_loader_dict['name'] in registry.get_formats()['Format']:
registry.unregister_reader(self.new_loader_dict['name'], Spectrum1D)
registry.unregister_identifier(self.new_loader_dict['name'], Spectrum1D)
# Add new loader to registry
spec = importlib.util.spec_from_file_location(os.path.basename(filename)[:-3], filename)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
QMessageBox.information(self,
"Loader saved successful.",
"Custom loader was saved successfully.")
示例2: save_loader_script
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
def save_loader_script(self, event=None, output_directory=None):
"""
oputput_directory parameter is strictly for use in tests.
"""
if not self.save_loader_check():
return
specutils_dir = os.path.join(os.path.expanduser('~'), '.specutils')
if not os.path.exists(specutils_dir):
os.mkdir(specutils_dir)
loader_name = self.ui.loader_name.text()
# If the loader name already exists in the registry, raise a warning
# and ask the user to pick another name
if loader_name in registry.get_formats(Spectrum1D, 'Read')['Format']:
QMessageBox.information(
self,
"Loader name already exists.",
"A loader with the name '{}' already exists in the registry. "
"Please choose a different name.".format(loader_name))
return
out_path = os.path.join(specutils_dir, loader_name)
filename = compat.getsavefilename(parent=self,
caption='Export loader to .py file',
basedir=out_path)[0]
if filename == '':
return
self.save_register_new_loader(filename)
示例3: set_umr_namelist
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
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)
示例4: call_cutout
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
def call_cutout(self):
self.spec_path = self.spectra_user_input.text()
if self.spec_path == "":
self.spectra_user_input.setStyleSheet("background-color: rgba(255, 0, 0, 128);")
info = QMessageBox.information(self, "Error", "Please provide directory containing NIRSpec spectra files.")
return
else:
self.spectra_user_input.setStyleSheet("")
if not os.path.isdir(self.spec_path):
self.spectra_user_input.setStyleSheet("background-color: rgba(255, 0, 0, 128);")
info = QMessageBox.information(self, "Error", "Broken path:\n\n"+self.spec_path)
return
if self.CutoutTool is not None:
if self.CutoutTool.isVisible():
info = QMessageBox.information(self, "Status",
"Error: Cutout tool is still running.")
self.CutoutTool.raise_()
return
else:
self.CutoutTool = None
try:
self.CutoutTool = NIRSpecCutoutTool(self.parent.session,
parent=self, spec_path=self.spec_path, TableGen=self)
except Exception as e:
info = QMessageBox.critical(self, "Error", "Cutout tool failed: "+str(e))
示例5: action_released
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
def action_released(self):
""" """
model = self.source_model
model_index = self._model_index_clicked
if model_index:
column = model_index.column()
if column == const.INSTALL and model.is_removable(model_index):
column = const.REMOVE
self.source_model.update_row_icon(model_index.row(), column)
if self.valid:
row_data = self.source_model.row(model_index.row())
type_ = row_data[const.PACKAGE_TYPE]
name = row_data[const.NAME]
versions = self.source_model.get_package_versions(name)
version = self.source_model.get_package_version(name)
if type_ == const.CONDA:
self._parent._run_action(name, column, version, versions)
elif type_ == const.PIP:
QMessageBox.information(self, "Remove pip package: "
"{0}".format(name),
"This functionality is not yet "
"available.")
else:
pass
示例6: restart_message
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
def restart_message(self):
"""
Print a restart message when the client is connected to an external
kernel
"""
message = _("Kernel process is either remote or unspecified. "
"Cannot restart.")
QMessageBox.information(self, "IPython", message)
示例7: pop_one_button_dialog
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
def pop_one_button_dialog(self, message):
""" Pop up a one-button dialog
:param message:
:return:
"""
assert isinstance(message, str), 'Input message %s must a string but not %s.' \
'' % (str(message), type(message))
QMessageBox.information(self, '4-circle Data Reduction', message)
示例8: show_message
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
def show_message(is_checked):
if is_checked or not msg_if_enabled:
if msg_warning is not None:
QMessageBox.warning(self, self.get_name(),
msg_warning, QMessageBox.Ok)
if msg_info is not None:
QMessageBox.information(self, self.get_name(),
msg_info, QMessageBox.Ok)
示例9: on_mouseDownEvent
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
def on_mouseDownEvent(self, event):
""" Respond to pick up a value with mouse down event
"""
x = event.xdata
y = event.ydata
if x is not None and y is not None:
msg = "You've clicked on a bar with coords:\n %f, %f" % (x, y)
QMessageBox.information(self, "Click!", msg)
示例10: focusInEvent
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
def focusInEvent(self, event):
if self.handle_focus:
self.handle_focus = False
tab = self.ui.tabWidget.currentWidget()
if tab is not None and tab.is_modified():
msg = 'The file \'%s\' has been changed on the file system. Do you want to replace the editor contents with these changes?' % tab.filename
msg += "\n\n" + "\n".join(["Diff in line %d:\nIn script: %s\nIn file: %s\n" % (lnr, l1, l2) for lnr, (l1, l2) in enumerate(zip(tab.get_script().split("\n"), tab.saved().split("\n"))) if l1.strip() != l2.strip()][:5])
if QMessageBox.information(self, 'File changed', msg, QMessageBox.Yes | QMessageBox.No) == QMessageBox.Yes:
tab.reload()
else:
tab.filemodified = os.path.getmtime(tab.filename)
self.handle_focus = True
示例11: set_umr_namelist
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
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 = []
non_ascii_namelist = []
for module_name in namelist:
if PY2:
if all(ord(c) < 128 for c in module_name):
if programs.is_module_installed(module_name):
fixed_namelist.append(module_name)
else:
QMessageBox.warning(self, _('Warning'),
_("You are working with Python 2, this means that "
"you can not import a module that contains non-"
"ascii characters."), QMessageBox.Ok)
non_ascii_namelist.append(module_name)
elif programs.is_module_installed(module_name):
fixed_namelist.append(module_name)
invalid = ", ".join(set(namelist)-set(fixed_namelist)-
set(non_ascii_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)
示例12: _on_save_model
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
def _on_save_model(self, interactive=True):
model_editor_model = self.hub.data_item.model_editor_model
# There are no models to save
if not model_editor_model.fittable_models:
QMessageBox.warning(self,
'No model available',
'No model exists to be saved.')
return
default_name = os.path.join(os.path.curdir, 'new_model.smf')
outfile = QFileDialog.getSaveFileName(
self, caption='Save Model', directory=default_name,
filter=SPECVIZ_MODEL_FILE_FILTER)[0]
# No file was selected; the user hit "Cancel"
if not outfile:
return
self._save_models(outfile)
QMessageBox.information(self,
'Model saved',
'Model successfully saved to {}'.format(outfile))
示例13: _write_skipped
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
def _write_skipped(self, skipped):
"""
Save a list of skipped spectra files to file.
"""
name = ".".join(self.save_file_name.split(".")[:-1])
file_name = "skipped_files_%s.txt" %name
with open(file_name, "w") as f:
for items in skipped:
line = " : ".join(items)+"\n"
f.write(line)
info = QMessageBox.information(self, "Info", "Some spectra files were not included in the generated MOSViz Table."
" A list of the these files and the reason they were skipped has been saved to\n\n "
" %s. " %file_name)
示例14: update_comments
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
def update_comments(self, pastSelection = False):
"""
Process comment and flag changes and save to file.
Parameters
----------
pastSelection : bool
True when updating past selections. Used when
user forgets to save.
"""
if self.input_flag.text() == "":
self.input_flag.setStyleSheet("background-color: rgba(255, 0, 0);")
return
i = None
try:
i = int(self.input_flag.text())
except ValueError:
self.input_flag.setStyleSheet("background-color: rgba(255, 0, 0);")
info = QMessageBox.information(self, "Status:", "Flag must be an int!")
return
self.input_flag.setStyleSheet("background-color: rgba(255, 255, 255);")
idx = self.data_idx
if pastSelection:
i = self.textChangedAt
self.textChangedAt = None
else:
i = self.toolbar.source_select.currentIndex()
i = self._index_hash(i)
data = self.session.data_collection[idx]
comp = data.get_component("comments")
comp.labels.flags.writeable = True
comp.labels[i] = self.input_comments.toPlainText()
comp = data.get_component("flag")
comp.labels.flags.writeable = True
comp.labels[i] = self.input_flag.text()
self.send_NumericalDataChangedMessage()
self.write_comments()
self.textChangedAt = None
示例15: call_main
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import information [as 别名]
def call_main(self):
"""
Calls the main function and handles exceptions.
"""
if self.CutoutTool is not None:
if self.CutoutTool.isVisible():
info = QMessageBox.information(self, "Status",
"Error: Cutout tool is still running.")
self.CutoutTool.raise_()
return
else:
self.CutoutTool = None
cwd = os.getcwd()
try:
self.main()
os.chdir(cwd)
except Exception as e:
info = QMessageBox.critical(self, "Error", str(e))
self.close()
os.chdir(cwd)
raise