我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用PyQt5.QtWidgets.QMessageBox.Information()。
def showImage(self, text): try: if text == 'Show Red': RPiCamera.showImage(self.rgb_array, 'r') elif text == 'Show Green': RPiCamera.showImage(self.rgb_array, 'g') elif text == 'Show Blue': RPiCamera.showImage(self.rgb_array, 'b') else: RPiCamera.showImage(self.rgb_array) except ValueError: mb = QMessageBox() mb.setIcon(QMessageBox.Information) mb.setWindowTitle('Error') mb.setText('Array not loaded, make sure you take picture or import an image first.') mb.setStandardButtons(QMessageBox.Ok) mb.show()
def install(self): infoBox = QMessageBox() infoBox.setIcon(QMessageBox.Information) infoBox.setText("Your programs are being installed.Please wait") infoBox.setWindowTitle("Information") infoBox.setStandardButtons(QMessageBox.Ok) infoBox.exec_() #BashCommands.StartRun() self.getItems() infoBox = QMessageBox() infoBox.setIcon(QMessageBox.Information) infoBox.setText("Your programs installed ") infoBox.setWindowTitle("Information") infoBox.setStandardButtons(QMessageBox.Ok) infoBox.exec_() # When clicked update button
def printAbout(self): """ Show window with about and version information. """ msgBox = QMessageBox(QMessageBox.Information, "About", "About <b>" + basics.NAME + "</b>: <br><br>" + basics.NAME + " " + "is a file encryption and decryption tool using a Trezor hardware " "device for safety and security. Symmetric AES cryptography is used " "at its core. <br><br>" + "<b>" + basics.NAME + " Version: </b>" + basics.VERSION_STR + " from " + basics.VERSION_DATE_STR + "<br><br><b>Python Version: </b>" + sys.version.replace(" \n", "; ") + "<br><br><b>Qt Version: </b>" + QT_VERSION_STR + "<br><br><b>PyQt Version: </b>" + PYQT_VERSION_STR) msgBox.setIconPixmap(QPixmap(basics.LOGO_IMAGE)) msgBox.exec_()
def update_database(self): """ Display the 'database update' dialog. """ self.show() is_something_running = False for x in B3App.Instance().processes: if x.state() == QProcess.Running: is_something_running = True break if is_something_running: msgbox = QMessageBox() msgbox.setIcon(QMessageBox.Information) msgbox.setWindowTitle('NOTICE') msgbox.setText('Some B3 processes are still running: you need to terminate them to update B3 database.') msgbox.setStandardButtons(QMessageBox.Ok) msgbox.exec_() else: update = UpdateDatabaseDialog(self.centralWidget()) update.show()
def tempPlot(self): try: self.y_title_axis = ['Temperature Plot', 'Temperature vs Time', 't(s)', 'T(C)', 'Sensor'] MultiPlot.Plot(self.tf, len(self.ids), self.y_title_axis) except KeyError: mb = QMessageBox() mb.setIcon(QMessageBox.Information) mb.setWindowTitle('Error') mb.setText('No temperature sensor connected.') mb.setStandardButtons(QMessageBox.Ok) mb.show()
def pumppowerchange(self): try: if self.pumppwmvalue > 100: raise ValueError else: self.PUMPPWM.setIntensity(self.pumppwmvalue) except ValueError: mb = QMessageBox() mb.setIcon(QMessageBox.Information) mb.setWindowTitle('Error') mb.setText('Please type in a value between 0-100.') mb.setStandardButtons(QMessageBox.Ok) mb.show()
def showPlots(self): try: RPiCamera.showPlot(self.rgb_array) self.statusbar = 'Ready' except ValueError: mb = QMessageBox() mb.setIcon(QMessageBox.Information) mb.setWindowTitle('Error') mb.setText('Array not loaded, make sure you take picture or import an image first.') mb.setStandardButtons(QMessageBox.Ok) mb.show()
def spawn_window(parent, node, iface_name): driver = node.can_driver if not slcan_cli.CLIInterface.is_backend_supported(driver): mbox = QMessageBox(parent) mbox.setWindowTitle('Unsupported CAN Backend') mbox.setText('CAN Adapter Control Panel cannot be used with the current CAN backend.') mbox.setInformativeText('The current backend is %r.' % type(driver).__name__) mbox.setIcon(QMessageBox.Information) mbox.setStandardButtons(QMessageBox.Ok) mbox.show() # Not exec() because we don't want it to block! return progress_dialog = QProgressDialog(parent) progress_dialog.setWindowTitle('CAN Adapter Control Panel Initialization') progress_dialog.setLabelText('Detecting CAN adapter capabilities...') progress_dialog.setMinimumDuration(800) progress_dialog.setCancelButton(None) progress_dialog.setRange(0, 0) progress_dialog.show() def supported_callback(supported): progress_dialog.close() if not supported: mbox = QMessageBox(parent) mbox.setWindowTitle('Incompatible CAN Adapter') mbox.setText('CAN Adapter Control Panel cannot be used with the connected adapter.') mbox.setInformativeText('Connected SLCAN adapter does not support CLI extensions.') mbox.setIcon(QMessageBox.Information) mbox.setStandardButtons(QMessageBox.Ok) mbox.show() # Not exec() because we don't want it to block! return slcp = slcan_cli.ControlPanelWindow(parent, slcan_iface, iface_name) slcp.show() slcan_iface = slcan_cli.CLIInterface(driver) slcan_iface.check_is_interface_supported(supported_callback)
def _write_example_data(self): try: mdt.utils.get_example_data(self.outputFile.text()) msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText('The MDT example data has been written to {}.'.format(self.outputFile.text())) msg.setWindowTitle('Success') msg.exec_() except IOError as e: msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setText(str(e)) msg.setWindowTitle("File writing error") msg.exec_()
def update(self): Update.Update() infoBox = QMessageBox() infoBox.setIcon(QMessageBox.Information) infoBox.setText("Updated") infoBox.setWindowTitle("Information") infoBox.setStandardButtons(QMessageBox.Ok) infoBox.exec_() # When clicked about button
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_()
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_()