本文整理汇总了Python中qtpy.QtWidgets.QMessageBox.warning方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.warning方法的具体用法?Python QMessageBox.warning怎么用?Python QMessageBox.warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QMessageBox
的用法示例。
在下文中一共展示了QMessageBox.warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _sel_to_text
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [as 别名]
def _sel_to_text(self, cell_range):
"""Copy an array portion to a unicode string"""
if not cell_range:
return
row_min, row_max, col_min, col_max = get_idx_rect(cell_range)
if col_min == 0 and col_max == (self.model().cols_loaded-1):
# we've selected a whole column. It isn't possible to
# select only the first part of a column without loading more,
# so we can treat it as intentional and copy the whole thing
col_max = self.model().total_cols-1
if row_min == 0 and row_max == (self.model().rows_loaded-1):
row_max = self.model().total_rows-1
_data = self.model().get_data()
if PY3:
output = io.BytesIO()
else:
output = io.StringIO()
try:
np.savetxt(output, _data[row_min:row_max+1, col_min:col_max+1],
delimiter='\t')
except:
QMessageBox.warning(self, _("Warning"),
_("It was not possible to copy values for "
"this array"))
return
contents = output.getvalue().decode('utf-8')
output.close()
return contents
示例2: set_user_env
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [as 别名]
def set_user_env(reg, parent=None):
"""Set HKCU (current user) environment variables"""
reg = listdict2envdict(reg)
types = dict()
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, "Environment")
for name in reg:
try:
_x, types[name] = winreg.QueryValueEx(key, name)
except WindowsError:
types[name] = winreg.REG_EXPAND_SZ
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, "Environment", 0,
winreg.KEY_SET_VALUE)
for name in reg:
winreg.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(parent, _("Warning"),
_("Module <b>pywin32 was not found</b>.<br>"
"Please restart this Windows <i>session</i> "
"(not the computer) for changes to take effect."))
示例3: set_umr_namelist
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [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: launch_error_message
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [as 别名]
def launch_error_message(self, error_type, error=None):
"""Launch a message box with a predefined error message.
Parameters
----------
error_type : int [CLOSE_ERROR, RESET_ERROR, RESTART_ERROR]
Possible error codes when restarting/reseting spyder.
error : Exception
Actual Python exception error caught.
"""
messages = {CLOSE_ERROR: _("It was not possible to close the previous "
"Spyder instance.\nRestart aborted."),
RESET_ERROR: _("Spyder could not reset to factory "
"defaults.\nRestart aborted."),
RESTART_ERROR: _("It was not possible to restart Spyder.\n"
"Operation aborted.")}
titles = {CLOSE_ERROR: _("Spyder exit error"),
RESET_ERROR: _("Spyder reset error"),
RESTART_ERROR: _("Spyder restart error")}
if error:
e = error.__repr__()
message = messages[error_type] + "\n\n{0}".format(e)
else:
message = messages[error_type]
title = titles[error_type]
self.splash.hide()
QMessageBox.warning(self, title, message, QMessageBox.Ok)
raise RuntimeError(message)
示例5: show_message
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [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)
示例6: get_user_credentials
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [as 别名]
def get_user_credentials(self):
"""Get user credentials with the login dialog."""
password = None
token = None
(username, remember_me,
remember_token) = self._get_credentials_from_settings()
valid_py_os = not (PY2 and sys.platform.startswith('linux'))
if username and remember_me and valid_py_os:
# Get password from keyring
try:
password = keyring.get_password('github', username)
except Exception:
# No safe keyring backend
if self._show_msgbox:
QMessageBox.warning(self.parent_widget,
_('Failed to retrieve password'),
_('It was not possible to retrieve '
'your password. Please introduce '
'it again.'))
if remember_token and valid_py_os:
# Get token from keyring
try:
token = keyring.get_password('github', 'token')
except Exception:
# No safe keyring backend
if self._show_msgbox:
QMessageBox.warning(self.parent_widget,
_('Failed to retrieve token'),
_('It was not possible to retrieve '
'your token. Please introduce it '
'again.'))
if not running_under_pytest():
credentials = DlgGitHubLogin.login(self.parent_widget, username,
password, token, remember_me,
remember_token)
if (credentials['username'] and credentials['password'] and
valid_py_os):
self._store_credentials(credentials['username'],
credentials['password'],
credentials['remember'])
CONF.set('main', 'report_error/remember_me',
credentials['remember'])
if credentials['token'] and valid_py_os:
self._store_token(credentials['token'],
credentials['remember_token'])
CONF.set('main', 'report_error/remember_token',
credentials['remember_token'])
else:
return dict(username=username,
password=password,
token='',
remember=remember_me,
remember_token=remember_token)
return credentials
示例7: _on_fit_clicked
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [as 别名]
def _on_fit_clicked(self, eq_pop_up=True):
if eq_pop_up:
self._on_equation_edit_button_clicked()
# Grab the currently selected plot data item from the data list
plot_data_item = self.hub.plot_item
# If this item is not a model data item, bail
if not isinstance(plot_data_item.data_item, ModelDataItem):
return
data_item = self._get_selected_data_item()
if data_item is None:
return
spectral_region = self.hub.spectral_regions
# Compose the compound model from the model editor sub model tree view
model_editor_model = plot_data_item.data_item.model_editor_model
result = model_editor_model.evaluate()
if result is None:
QMessageBox.warning(self,
"Please add models to fit.",
"Models can be added by clicking the"
" green \"add\" button and selecting a"
" model from the drop-down menu")
return
# Load options
fitter = FITTERS[self.fitting_options["fitter"]]
output_formatter = "{:0.%sg}" % self.fitting_options['displayed_digits']
kwargs = {}
if isinstance(fitter, fitting.LevMarLSQFitter):
kwargs['maxiter'] = self.fitting_options['max_iterations']
kwargs['acc'] = self.fitting_options['relative_error']
kwargs['epsilon'] = self.fitting_options['epsilon']
# Run the compound model through the specutils fitting routine. Ensure
# that the returned values are always in units of the current plot by
# passing in the spectrum with the spectral axis and flux
# converted to plot units.
spectrum = data_item.spectrum.with_spectral_unit(
plot_data_item.spectral_axis_unit)
spectrum = spectrum.new_flux_unit(plot_data_item.data_unit)
# Setup the thread and begin execution.
self.fit_model_thread = FitModelThread(
spectrum=spectrum,
model=result,
fitter=fitter(),
fitter_kwargs=kwargs,
window=spectral_region)
self.fit_model_thread.result.connect(
lambda x, r=result: self._on_fit_model_finished(x, result=r))
self.fit_model_thread.start()
示例8: send_report
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [as 别名]
def send_report(self, title, body, application_log=None):
_logger().debug('sending bug report on github\ntitle=%s\nbody=%s',
title, body)
# Credentials
credentials = self.get_user_credentials()
username = credentials['username']
password = credentials['password']
remember = credentials['remember']
token = credentials['token']
remember_token = credentials['remember_token']
if username is None and password is None and token is None:
return False
_logger().debug('got user credentials')
# upload log file as a gist
if application_log:
url = self.upload_log_file(application_log)
body += '\nApplication log: %s' % url
try:
if token:
gh = github.GitHub(access_token=token)
else:
gh = github.GitHub(username=username, password=password)
repo = gh.repos(self.gh_owner)(self.gh_repo)
ret = repo.issues.post(title=title, body=body)
except github.ApiError as e:
_logger().warning('Failed to send bug report on Github. '
'response=%r', e.response)
# invalid credentials
if e.response.code == 401:
if self._show_msgbox:
QMessageBox.warning(
self.parent_widget, _('Invalid credentials'),
_('Failed to create Github issue, '
'invalid credentials...'))
else:
# other issue
if self._show_msgbox:
QMessageBox.warning(
self.parent_widget,
_('Failed to create issue'),
_('Failed to create Github issue. Error %d') %
e.response.code)
return False
else:
issue_nbr = ret['number']
if self._show_msgbox:
ret = QMessageBox.question(
self.parent_widget, _('Issue created on Github'),
_('Issue successfully created. Would you like to open the '
'issue in your web browser?'))
if ret in [QMessageBox.Yes, QMessageBox.Ok]:
webbrowser.open(
'https://github.com/%s/%s/issues/%d' % (
self.gh_owner, self.gh_repo, issue_nbr))
return True
示例9: _on_remove
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [as 别名]
def _on_remove(self):
selection = self._table.selectionModel().selection().indexes()
if len(selection) == 0:
QMessageBox.warning(self, "Specimen position", "Select a position")
return
model = self._table.model()
for row in sorted(map(methodcaller('row'), selection), reverse=True):
model.removeRow(row)
示例10: set_state
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [as 别名]
def set_state(self, state):
"""
Populate the UI elements with the data from the given state.
@param state: Transmission object
"""
popup_warning = ""
# Beam finder
if state.x_position is not None and state.y_position is not None:
self._content.x_pos_edit.setText(str("%6.4f" % state.x_position))
self._content.y_pos_edit.setText(str("%6.4f" % state.y_position))
self._content.use_beam_finder_checkbox.setChecked(state.use_finder)
self._content.beam_data_file_edit.setText(state.beam_file)
self._content.beam_radius_edit.setText(str(state.beam_radius))
if not self._settings.debug and not self._settings.advanced and not state.use_direct_beam:
# Warn the user if we're about to set an option that is not seen!
popup_warning += "The reduction you are loading has advanced options for finding the beam center.\n"
popup_warning += "Use the advanced interface to see all option. Those options will now be skipped."
state.use_direct_beam = True
self._content.direct_beam.setChecked(state.use_direct_beam)
self._content.scattering_data.setChecked(not state.use_direct_beam)
self._content.beam_radius_edit.setEnabled(not state.use_direct_beam)
self._use_beam_finder_changed(state.use_finder)
# Sensitivity
self._content.sensitivity_file_edit.setText(state.sensitivity_data)
self._content.sensitivity_chk.setChecked(state.sensitivity_corr)
self._sensitivity_clicked(state.sensitivity_corr)
self._content.min_sensitivity_edit.setText(str(state.min_sensitivity))
self._content.max_sensitivity_edit.setText(str(state.max_sensitivity))
if not self._use_sample_dc:
self._content.sensitivity_dark_file_edit.setText(state.sensitivity_dark)
if not self._settings.debug and not self._settings.advanced and not state.use_sample_beam_center:
# Warn the user if we're about to set an option that is not seen!
popup_warning += "The reduction you are loading has advanced options for the flood field beam center.\n"
popup_warning += "Use the advanced interface to see all option. Those options will now be skipped."
state.use_sample_beam_center = True
self._content.use_sample_center_checkbox.setChecked(state.use_sample_beam_center)
self._content.x_pos_edit_2.setText(str("%6.4f" % state.flood_x_position))
self._content.y_pos_edit_2.setText(str("%6.4f" % state.flood_y_position))
self._content.use_beam_finder_checkbox_2.setChecked(state.flood_use_finder)
self._content.beam_data_file_edit_2.setText(state.flood_beam_file)
self._content.beam_radius_edit_2.setText(str(state.flood_beam_radius))
self._content.direct_beam_2.setChecked(state.flood_use_direct_beam)
self._content.scattering_data_2.setChecked(not state.flood_use_direct_beam)
self._content.beam_radius_edit_2.setEnabled(not state.flood_use_direct_beam)
self._sensitivity_clicked(self._content.sensitivity_chk.isChecked())
self._use_sample_center_changed(self._content.use_sample_center_checkbox.isChecked())
if len(popup_warning)>0:
QMessageBox.warning(self, "Turn ON advanced interface", popup_warning)
示例11: _warning
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [as 别名]
def _warning(self, title, message):
"""
Pop up a dialog and warn the user
@param title: dialog box title
@param message: message to be displayed
#TODO: change this to signals and slots mechanism
"""
if len(self.widgets)>0:
QMessageBox.warning(self.widgets[0], title, message)
示例12: edit_expression
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [as 别名]
def edit_expression(self):
"""Edit selected expression in main dialog"""
if not self.list_derived_components.currentItem():
QMessageBox.warning(self, "No Spectrum1D Objects",
"No selected expression to edit!")
else:
current_item = self.list_derived_components.currentItem()
label = current_item.text(0)
equation = current_item.text(1)
self.editor = EquationEditor(self, label=label, equation=equation, parent=self)
示例13: remove_expression
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [as 别名]
def remove_expression(self):
"""Remove selected expression in main diaglog"""
if not self.list_derived_components.currentItem():
QMessageBox.warning(self, "No Spectrum1D Objects",
"No selected expression to remove!")
else:
# Get current selected item and it's index in the QTreeWidget.
current_item = self.list_derived_components.currentItem()
index = self.list_derived_components.indexOfTopLevelItem(current_item)
self.list_derived_components.takeTopLevelItem(index)
示例14: open_output_file_if_writable
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [as 别名]
def open_output_file_if_writable(self, full_output_file_name):
_o_file = FileHandler(filename=full_output_file_name)
if _o_file.is_file_writable():
outfile = open(full_output_file_name, "w")
else:
title = "No write permissions!"
error_msg = "Unable to write cached table. " + \
"Will not be able to write output files to this directory. " + \
"\n\nCheck file and directory for write permissions!"
QMessageBox.warning(self.parent, title, error_msg)
outfile = None
return outfile
示例15: run
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import warning [as 别名]
def run(self):
try:
o_generate = GenerateSumthing(parent=self.parent,
folder=self.parent.current_folder)
o_generate.create_sum_inp_file()
self.read_auto_sum_file()
self.populate_table()
except IOError:
QMessageBox.warning(self.parent, "File does not exist!", "Check your folder! ")
self.error_reported = True