Python PyQt5.QtWidgets.QMessageBox 模块,Question() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用PyQt5.QtWidgets.QMessageBox.Question()

项目:gpvdm    作者:roderickmackenzie    | 项目源码 | 文件源码
def yes_no_cancel_dlg(parent,text):
    if parent!=None:
        msgBox = QMessageBox(parent)
        msgBox.setIcon(QMessageBox.Question)
        msgBox.setText("Question")
        msgBox.setInformativeText(text)
        msgBox.setStandardButtons(QMessageBox.Yes| QMessageBox.No| QMessageBox.Cancel  )
        msgBox.setDefaultButton(QMessageBox.No)
        reply = msgBox.exec_()
        if reply == QMessageBox.Yes:
            return "yes"
        elif reply == QMessageBox.No:
            return "no"
        else:
            return "cancel"
    else:
        reply = input(text+"y/n/c")

        if reply == "y":
            return "yes"
        elif reply == "n":
            return "no"
        else:
            return "cancel"
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def my_close(self):
        settings = constants.SETTINGS
        not_show = settings.value('not_show_close_dialog', False, type=bool)

        if not not_show:
            cb = QCheckBox("Do not show this again.")
            msgbox = QMessageBox(QMessageBox.Question, "Confirm close", "Are you sure you want to close?")
            msgbox.addButton(QMessageBox.Yes)
            msgbox.addButton(QMessageBox.No)
            msgbox.setDefaultButton(QMessageBox.No)
            msgbox.setCheckBox(cb)

            reply = msgbox.exec()

            not_show_again = bool(cb.isChecked())
            settings.setValue("not_show_close_dialog", not_show_again)
            self.not_show_again_changed.emit()
            if reply != QMessageBox.Yes:
                return

        self.closed.emit(self)
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def process_delete(self, process):
        """
        Handle the removal of a B3 process.
        """
        msgbox = QMessageBox()
        msgbox.setIcon(QMessageBox.Question)
        msgbox.setWindowTitle('CONFIRM')
        msgbox.setText('Are you sure?')
        msgbox.setInformativeText('Do you want to remove %s?' % process.name)
        msgbox.setStandardButtons(QMessageBox.No|QMessageBox.Yes)
        msgbox.setDefaultButton(QMessageBox.No)
        msgbox.layout().addItem(QSpacerItem(300, 0, QSizePolicy.Minimum, QSizePolicy.Expanding),
                                msgbox.layout().rowCount(), 0, 1, msgbox.layout().columnCount())
        msgbox.exec_()

        if msgbox.result() == QMessageBox.Yes:
            if process.state() != QProcess.NotRunning:
                self.process_shutdown(process)
            process.delete()
            self.repaint()
项目:gpvdm    作者:roderickmackenzie    | 项目源码 | 文件源码
def yes_no_dlg(parent,text):
    msgBox = QMessageBox(parent)
    msgBox.setIcon(QMessageBox.Question)
    msgBox.setText("Question")
    msgBox.setInformativeText(text)
    msgBox.setStandardButtons(QMessageBox.Yes| QMessageBox.No )
    msgBox.setDefaultButton(QMessageBox.No)
    reply = msgBox.exec_()
    if reply == QMessageBox.Yes:
        return True
    else:
        return False
项目:gpvdm    作者:roderickmackenzie    | 项目源码 | 文件源码
def yes_no_cancel_dlg(parent,text):
    msgBox = QMessageBox(parent)
    msgBox.setIcon(QMessageBox.Question)
    msgBox.setText("Question")
    msgBox.setInformativeText(text)
    msgBox.setStandardButtons(QMessageBox.Yes| QMessageBox.No| QMessageBox.Cancel  )
    msgBox.setDefaultButton(QMessageBox.No)
    reply = msgBox.exec_()
    if reply == QMessageBox.Yes:
        return "yes"
    elif reply == QMessageBox.No:
        return "no"
    else:
        return "cancel"
项目:UM3NetworkPrintingPlugin    作者:Ultimaker    | 项目源码 | 文件源码
def materialHotendChangedMessage(self, callback):
        Application.getInstance().messageBox(i18n_catalog.i18nc("@window:title", "Changes on the Printer"),
            i18n_catalog.i18nc("@label",
                "Would you like to update your current printer configuration into Cura?"),
            i18n_catalog.i18nc("@label",
                "The PrintCores and/or materials on your printer were changed. For the best result, always slice for the PrintCores and materials that are inserted in your printer."),
            buttons=QMessageBox.Yes + QMessageBox.No,
            icon=QMessageBox.Question,
            callback=callback
        )
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def save_all(self):
        if self.num_frames == 0:
            return

        settings = constants.SETTINGS
        try:
            not_show = settings.value('not_show_save_dialog', type=bool, defaultValue=False)
        except TypeError:
            not_show = False

        if not not_show:
            cb = QCheckBox("Don't ask me again.")
            msg_box = QMessageBox(QMessageBox.Question, self.tr("Confirm saving all signals"),
                                  self.tr("All changed signal files will be overwritten. OK?"))
            msg_box.addButton(QMessageBox.Yes)
            msg_box.addButton(QMessageBox.No)
            msg_box.setCheckBox(cb)

            reply = msg_box.exec()
            not_show_again = cb.isChecked()
            settings.setValue("not_show_save_dialog", not_show_again)
            self.not_show_again_changed.emit()

            if reply != QMessageBox.Yes:
                return

        for f in self.signal_frames:
            if f.signal is None or f.signal.filename == "":
                continue
            f.signal.save()
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def shutdown(self):
        """
        Perform cleanup operation before the application exits.
        This is executed when the `aboutToQuit` signal is emitted, before `quit()
        or when the user shutdown the Desktop session`.
        """
        LOG.debug('shutdown requested')
        is_something_running = False
        for process in self.processes:
            if process.state() == QProcess.Running:
                is_something_running = True
                break

        if is_something_running:
            # ask the use if he wants to quit for real
            LOG.debug('some processes are still running: asking the user if he wants to terminate them...')
            msgbox = QMessageBox()
            msgbox.setIcon(QMessageBox.Question)
            msgbox.setText('Are you sure you want to quit?')
            msgbox.setInformativeText('NOTE: all the running B3 will be stopped!')
            msgbox.setStandardButtons(QMessageBox.No | QMessageBox.Yes)
            msgbox.setDefaultButton(QMessageBox.No)
            msgbox.exec_()

            if msgbox.result() == QMessageBox.Yes:
                LOG.debug('user agreed to terminate all the running processes and quit the application')
            else:
                LOG.debug('shutdown aborted')
                return

        self.shutdown_requested = True
        self.stop_all()

        ## REMOVE LOG HANDLERS
        for handler in LOG.handlers:
            handler.close()
            LOG.removeHandler(handler)

        ## HIDE SYSTEM TRAY (ON WINDOWS IT STAYS VISIBLE SOMETIME)
        if b3.getPlatform() != 'linux':
            # linux has no system tray
            self.main_window.system_tray.hide()

        ## QUIT THE APPLICATION
        self.quit()

    ############################################## OTHER METHODS #######################################################