当前位置: 首页>>代码示例>>Python>>正文


Python QMessageBox.question方法代码示例

本文整理汇总了Python中qtpy.QtWidgets.QMessageBox.question方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.question方法的具体用法?Python QMessageBox.question怎么用?Python QMessageBox.question使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qtpy.QtWidgets.QMessageBox的用法示例。


在下文中一共展示了QMessageBox.question方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: closeEvent

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
    def closeEvent(self, event):
        """
            Executed when the application closes
        """
        if False:
            reply = QMessageBox.question(self, 'Message',
                                               "Are you sure you want to quit this application?",
                                               QMessageBox.Yes, QMessageBox.No)

            if reply == QMessageBox.Yes:
                event.accept()
            else:
                event.ignore()

        # Save application settings
        if self._clear_and_restart:
            self._clear_and_restart = False
            QSettings().clear()
        else:
            settings = QSettings()

            settings.setValue("instrument_name", self._instrument)
            settings.setValue("last_file", self._filename)
            settings.setValue("recent_files", self._recent_files)
            settings.setValue("last_directory", str(self._last_directory))
            settings.setValue("last_export_directory", str(self._last_export_directory))
开发者ID:samueljackson92,项目名称:mantid,代码行数:28,代码来源:reduction_application.py

示例2: closeEvent

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
    def closeEvent(self, event):
        if self.dirty:
            res = QMessageBox.question(
                self,
                QCoreApplication.applicationName(),
                self.tr("Save changes to file '%s'?" %
                        self.filename
                        if self.filename is not None else "unknown"),
                QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel
            )
            if res == QMessageBox.Cancel:
                event.ignore()
                return
            elif res == QMessageBox.Yes:
                self.save_file()

        self.save_settings()

        try:
            self.worker.quit()
        except AttributeError:
            pass

        try:
            self.serial.close()
        except (SerialException, AttributeError):
            pass
开发者ID:MrLeeh,项目名称:jsonwatchqt,代码行数:29,代码来源:mainwindow.py

示例3: synchronize

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
 def synchronize(self):
     """
     Synchronize Spyder's path list with PYTHONPATH environment variable
     Only apply to: current user, on Windows platforms
     """
     answer = QMessageBox.question(self, _("Synchronize"),
         _("This will synchronize Spyder's path list with "
                 "<b>PYTHONPATH</b> environment variable for current user, "
                 "allowing you to run your Python modules outside Spyder "
                 "without having to configure sys.path. "
                 "<br>Do you want to clear contents of PYTHONPATH before "
                 "adding Spyder's path list?"),
         QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
     if answer == QMessageBox.Cancel:
         return
     elif answer == QMessageBox.Yes:
         remove = True
     else:
         remove = False
     from spyder.utils.environ import (get_user_env, set_user_env,
                                       listdict2envdict)
     env = get_user_env()
     if remove:
         ppath = self.active_pathlist+self.ro_pathlist
     else:
         ppath = env.get('PYTHONPATH', [])
         if not isinstance(ppath, list):
             ppath = [ppath]
         ppath = [path for path in ppath
                  if path not in (self.active_pathlist+self.ro_pathlist)]
         ppath.extend(self.active_pathlist+self.ro_pathlist)
     env['PYTHONPATH'] = ppath
     set_user_env(listdict2envdict(env), parent=self)
开发者ID:rlaverde,项目名称:spyder,代码行数:35,代码来源:pathmanager.py

示例4: restart_kernel

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
    def restart_kernel(self):
        """
        Restart the associanted kernel

        Took this code from the qtconsole project
        Licensed under the BSD license
        """
        message = _('Are you sure you want to restart the kernel?')
        buttons = QMessageBox.Yes | QMessageBox.No
        result = QMessageBox.question(self, _('Restart kernel?'),
                                      message, buttons)
        if result == QMessageBox.Yes:
            sw = self.shellwidget
            if sw.kernel_manager:
                try:
                    sw.kernel_manager.restart_kernel()
                except RuntimeError as e:
                    sw._append_plain_text(
                        _('Error restarting kernel: %s\n') % e,
                        before_prompt=True
                    )
                else:
                    sw._append_html(_("<br>Restarting kernel...\n<hr><br>"),
                        before_prompt=True,
                    )
            else:
                sw._append_plain_text(
                    _('Cannot restart a kernel not started by Spyder\n'),
                    before_prompt=True
                )
开发者ID:jitseniesen,项目名称:spyder,代码行数:32,代码来源:client.py

示例5: ask_confirmation

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
def ask_confirmation(self, message, title="Mantid Workbench"):
    """
    :param message:
    :return:
    """
    reply = QMessageBox.question(self, title, message, QMessageBox.Yes, QMessageBox.No)
    return True if reply == QMessageBox.Yes else False
开发者ID:samueljackson92,项目名称:mantid,代码行数:9,代码来源:table_copying.py

示例6: _run_pip_action

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
    def _run_pip_action(self, package_name, action):
        """
        DEPRECATED
        """
        prefix = self.prefix

        if prefix == self.root_prefix:
            name = 'root'
        elif self.api.conda_environment_exists(prefix=prefix):
            name = osp.basename(prefix)
        else:
            name = prefix

        if action == C.ACTION_REMOVE:
            msgbox = QMessageBox.question(self,
                                          "Remove pip package: "
                                          "{0}".format(package_name),
                                          "Do you want to proceed?",
                                          QMessageBox.Yes | QMessageBox.No)
            if msgbox == QMessageBox.Yes:
                self.update_status()
                worker = self.api.pip_remove(prefix=self.prefix,
                                             pkgs=[package_name])
                worker.sig_finished.connect(self._pip_process_ready)
                status = (_('Removing pip package <b>') + package_name +
                          '</b>' + _(' from <i>') + name + '</i>')
                self.update_status(hide=True, message=status,
                                   progress=[0, 0])
开发者ID:Discalced51,项目名称:conda-manager,代码行数:30,代码来源:packages.py

示例7: save_if_required

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
    def save_if_required(self, prompt_for_confirm=True, force_save=False):
        """
        Save the editor's contents to a file. The function has the following options:
        - if prompt_for_confirmation is True -> then show the yes/no dialog
        - if force_save is True, and prompt_for_confirmation is False -> then save the file anyway
        - if prompt_for_confirmation and force_save are both False -> then do NOT save the file, discard all changes

        :param prompt_for_confirmation: If this is True, then the user will be prompted with a yes/no dialog to
                                        decide whether to save or discard the file.
                                        If this parameter is True, force_save will be ignored!
        :param force_save: If this is True, then if the user is NOT being prompted, the file will be saved anyway!
                           This is used for the File > Save Script (Ctrl + S) action.
        :returns: True if either saving was successful or no save was requested. Returns False if
        the operation should be cancelled
        """
        if prompt_for_confirm:
            button = QMessageBox.question(self.editor, "",
                                          "Save changes to document before closing?",
                                          buttons=(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel),
                                          defaultButton=QMessageBox.Cancel)
            if button == QMessageBox.Yes:
                return self.write()
            elif button == QMessageBox.No:
                return True
            else:
                # Cancelled
                return False
        elif force_save:
            return self.write()
        else:
            # pretend the user clicked No on the dialog
            return True
开发者ID:mantidproject,项目名称:mantid,代码行数:34,代码来源:interpreter.py

示例8: _offer_overwriting_gui

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
 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; 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.No)
开发者ID:mantidproject,项目名称:mantid,代码行数:10,代码来源:project.py

示例9: send_report

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
    def send_report(self, title, body, application_log=None):
        _logger().debug('sending bug report on github\ntitle=%s\nbody=%s',
                        title, body)

        # Credentials
        credentials = self.get_user_credentials()
        username = credentials['username']
        password = credentials['password']
        remember = credentials['remember']
        token = credentials['token']
        remember_token = credentials['remember_token']

        if username is None and password is None and token is None:
            return False
        _logger().debug('got user credentials')

        # upload log file as a gist
        if application_log:
            url = self.upload_log_file(application_log)
            body += '\nApplication log: %s' % url
        try:
            if token:
                gh = github.GitHub(access_token=token)
            else:
                gh = github.GitHub(username=username, password=password)
            repo = gh.repos(self.gh_owner)(self.gh_repo)
            ret = repo.issues.post(title=title, body=body)
        except github.ApiError as e:
            _logger().warning('Failed to send bug report on Github. '
                              'response=%r', e.response)
            # invalid credentials
            if e.response.code == 401:
                if self._show_msgbox:
                    QMessageBox.warning(
                        self.parent_widget, _('Invalid credentials'),
                        _('Failed to create Github issue, '
                          'invalid credentials...'))
            else:
                # other issue
                if self._show_msgbox:
                    QMessageBox.warning(
                        self.parent_widget,
                        _('Failed to create issue'),
                        _('Failed to create Github issue. Error %d') %
                        e.response.code)
            return False
        else:
            issue_nbr = ret['number']
            if self._show_msgbox:
                ret = QMessageBox.question(
                    self.parent_widget, _('Issue created on Github'),
                    _('Issue successfully created. Would you like to open the '
                      'issue in your web browser?'))
            if ret in [QMessageBox.Yes, QMessageBox.Ok]:
                webbrowser.open(
                    'https://github.com/%s/%s/issues/%d' % (
                        self.gh_owner, self.gh_repo, issue_nbr))
            return True
开发者ID:burrbull,项目名称:spyder,代码行数:60,代码来源:backend.py

示例10: _offer_save_message_box

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
 def _offer_save_message_box(self, parent):
     if self.prompt_save_on_close:
         return QMessageBox.question(parent, 'Unsaved Project',
                                     "The project is currently unsaved. Would you like to "
                                     "save before closing?",
                                     QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel,
                                     QMessageBox.Yes)
     else:
         return QMessageBox.No
开发者ID:mantidproject,项目名称:mantid,代码行数:11,代码来源:project.py

示例11: _submit_to_github

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
    def _submit_to_github(self):
        """Action to take when pressing the submit button."""
        # Get reference to the main window
        if self.parent() is not None:
            if getattr(self.parent(), 'main', False):
                # This covers the case when the dialog is attached
                # to the internal console
                main = self.parent().main
            else:
                # Else the dialog is attached to the main window
                # directly
                main = self.parent()
        else:
            main = None

        # Getting description and traceback
        title = self.title.text()
        description = self.input_description.toPlainText()
        traceback = self.error_traceback[:-1]  # Remove last EOL

        # Render issue
        if main is not None:
            issue_text = main.render_issue(description=description,
                                           traceback=traceback)
        else:
            issue_text = description

        try:
            if main is None:
                org = 'ccordoba12'
            else:
                org = 'spyder-ide'
            github_backend = GithubBackend(org, 'spyder', parent_widget=main)
            github_report = github_backend.send_report(title, issue_text)
            if github_report:
                self.close()
        except Exception:
            ret = QMessageBox.question(
                      self, _('Error'),
                      _("An error occurred while trying to send the issue to "
                        "Github automatically. Would you like to open it "
                        "manually?<br><br>"
                        "If so, please make sure to paste your clipboard "
                        "into the issue report box that will appear in a new "
                        "browser tab before clicking <i>Submit</i> on that "
                        "page."))
            if ret in [QMessageBox.Yes, QMessageBox.Ok]:
                QApplication.clipboard().setText(issue_text)
                issue_body = (
                    " \n<!---   *** BEFORE SUBMITTING: PASTE CLIPBOARD HERE "
                    "TO COMPLETE YOUR REPORT ***   ---!>\n")
                if main is not None:
                    main.report_issue(body=issue_body, title=title,
                                      open_webpage=True)
                else:
                    pass
开发者ID:impact27,项目名称:spyder,代码行数:58,代码来源:reporterror.py

示例12: reset_namespace

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
    def reset_namespace(self):
        """Resets the namespace by removing all names defined by the user"""

        reply = QMessageBox.question(
            self,
            _("Reset IPython namespace"),
            _("All user-defined variables will be removed." "<br>Are you sure you want to reset the namespace?"),
            QMessageBox.Yes | QMessageBox.No,
        )

        if reply == QMessageBox.Yes:
            self.execute("%reset -f")
开发者ID:silentquasar,项目名称:spyder,代码行数:14,代码来源:shell.py

示例13: _check_unsaved_comments

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
 def _check_unsaved_comments(self):
     if self.textChangedAt is None:
         return #Nothing to be changed
     i = self.toolbar.source_select.currentIndex()
     i = self._index_hash(i)
     if self.textChangedAt == i:
         self.textChangedAt = None
         return #This is a refresh
     info = "Comments or flags changed but were not saved. Would you like to save them?"
     reply = QMessageBox.question(self, '', info, QMessageBox.Yes | QMessageBox.No)
     if reply == QMessageBox.Yes:
         self.update_comments(True)
     self.textChangedAt = None
开发者ID:spacetelescope,项目名称:mosviz,代码行数:15,代码来源:mos_viewer.py

示例14: reject

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
    def reject(self):
        """ """
        if self.busy:
            answer = QMessageBox.question(
                self,
                'Quit Conda Manager?',
                'Conda is still busy.\n\nDo you want to quit?',
                buttons=QMessageBox.Yes | QMessageBox.No)

            if answer == QMessageBox.Yes:
                QDialog.reject(self)
                # Do some cleanup?
        else:
            QDialog.reject(self)
开发者ID:Discalced51,项目名称:conda-manager,代码行数:16,代码来源:packages.py

示例15: closing_plugin

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import question [as 别名]
    def closing_plugin(self, cancelable=False):
        """Perform actions before parent main window is closed."""
        if self.busy:
            answer = QMessageBox.question(
                self,
                'Conda Manager',
                'Conda Manager is still busy.\n\nDo you want to quit?',
                buttons=QMessageBox.Yes | QMessageBox.No)

            if answer == QMessageBox.Yes:
                return True
            else:
                return False
        else:
            return True
开发者ID:ccordoba12,项目名称:conda-manager,代码行数:17,代码来源:condapackages.py


注:本文中的qtpy.QtWidgets.QMessageBox.question方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。