Python PyQt5.QtWidgets.QMessageBox() Examples
The following are 30
code examples of PyQt5.QtWidgets.QMessageBox().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PyQt5.QtWidgets
, or try the search function
.
Example #1
Source File: part-3.py From Writer-Tutorial with MIT License | 7 votes |
def insertImage(self): # Get image file name filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Insert image',".","Images (*.png *.xpm *.jpg *.bmp *.gif)") if filename: # Create image object image = QtGui.QImage(filename) # Error if unloadable if image.isNull(): popup = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical, "Image load error", "Could not load image file!", QtWidgets.QMessageBox.Ok, self) popup.show() else: cursor = self.text.textCursor() cursor.insertImage(image,filename)
Example #2
Source File: mbusb_gui.py From multibootusb with GNU General Public License v2.0 | 6 votes |
def closeEvent(self, event): """ To capture the main close event. :param event: Close event. :return: """ if config.process_exist == None: event.accept() else: reply = QtWidgets.QMessageBox.question(self, 'Exit MultiBootUSB...', "A process is still running.\n" "Do you really want to quit multibootusb?", QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.Yes: log("Closing multibootusb...") event.accept() sys.exit(0) else: log("Close event cancelled.") event.ignore()
Example #3
Source File: CalibrationSettings.py From nanovna-saver with GNU General Public License v3.0 | 6 votes |
def checkExpertUser(self): if not self.app.settings.value("ExpertCalibrationUser", False, bool): response = QtWidgets.QMessageBox.question( self, "Are you sure?", "Use of the manual calibration buttons " + "is non-intuitive, and primarily suited for users with very " + "specialized needs. The buttons do not sweep for you, nor do " + "they interact with the NanoVNA calibration.\n\n" + "If you are trying to do a calibration of the NanoVNA, do so " + "on the device itself instead. If you are trying to do a " + "calibration with NanoVNA-Saver, use the Calibration Assistant " + "if possible.\n\n" + "If you are certain you know what you are doing, click Yes.", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Cancel) if response == QtWidgets.QMessageBox.Yes: self.app.settings.setValue("ExpertCalibrationUser", True) return True return False return True
Example #4
Source File: mbusb_gui.py From multibootusb with GNU General Public License v2.0 | 6 votes |
def onFsckClick_impl(self, fsck_func): if not config.usb_disk: QtWidgets.QMessageBox.information( self, 'No partition is selected', 'Please select the partition to check.') return if not config.usb_disk[-1:].isdigit(): QtWidgets.QMessageBox.information( self, 'Selected device is not partition', 'Please select a partition not a disk.') return output = [] with usb.UnmountedContext(config.usb_disk, self.update_usb_mount): fsck_func(config.usb_disk, output) for resultcode, msgout, cmd in output: QtWidgets.QMessageBox.information( self, 'Integrity Check', cmd + ' said:\n' + str(msgout[0], 'utf-8'))
Example #5
Source File: ImgurClientDialog.py From DownloaderForReddit with GNU General Public License v3.0 | 6 votes |
def help_dialog(self): help_message = QtWidgets.QMessageBox() help_message.setWindowTitle('Imgur Client Help') help_message.setText('You must supply your own imgur client id and client secret in order for this app to use ' 'the imgur api.<br><br>Due to the limits imposed by the imgur api, it is necessary for ' 'each user to get their own credentials from imgur.com and supply them to the app for ' 'personal use.<br>Each client is only allowed 12,200 requests per day, so to keep ' 'each user from running out of requests, this client information is not ' 'supplied by the app.<br><br>Please follow the link below to obtain an imgur client-id ' 'and client-secret. You will need an imgur account<br><br>Recommended details to enter:' '<br>Application name: Downloader for Reddit<br>Authorization type: Anonymous usage ' 'without authorization<br>Authorization callback url: https://google.com (any valid url ' 'will work here and it does not matter for anonymous usage)<br>Application ' 'website: https://github.com/MalloyDelacroix/DownloaderForReddit<br>Email: ' 'Your email address to email your credentials to. If you need more requests, you can <br>' 'use the comercial endpoint at https://rapidapi.com/imgur/api/imgur-9.') help_message.setTextFormat(QtCore.Qt.RichText) help_message.setInformativeText("<a href='https://api.imgur.com/oauth2/addclient'>https://api.imgur.com/oauth2/addclient<a/>") help_message.exec_()
Example #6
Source File: mbusb_gui.py From multibootusb with GNU General Public License v2.0 | 6 votes |
def install_syslinux_impl(self): """ Function to install syslinux on distro directory and on selected USB disks. :return: """ self.ui.statusbar.showMessage(str("Status: Installing Syslinux...")) syslinux_distro_dir(config.usb_disk, config.image_path, config.distro) syslinux_default(config.usb_disk) replace_grub_binary() update_distro_cfg_files(config.image_path, config.usb_disk, config.distro, config.persistence) self.update_list_box(config.usb_disk) self.ui.statusbar.showMessage("Status: Idle") self.ui_disable_persistence() log(iso_name(config.image_path) + ' has been successfully installed.') QtWidgets.QMessageBox.information(self, 'Finished...', iso_name(config.image_path) + ' has been successfully installed.')
Example #7
Source File: mbusb_gui.py From multibootusb with GNU General Public License v2.0 | 6 votes |
def install_syslinux(self): try: try: self.install_syslinux_impl() finally: config.process_exist = None self.ui_enable_controls() except (KeyboardInterrupt, SystemExit): raise except: uninstall_distro.do_uninstall_distro( config.distro, iso_basename(config.image_path)) o = io.StringIO() traceback.print_exc(None, o) QtWidgets.QMessageBox.information( self, 'install_syslinux() failed', o.getvalue()) log("install_syslinux() failed.") log(o.getvalue())
Example #8
Source File: pyqt5_execute_macro_command.py From handyscripts with MIT License | 6 votes |
def execute_macro_command_CB(self, *a): cmd = self.macro_command_textEdit.toPlainText() try: temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".mcr") temp_file.write(cmd.encode('utf8')) temp_file.flush() tp.macro.execute_file(temp_file.name) except Exception as e: error_dialog = QtWidgets.QMessageBox() error_dialog.setWindowTitle("Error") if str(e): error_dialog.setText("Error: {}".format(str(e))) else: error_dialog.setText("Error:\nNo error details available. ") error_dialog.exec_() finally: temp_file.close() os.unlink(temp_file.name)
Example #9
Source File: mbusb_gui.py From multibootusb with GNU General Public License v2.0 | 6 votes |
def dd_finished(self): """ Re-enable the blocked widgets for newer use. :return: """ self.ui.progressbar.setValue(0) self.ui.statusbar.showMessage("Status: Idle") config.process_exist = None msgBox = QtWidgets.QMessageBox() if self.progress_thread_dd.error: title = "Failed to write the iso image to the USB disk." msg = self.progress_thread_dd.error else: title = "Image succesfully written to USB disk." msg = "Reboot to boot from USB or test it from " \ "<b>Boot ISO/USB</b> tab." msgBox.setText(title) msgBox.setInformativeText(msg); msgBox.setStandardButtons(QtWidgets.QMessageBox.Ok) msgBox.setIcon(QtWidgets.QMessageBox.Information) msgBox.exec_() self.ui_enable_controls()
Example #10
Source File: mbusb_gui.py From multibootusb with GNU General Public License v2.0 | 6 votes |
def onAllDrivesClicked(self): """ Include fixed drives to available USB devices. :return: """ if self.ui.checkbox_all_drives.isChecked() is False: self.onRefreshClick() return if getattr(config, 'protected_drives', []): reply = QtWidgets.QMessageBox.Yes else: reply = QtWidgets.QMessageBox.warning( self, "WARNING!", "This option enables working with fixed drives\n" "and is potentially VERY DANGEROUS\n\n" "Are you SURE you want to enable it?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.No: self.ui.checkbox_all_drives.setChecked(False) elif reply == QtWidgets.QMessageBox.Yes: self.ui.checkbox_all_drives.setChecked(True) self.onRefreshClick()
Example #11
Source File: mbusb_gui.py From multibootusb with GNU General Public License v2.0 | 6 votes |
def check_remount(self): if config.usb_details['file_system'] != 'vfat': return True try: with UnmountedContext(config.usb_disk, self.update_usb_mount) as m: pass return True except usb.RemountError: QtWidgets.QMessageBox.critical( self,"Remount failed.", "Could not remount '{0}'. " "Please make sure no process has open " "handle(s) to previously mounted filesystem." .format(config.usb_disk)) return False
Example #12
Source File: settingsdialog.py From Lector with GNU General Public License v3.0 | 6 votes |
def delete_database(self): def ifcontinue(box_button): if box_button.text() != '&Yes': return database_filename = os.path.join( self.main_window.database_path, 'Lector.db') os.remove(database_filename) QtWidgets.qApp.exit() # Generate a message box to confirm deletion confirm_deletion = QtWidgets.QMessageBox() deletion_prompt = self._translate( 'SettingsUI', f'Delete database and exit?') confirm_deletion.setText(deletion_prompt) confirm_deletion.setIcon(QtWidgets.QMessageBox.Critical) confirm_deletion.setWindowTitle(self._translate('SettingsUI', 'Confirm')) confirm_deletion.setStandardButtons( QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) confirm_deletion.buttonClicked.connect(ifcontinue) confirm_deletion.show() confirm_deletion.exec_()
Example #13
Source File: main_gui.py From IDAngr with BSD 2-Clause "Simplified" License | 6 votes |
def get_mem(addr): dialog = IDAngrAddMemDialog() dialog.set_addr(addr) r = dialog.exec_() if r == QtWidgets.QDialog.Accepted: addr = dialog.ui.addrTextEdit.displayText() try: addr = int(addr, 16) except: QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical, 'Error', "Address not in hex format").exec_() return None length = dialog.ui.lenTextEdit.displayText() try: length = int(length) except: QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical, 'Error', "Length not in dec format").exec_() return None return (addr, length) return None
Example #14
Source File: ddt4all.py From ddt4all with GNU General Public License v3.0 | 6 votes |
def zipdb(self): filename_tuple = widgets.QFileDialog.getSaveFileName(self, _("Save database (keep '.zip' extension)"), "./ecu.zip", "*.zip") if qt5: filename = str(filename_tuple[0]) else: filename = str(filename_tuple) if not filename.endswith(".zip"): filename += ".zip" if not isWritable(str(os.path.dirname(filename))): mbox = widgets.QMessageBox() mbox.setText("Cannot write to directory " + os.path.dirname(filename)) mbox.exec_() return self.logview.append(_("Zipping XML database... (this can take a few minutes")) core.QCoreApplication.processEvents() parameters.zipConvertXML(filename) self.logview.append(_("Zip job finished"))
Example #15
Source File: source_tab.py From vorta with GNU General Public License v3.0 | 6 votes |
def paste_text(self): sources = QApplication.clipboard().text().splitlines() invalidSources = "" for source in sources: if len(source) > 0: # Ignore empty newlines if not os.path.exists(source): invalidSources = invalidSources + "\n" + source else: new_source, created = SourceFileModel.get_or_create(dir=source, profile=self.profile()) if created: self.sourceFilesWidget.addItem(source) new_source.save() if len(invalidSources) != 0: # Check if any invalid paths msg = QMessageBox() msg.setText("Some of your sources are invalid:" + invalidSources) msg.exec()
Example #16
Source File: gui.py From biometric-attendance-sync-tool with GNU General Public License v3.0 | 6 votes |
def create_message_box(title, text, icon="information", width=150): msg = QMessageBox() msg.setWindowTitle(title) lineCnt = len(text.split('\n')) if lineCnt > 15: scroll = QtWidgets.QScrollArea() scroll.setWidgetResizable(1) content = QtWidgets.QWidget() scroll.setWidget(content) layout = QtWidgets.QVBoxLayout(content) tmpLabel = QtWidgets.QLabel(text) tmpLabel.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) layout.addWidget(tmpLabel) msg.layout().addWidget(scroll, 12, 10, 1, msg.layout().columnCount()) msg.setStyleSheet("QScrollArea{min-width:550 px; min-height: 400px}") else: msg.setText(text) if icon == "warning": msg.setIcon(QtWidgets.QMessageBox.Warning) msg.setStyleSheet("QMessageBox Warning{min-width: 50 px;}") else: msg.setIcon(QtWidgets.QMessageBox.Information) msg.setStyleSheet("QMessageBox Information{min-width: 50 px;}") msg.setStyleSheet("QmessageBox QLabel{min-width: "+str(width)+"px;}") msg.exec_()
Example #17
Source File: reversi_window.py From reversi_ai with MIT License | 6 votes |
def poll_msg_queue(self): self.board = self.socket_receiver.get_board() self.repaint() winner = self.socket_receiver.get_winner() if winner is not None: dialog = QtWidgets.QMessageBox() dialog.setText('{} wins.'.format(winner)) dialog.exec_() player_with_no_moves = self.socket_receiver.get_no_moves() if player_with_no_moves is not None: name = color_name[player_with_no_moves] dialog = QtWidgets.QMessageBox() dialog.setText('{} had no moves, skipping turn.'.format(name)) dialog.exec_()
Example #18
Source File: main_gui.py From simnibs with GNU General Public License v3.0 | 6 votes |
def definePosition(self, row): pos_gui = Position_GUI(self.table_rows[row].p1, self.table_rows[row].p2, str(self.table_rows[row].name_item.text()), self.glHeadModel) pos_gui.show() p1, p2, name, ok = pos_gui.GetPositions() #to make sure the reference is given while ok and p2 == [0.0,0.0,0.0]: QtWidgets.QMessageBox.critical(self, "Warning", 'You must select a direction by checking the box and clicking the head model') p1, p2, name, ok = pos_gui.GetPositions() if ok: self.table_rows[row].p1 = p1 self.table_rows[row].p2 = p2 scalp_surf = self.glHeadModel.getSurface('Scalp') self.writeOnPosColumn(row, p1) self.table_rows[row].name_item.setText(name) self.updateStimulatorModels()
Example #19
Source File: easygui_qt.py From easygui_qt with BSD 3-Clause "New" or "Revised" License | 6 votes |
def show_message(message="Message", title="Title"): """Simple message box. :param message: message string :param title: window title >>> import easygui_qt as easy >>> easy.show_message() .. image:: ../docs/images/show_message.png """ app = SimpleApp() box = qt_widgets.QMessageBox(None) box.setWindowTitle(title) box.setText(message) box.show() box.raise_() box.exec_() app.quit()
Example #20
Source File: dataeditor.py From ddt4all with GNU General Public License v3.0 | 6 votes |
def remove_selected(self): if len(self.datatable.selectedItems()) == 0: return r = self.datatable.selectedItems()[-1].row() dataname = utf8(self.datatable.item(r, 0).text()) # Check if data needed by request for reqname, request in self.ecurequestsparser.requests.iteritems(): for rcvname, rcvdi in request.dataitems.iteritems(): if rcvname == dataname: msgbox = widgets.QMessageBox() msgbox.setText(_("Data is used by request %s") % reqname) msgbox.exec_() return for sndname, snddi in request.sendbyte_dataitems.iteritems(): if sndname == dataname: msgbox = widgets.QMessageBox() msgbox.setText(_("Data is used by request %s") % reqname) msgbox.exec_() return self.ecurequestsparser.data.pop(dataname) self.reload()
Example #21
Source File: pypipboyapp.py From PyPipboyApp with GNU General Public License v3.0 | 6 votes |
def requestQuit(self): # do you really wanna if not int(self.settings.value('mainwindow/promptBeforeQuit', 1)) or QtWidgets.QMessageBox.question(self.mainWindow, 'Close', 'Are you sure you want to quit?', QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No) == QtWidgets.QMessageBox.Yes: # disconnect any network sessions if self.networkChannel.isConnected: self.networkChannel.disconnect() # Close Relay Service self.relayController.stopRelayService() self.relayController.stopAutodiscoverService() # save state self.settings.setValue('mainwindow/geometry', self.mainWindow.saveGeometry()) self.settings.setValue('mainwindow/fullscreen', int(self.mainWindow.isFullScreen())) self.settings.setValue('mainwindow/windowstate', self.mainWindow.saveState()) self.settings.sync() # quit self.quit()
Example #22
Source File: easygui_qt.py From easygui_qt with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get_abort(message="Major problem - or at least we think there is one...", title="Major problem encountered!"): '''Displays a message about a problem. If the user clicks on "abort", sys.exit() is called and the program ends. If the user clicks on "ignore", the program resumes its execution. :param title: the window title :param message: the message to display >>> import easygui_qt as easy >>> easy.get_abort() .. image:: ../docs/images/get_abort.png ''' app = SimpleApp() reply = qt_widgets.QMessageBox.critical(None, title, message, qt_widgets.QMessageBox.Abort | qt_widgets.QMessageBox.Ignore) if reply == qt_widgets.QMessageBox.Abort: sys.exit() else: pass app.quit()
Example #23
Source File: player_functions.py From kawaii-player with GNU General Public License v3.0 | 6 votes |
def qmsg_message(txt): print(txt) #root = tkinter.Tk() #width = root.winfo_screenwidth() #height = root.winfo_screenheight() #print(width, height, '--screen--tk--') msg = QtWidgets.QMessageBox() msg.setGeometry(0, 0, 50, 20) #msg.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint) msg.setWindowModality(QtCore.Qt.NonModal) msg.setWindowTitle("Kawaii-Player MessageBox") msg.setIcon(QtWidgets.QMessageBox.Information) msg.setText(txt+'\n\n(Message Will Autohide in 5 seconds)') msg.show() frame_timer = QtCore.QTimer() frame_timer.timeout.connect(lambda x=0: frame_options(msg)) frame_timer.setSingleShot(True) frame_timer.start(5000) msg.exec_()
Example #24
Source File: pypipboyapp.py From PyPipboyApp with GNU General Public License v3.0 | 6 votes |
def _slotConnectToHostFinished(self, status, msg): # hide busy dialog if self._connectHostMessageBox: self._connectHostMessageBox.hide() self._connectHostMessageBox = None # delete thread if self._connectHostThread: self._connectHostThread.wait() self._connectHostThread = None # Handle errors if status: pass else: QtWidgets.QMessageBox.warning(self.mainWindow, 'Connection to host failed', msg) # Shows a warning message dialog
Example #25
Source File: ddt4all.py From ddt4all with GNU General Public License v3.0 | 5 votes |
def connectedMode(self): self.timer.stop() self.securitycheck = self.safetycheck.isChecked() self.selectedportspeed = int(self.speedcombo.currentText()) if not pc.securitycheck: msgbox = widgets.QMessageBox() msgbox.setText(_("You must check the recommendations")) msgbox.exec_() return if self.wifibutton.isChecked(): self.port = str(self.wifiinput.text()) self.mode = 1 self.done(True) else: currentitem = self.listview.currentItem() if currentitem: portinfo = utf8(currentitem.text()) self.port = self.ports[portinfo][0] options.port_name = self.ports[portinfo][1] self.mode = 1 self.done(True) else: msgbox = widgets.QMessageBox() msgbox.setText(_("Please select a communication port")) msgbox.exec_()
Example #26
Source File: part-4.py From Writer-Tutorial with MIT License | 5 votes |
def insertImage(self): # Get image file name #PYQT5 Returns a tuple in PyQt5 filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Insert image',".","Images (*.png *.xpm *.jpg *.bmp *.gif)")[0] if filename: # Create image object image = QtGui.QImage(filename) # Error if unloadable if image.isNull(): popup = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical, "Image load error", "Could not load image file!", QtWidgets.QMessageBox.Ok, self) popup.show() else: cursor = self.text.textCursor() cursor.insertImage(image,filename)
Example #27
Source File: ddt4all.py From ddt4all with GNU General Public License v3.0 | 5 votes |
def mousePressEvent(self, mousevent): msgbox = widgets.QMessageBox() msgbox.setText(_("<center>This Software is free, but I need money to buy cables/ECUs and make this application more reliable</center>")) okbutton = widgets.QPushButton(_('Yes I contribute')) msgbox.addButton(okbutton, widgets.QMessageBox.YesRole) msgbox.addButton(widgets.QPushButton(_("No, I don't")), widgets.QMessageBox.NoRole) okbutton.clicked.connect(self.donate) msgbox.exec_()
Example #28
Source File: table.py From Writer-Tutorial with MIT License | 5 votes |
def insert(self): cursor = self.parent.text.textCursor() # Get the configurations rows = self.rows.value() cols = self.cols.value() if not rows or not cols: popup = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Warning, "Parameter error", "Row and column numbers may not be zero!", QtWidgets.QMessageBox.Ok, self) popup.show() else: padding = self.pad.value() space = self.space.value() # Set the padding and spacing fmt = QtGui.QTextTableFormat() fmt.setCellPadding(padding) fmt.setCellSpacing(space) # Inser the new table cursor.insertTable(rows,cols,fmt) self.close()
Example #29
Source File: ddt4all.py From ddt4all with GNU General Public License v3.0 | 5 votes |
def donate(self): url = core.QUrl("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=cedricpaille@gmail.com&lc=CY&item_name=codetronic¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG.if:NonHosted", core.QUrl.TolerantMode) gui.QDesktopServices().openUrl(url) msgbox = widgets.QMessageBox() msgbox.setText(_("<center>Thank you for you contribution, if nothing happens, please go to : https://github.com/cedricp/ddt4all</center>")) msgbox.exec_()
Example #30
Source File: night_mode.py From Anki-Night-Mode with GNU General Public License v3.0 | 5 votes |
def message_box(self): box = QMessageBox() if self.config.state_on.value: box_style = MessageBoxStyle(self) box.setStyleSheet(box_style.style) return box