How to use the qtpy.QtWidgets.QMessageBox function in QtPy

To help you get started, we’ve selected a few QtPy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MTgeophysics / mtpy / tests / SmartMT / test_exportDialog.py View on Github external
def _fake_msg_dialog_exec_overwrite(self):
        self.dialog._msg_box.show()
        QTest.qWaitForWindowActive(self.dialog._msg_box)
        _click_area(self.dialog._msg_box_button_overwrite)
        return QMessageBox.Accepted
github slaclab / pydm / pydm / widgets / pushbutton.py View on Github external
def confirm_dialog(self):
        """
        Show the confirmation dialog with the proper message in case
        ```showConfirmMessage``` is True.

        Returns
        -------
        bool
            True if the message was confirmed or if ```showCofirmMessage```
            is False.
        """

        if self._show_confirm_dialog:
            if self._confirm_message == "":
                self._confirm_message = PyDMPushButton.DEFAULT_CONFIRM_MESSAGE
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Question)
            msg.setText(self._confirm_message)
            msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            msg.setDefaultButton(QMessageBox.No)
            ret = msg.exec_()
            if ret == QMessageBox.No:
                return False
        return True
github slaclab / pydm / pydm / widgets / rules_editor.py View on Github external
def del_rule(self):
        """Delete the rule selected in the rules list."""
        idx = self.get_current_index()
        if idx < 0:
            return
        name = self.lst_rule_item.text()

        confirm_message = "Are you sure you want to delete Rule: {}?".format(
            name)
        reply = QtWidgets.QMessageBox().question(self, 'Message',
                                             confirm_message,
                                             QtWidgets.QMessageBox.Yes,
                                             QtWidgets.QMessageBox.No)

        if reply == QtWidgets.QMessageBox.Yes:
            self.lst_rules.takeItem(idx)
            self.lst_rules.clearSelection()
            self.rules.pop(idx)
            self.clear_form()
github glue-viz / glue / glue / viewers / common / qt / base_widget.py View on Github external
def _confirm_close(self):
        """Ask for close confirmation

        :rtype: bool. True if user wishes to close. False otherwise
        """
        if self._warn_close and not os.environ.get('GLUE_TESTING'):
            buttons = QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel
            dialog = QtWidgets.QMessageBox.warning(self, "Confirm Close",
                                                   "Do you want to close this window?",
                                                   buttons=buttons,
                                                   defaultButton=QtWidgets.QMessageBox.Cancel)
            return dialog == QtWidgets.QMessageBox.Ok
        return True
github spyder-ide / spyder / spyder / preferences / maininterpreter.py View on Github external
args = ["-c", "import sys; print(sys.version_info[0])"]
            proc = programs.run_program(pyexec, args)
            console_version = int(proc.communicate()[0])
        except IOError:
            console_version = spyder_version
        except ValueError:
            return False
        if spyder_version != console_version:
            QMessageBox.warning(self, _('Warning'),
                _("You selected a <b>Python %d</b> interpreter for the console "
                  "but Spyder is running on <b>Python %d</b>!.<br><br>"
                  "Although this is possible, we recommend you to install and "
                  "run Spyder directly with your selected interpreter, to avoid "
                  "seeing false warnings and errors due to the incompatible "
                  "syntax between these two Python versions."
                  ) % (console_version, spyder_version), QMessageBox.Ok)
        return True
github sys-bio / tellurium / spyder_mod / Spyder 3.1.3 / spyder / app / mainwindow.py View on Github external
"this command will remove all your Spyder configuration files "
            "located in '%s').<br><br>"
            "If restoring the default settings does not help, please take "
            "the time to search for <a href="\&quot;%s\&quot;">known bugs</a> or "
            "<a href="\&quot;%s\&quot;">discussions</a> matching your situation before "
            "eventually creating a new issue <a href="\&quot;%s\&quot;">here</a>. "
            "Your feedback will always be greatly appreciated."
            "" % (get_conf_path(), __project_url__,
                  __forum_url__, __project_url__))

    # Create main window
    mainwindow = None
    try:
        mainwindow = run_spyder(app, options, args)
    except FontError as fontError:
        QMessageBox.information(None, "Spyder",
                "Spyder was unable to load the <i>Spyder 3</i> "
                "icon theme. That's why it's going to fallback to the "
                "theme used in Spyder 2.<br><br>"
                "For that, please close this window and start Spyder again.")
        CONF.set('main', 'icon_theme', 'spyder 2')
    except BaseException:
        CONF.set('main', 'crash', True)
        import traceback
        traceback.print_exc(file=STDERR)
        traceback.print_exc(file=open('spyder_crash.log', 'w'))
    if mainwindow is None:
        # An exception occured
        if SPLASH is not None:
            SPLASH.hide()
        return
github mantidproject / mantid / qt / python / mantidqt / project / project.py View on Github external
def _offer_overwriting_gui():
        """
        Offers up a overwriting QMessageBox giving the option to overwrite a project, and returns the reply.
        :return: QMessaageBox.Yes or QMessageBox.No or QMessageBox.Cancel; The value is the value selected by the user.
        """
        return QMessageBox().question(None, "Overwrite project?",
                                      "Would you like to overwrite the selected project?",
                                      QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel,
                                      QMessageBox.Yes)
github spyder-ide / spyder-notebook / spyder_notebook / widgets / client.py View on Github external
def shutdown_kernel(self):
        """Shutdown the kernel of the client."""
        kernel_id = self.get_kernel_id()

        if kernel_id:
            delete_url = self.add_token(url_path_join(self.server_url,
                                                      'api/kernels/',
                                                      kernel_id))
            delete_req = requests.delete(delete_url)
            if delete_req.status_code != 204:
                QMessageBox.warning(
                    self,
                    _("Server error"),
                    _("The Jupyter Notebook server "
                      "failed to shutdown the kernel "
github hyperspy / hyperspyUI / hyperspyui / plugins / gitgetter.py View on Github external
if sys.__stdout__ is None:
            sys.__stdout__ = sys.stdout
            stdout_set = True
        try:
            ic.main(['--no-deps', '-I', branch])
            ic.main([branch])
        finally:
            if stdout_set:
                sys.__stdout__ = None  # Let's leave things as we found them.
            (pip.download.DownloadProgressBar,
             pip.download.DownloadProgressSpinner) = old_classes
    else:
        try:
            branch.checkout()
        except git.GitCommandError as e:
            mb = QMessageBox(QMessageBox.Critical, tr("Git checkout failed"),
                             e.stderr)
            mb.exec_()
            raise ValueError()
github mantidproject / mantid / scripts / Muon / GUI / Common / home_instrument_widget / home_instrument_widget_view.py View on Github external
def instrument_changed_warning(self):
        msg = QtWidgets.QMessageBox(self)
        msg.setIcon(QtWidgets.QMessageBox.Warning)
        msg.setText("Changing instrument will reset the interface, continue?")
        msg.setWindowTitle("Changing Instrument")
        msg.setStandardButtons(
            QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
        retval = msg.exec_()
        if retval == 1024:
            # The "OK" code
            return 1
        else:
            return 0