Python PyQt5.QtWidgets.QMessageBox() Examples

The following are 30 code examples for showing how to use PyQt5.QtWidgets.QMessageBox(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .

Example 1
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 6 votes vote down vote up
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 2
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 6 votes vote down vote up
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 3
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 6 votes vote down vote up
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 4
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 6 votes vote down vote up
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
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 6 votes vote down vote up
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 6
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 6 votes vote down vote up
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 7
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 6 votes vote down vote up
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 8
Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 9
Project: easygui_qt   Author: aroberge   File: easygui_qt.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 10
Project: easygui_qt   Author: aroberge   File: easygui_qt.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 11
Project: Lector   Author: BasioMeusPuga   File: settingsdialog.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 12
Project: biometric-attendance-sync-tool   Author: frappe   File: gui.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 13
Project: IDAngr   Author: andreafioraldi   File: main_gui.py    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
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
Project: Writer-Tutorial   Author: goldsborough   File: part-3.py    License: MIT License 6 votes vote down vote up
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 15
Project: ddt4all   Author: cedricp   File: ddt4all.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 16
Project: ddt4all   Author: cedricp   File: dataeditor.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 17
Project: kawaii-player   Author: kanishka-linux   File: player_functions.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 18
Project: PyPipboyApp   Author: matzman666   File: pypipboyapp.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 19
Project: PyPipboyApp   Author: matzman666   File: pypipboyapp.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 20
Project: reversi_ai   Author: andysalerno   File: reversi_window.py    License: MIT License 6 votes vote down vote up
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 21
Project: vorta   Author: borgbase   File: source_tab.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 22
Project: handyscripts   Author: Tecplot   File: pyqt5_execute_macro_command.py    License: MIT License 6 votes vote down vote up
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 23
Project: nanovna-saver   Author: NanoVNA-Saver   File: CalibrationSettings.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 24
Project: DownloaderForReddit   Author: MalloyDelacroix   File: ImgurClientDialog.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 25
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 5 votes vote down vote up
def onComboChange(self):
        """
        Detects and updates GUI with populated USB device details.
        :return:
        """
        self.ui.installed_distros.clear()
        config.usb_disk = osdriver.listbox_entry_to_device(
            self.ui.combo_drives.currentText())
        if config.usb_disk == 0 or config.usb_disk:
            # Get the GPT status of the disk and store it on a variable
            try:
                usb.gpt_device(config.usb_disk)
                config.imager_usb_disk \
                    = self.ui.combo_drives.currentText()
                config.usb_details \
                    = usb.details(config.usb_disk)
            except Exception as e:
                o = io.StringIO()
                traceback.print_exc(None, o)
                log(o.getvalue())
                QtWidgets.QMessageBox.critical(
                    self, "The disk/partition is not usable.",
                    str(e))
                self.ui.combo_drives.setCurrentIndex(0)
                # Above statement triggers call to this method.
                return
            log("Selected device " +
                            osdriver.usb_disk_desc(config.usb_disk))
            self.update_target_info()
            self.update_list_box(config.usb_disk)
            self.ui_update_persistence()
        else:
            self.ui.usb_dev.clear()
            self.ui.usb_vendor.clear()
            self.ui.usb_model.clear()
            self.ui.usb_size.clear()
            self.ui.usb_mount.clear()
            self.ui.usb_type.clear()
            self.ui.usb_fs.clear()
            log("No USB disk found...") 
Example 26
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 5 votes vote down vote up
def onedit_syslinux(self):
        """
        Function to edit main syslinux.cfg file.
        :return:
        """
        # Function to edit syslinux.cfg file on editors like gedit, notepad etc.
        # Suggest me more editor which can be included in to this function.
        sys_cfg_file = os.path.join(config.usb_mount, "multibootusb", "syslinux.cfg")
        log("Locating " + sys_cfg_file)
        editor = ''
        if not os.path.exists(sys_cfg_file):
            log("syslinux.cfg file not found...")
            QtWidgets.QMessageBox.information(self, 'File not found...', 'Sorry. Unable to locate syslinux.cfg file.\n'
                                                                         'You can only edit syslinux.cfg file generated by multibootusb.')
        else:
            if platform.system() == "Linux":
                for e in config.editors_linux:
                    if subprocess.call('which ' + e, shell=True) == 0:
                        log("Editor found is " + e)
                        editor = e
                        break
            elif platform.system() == "Windows":
                for e in config.editors_win:
                    if not shutil.which(e) is None:
                        log("Editor found is " + e)
                        editor = e
                        break
            if not editor:
                QtWidgets.QMessageBox.information(self, 'Editor not found...',
                                                  'Sorry. Installed editor is not supported by multibootusb\n'
                                                  'Edit ' + sys_cfg_file + ' manually.\n')
            else:
                try:
                    subprocess.Popen(editor + " '" + sys_cfg_file + "'", shell=True).pid
                except OSError:
                    QtWidgets.QMessageBox.warning(self, 'Error...',
                                                  'Failed to open syslinux.cfg file.\n'
                                                  'Edit syslinux.cfg file manually.\n') 
Example 27
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 5 votes vote down vote up
def OnUninstallClick(self):
        """
        Triggers a function to uninstall a selected distro.
        :return:
        """

        self.ui_disable_controls()

        if self.ui.installed_distros.currentItem() is None:
            log("Please select a distro from the list.")
            QtWidgets.QMessageBox.information(self, 'No selection.', 'Please select a distro from the list.')
            self.ui_enable_controls()
        else:
            config.uninstall_distro_dir_name = str(
                self.ui.installed_distros.currentItem().text()).strip()
            reply = QtWidgets.QMessageBox.question(
                self, "Review selection...",
                "Are you sure to uninstall " + config.uninstall_distro_dir_name,
                QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
                QtWidgets.QMessageBox.No)

            if reply == QtWidgets.QMessageBox.Yes:
                if not os.path.exists(
                        os.path.join(config.usb_mount, 'multibootusb',
                                     config.uninstall_distro_dir_name)):
                    log("Distro install directory not found. "
                        "Just updating syslinux.cfg and grub.cfg.")
                    uninstall_distro.update_sys_cfg_file(config.uninstall_distro_dir_name)
                    uninstall_distro.update_grub_cfg_file(config.uninstall_distro_dir_name)
                    self.uninstall_sys_file_update()
                    # self.uninstall.update_sys_cfg_file()
                    self.ui_enable_controls()
                else:
                    self.progress_thread_uninstall.start()
            else:
                self.ui_enable_controls() 
Example 28
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 5 votes vote down vote up
def uninstall_sys_file_update(self):
        """
        Function to remove and update uninstall distro text.
        :return:
        """

        # This function is already called from 'do_uninstall_distro()'
        # update_sys_cfg_file(config.uninstall_distro_dir_name)

        self.update_list_box(config.usb_mount)
        self.ui.statusbar.showMessage("Status: Idle")
        QtWidgets.QMessageBox.information(self, 'Uninstall Complete...',
                                          config.uninstall_distro_dir_name + ' has been successfully removed.')
        self.ui_enable_controls() 
Example 29
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 5 votes vote down vote up
def show_admin_info():
    """
    Show simple information box reminding user to run the software with admin/root privilege.
    Only required under Linux as the windows executable always will start with admin privilege.
    :return:
    """
    msg = QtWidgets.QMessageBox()
    msg.setIcon(QtWidgets.QMessageBox.Information)
    if os.path.exists('scripts'):
        msg.setText('Admin privilege is required to run multibootusb.\n'
                    'Try  \'sudo python3 ./multibootusb\'\n')
    else:
        msg.setText('Admin privilege is required to run multibootusb.\n'
                    'Try  \'multibootusb-pkexec\'\n')
    msg.exec_() 
Example 30
Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def removePoslistTab(self, index):
        '''
        ret = QtWidgets.QMessageBox.warning(self, "Warning",
                'Are you sure you want to delete poslist ' + str(index+1) + '?')
        if ret == False:
            return
        '''
        widget = self.poslistTabWidget.widget(index)
        widget.deleteLater()
        self.poslistTabWidget.removeTab(index)
        del self.session.poslists[index]

    #Changes the stimulators (coils and electrodes) being shown in the OpenGL window