def error_message(exception,
text="An error occurred when processing your request",
title="Error"):
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setText(text)
msg.setWindowTitle(title)
msg.setDetailedText(str(exception))
msg.setStandardButtons(QMessageBox.Ok)
msg.exec_()
python类information()的实例源码
def process_refresh(self, row, process):
"""
Refresh a process configuration file
"""
if process.state() == QProcess.Running:
msgbox = QMessageBox()
msgbox.setIcon(QMessageBox.Information)
msgbox.setWindowTitle('NOTICE')
msgbox.setText('%s is currently running: you need to stop it to refresh the configuration file.' % process.name)
msgbox.setStandardButtons(QMessageBox.Ok)
msgbox.exec_()
else:
process.config = process.config_path
self.paint_row(row)
def minimize_in_system_tray(self):
"""
Minimize B3 in system tray icon
"""
if b3.getPlatform() != 'linux':
# do not use system tray on linux since it looks bad on Ubuntu
# which is the mainly used Linux client distribution (they can live without it)
self.hide()
if not self.system_tray_minimized:
self.system_tray_minimized = True
self.system_tray.showMessage("B3 is still running!",
self.system_tray_balloon[b3.getPlatform()],
QSystemTrayIcon.Information, 20000)
############################################# ACTION HANDLERS ######################################################
def savefile(self):
tempfilename = 'TemperatureData.csv'
filepath = QFileDialog.getExistingDirectory(self, 'Choose Directory', os.sep.join((os.path.expanduser('~'), 'Desktop')))
self.y_variablename = 'TemperatureSensor'
MultiPlot.SaveToCsv(self.tf, tempfilename, filepath, len(self.ids), self.y_variablename)
mb = QMessageBox()
mb.setIcon(QMessageBox.Information)
mb.setWindowTitle('Information')
mb.setText('File saved to directory.')
mb.setStandardButtons(QMessageBox.Ok)
mb.show()
def begin_async_check(parent):
if not _should_continue():
logger.info('Update check skipped')
return
update_reference = None
def check_from_gui_thread():
if background_thread.is_alive():
logger.info('Update checker is still running...')
else:
gui_timer.stop()
logger.info('Update checker stopped')
if update_reference is None:
return
mbox = QMessageBox(parent)
mbox.setWindowTitle('Update Available')
mbox.setText('New version is available.<br><br>%s' % update_reference)
mbox.setIcon(QMessageBox.Information)
mbox.setStandardButtons(QMessageBox.Ok)
mbox.exec()
def do_background_check():
nonlocal update_reference
# noinspection PyBroadException
try:
if RUNNING_ON_WINDOWS:
update_reference = _do_windows_check()
else:
update_reference = _do_pip_check()
logger.info('Update reference: %r', update_reference)
except Exception:
logger.error('Update checker failed', exc_info=True)
background_thread = threading.Thread(target=do_background_check, name='update_checker', daemon=True)
background_thread.start()
gui_timer = QTimer(parent)
gui_timer.setSingleShot(False)
gui_timer.timeout.connect(check_from_gui_thread)
gui_timer.start(2000)
def __init__(self, parentObject, parent=None):
super(infoBox, self).__init__(parent)
self.parentObject = parentObject
if parentObject.enable_earthattr:
text = "Earth's Atmosphere contains approximately 78% Nitrogen, 21% oxygen, and small amounts of other " \
"elements.\n\n" \
"The sun's radiation is absorbed by various substances in the stmosphere, including water vapour, " \
"ozone, and dust particles.\n\n " \
"This model assumes cloudless skies."
if parentObject.enable_mercuryattr:
text = 'Mercury has no atmosphere, and therefore none of the incoming solar radiation is absorbed.\n\n' \
'The solar spectrum reaching the surface of Mercury is the extra-terrestial spectrum, corrected ' \
'for distance from the sun.'
if parentObject.enable_venusattr:
text = 'yoyrrrrroyo'
if parentObject.enable_marsattr:
text = "The Martian atmosphere consists of mostly carbon dioxide (96%), and small amounts of other " \
"gases.\n\n It has a mean pressure of approximately 0.6% that of Earth's at sea level. Incoming " \
"solar radiation is absorbed by carbon dioxide (in the 2 micron + range), and aerosols such as " \
"Martian dust."
if parentObject.enable_ceresattr:
text = "There are indications that Ceres has a tenuous atmosphere of water vapour caused by sublimation " \
"of ice from the surface. This is unproved however, and likely negligible, therefore he solar" \
" spectrum reaching the surface of Ceres is the extra-terrestial spectrum, corrected for distance " \
"from the sun. "
if parentObject.enable_europaattr:
text = "Europa has a very tenuous atmosphere composed solely of molecular oxygen, offerring little " \
"protection from the sun's radiation. It has an atmospheric pressure 10^(-12) times less than" \
" that of Earth, having a negligible effect on the incoming radiation."
if parentObject.enable_halleyattr:
text = "Halley's comet has no atmosphere, but when it's orbit takes it close to the sun the comet" \
" develops a coma up to 100,000 km across. Evaporation of this dirty ice releases dust " \
"particles, which travel with the gas away from the nucleus. Gas molecules in the coma absorb " \
"solar light and then re-radiate it at different wavelengths, a phenomenon known as " \
"fluorescence, whereas dust particles scatter the solar light. Both processes are responsible " \
"for making the coma visible."
if parentObject.enable_plutoattr:
text = "PLuto has a very tenuous atmosphere roughly 100,000 times less dense than the Earth's atmosphere." \
""
d = QMessageBox()
d.setWindowTitle('Information')
# d.setIcon(QMessageBox.Information)
d.setText(text)
d.exec_()