python类Cancel()的实例源码

yes_no_cancel_dlg.py 文件源码 项目:gpvdm 作者: roderickmackenzie 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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"
uamodeler.py 文件源码 项目:opcua-modeler 作者: FreeOpcUa 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def _save_as(self):
        path, ok = QFileDialog.getSaveFileName(self.modeler, caption="Save OPC UA XML", filter="XML Files (*.xml *.XML)")
        if ok:
            if os.path.isfile(path):
                reply = QMessageBox.question(
                    self.modeler,
                    "OPC UA Modeler",
                    "File already exit, do you really want to save to this file?",
                    QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel
                )
                if reply != QMessageBox.Yes:
                    return
            if self._last_model_dir != os.path.dirname(path):
                self._last_model_dir = os.path.dirname(path)
                self.settings.setValue("last_model_dir", self._last_model_dir)
            self._model_mgr.save_model(path)
main_window.py 文件源码 项目:uitester 作者: IfengAutomation 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def closeEvent(self, event):
        """
        close window event
        :return:
        """
        if not hasattr(self, 'case_edit_window'):  # case_edit_window is not exist
            self.close()
            return
        if not self.case_edit_window.isVisible():  # case_edit_window is not visible
            self.close()
            return

        # signal for case_edit_window's closeEvent
        self.case_edit_window.close_cancel_signal.connect(self.editor_close_ignore, Qt.DirectConnection)

        # case_edit_window is visible
        reply = self.message_box.question(self, "Confirm Close?", "The editor is opened, still close?",
                                          QMessageBox.Yes | QMessageBox.Cancel)
        if reply == QMessageBox.Yes:
            self.is_editor_close_cancel = False
            self.case_edit_window.close()
            if self.is_editor_close_cancel:   # editor close is canceled
                event.ignore()
                return
            self.close()
        else:
            event.ignore()
case_editor.py 文件源码 项目:uitester 作者: IfengAutomation 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def handle_message_box_apply(self, event):
        """
        message box
        :param event:
        :return:
        """
        reply = self.message_box.question(self, "Save Changes?", "The case has been modified, save changes?",
                                          QMessageBox.Save | QMessageBox.Cancel | QMessageBox.Discard)

        if reply == QMessageBox.Save:  # update case info
            self.save_case(event)
            # check case data widget isVisible
            if hasattr(self, 'case_data_widget') and self.case_data_widget.isVisible():
                self.case_data_widget.close()
        elif reply == QMessageBox.Discard:
            # check case data widget isVisible
            if hasattr(self, 'case_data_widget') and self.case_data_widget.isVisible():
                self.case_data_widget.close()
            self.close()
            return
        else:
            self.close_cancel_signal.emit()
            event.ignore()
notepad.py 文件源码 项目:OpenTutorials_PyQt 作者: RavenKyu 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def slot_new(self):
        """
        ???? ?? ? ??
        :return:
        """
        if not self.is_saved:
            reply = QMessageBox.information(
                self, self.tr("Save"), self.tr("??? ??? ?????????"),
                QMessageBox.Save | QMessageBox.No | QMessageBox.Cancel, QMessageBox.Save)
            if reply == QMessageBox.Save:
                if not self.slot_save():
                    return  # ?? ??
            elif reply == QMessageBox.No:
                pass
            else:
                return  # ?? ??
        self.init_setting()
model.py 文件源码 项目:Osdag 作者: osdag-admin 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def set_databaseconnection():
    '''
    Setting connection with SQLite
    '''
    # TODO explicitly close database connection on exit
    filepath = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'ResourceFiles', 'Database', 'Intg_osdag.sqlite')
    db = QSqlDatabase.addDatabase("QSQLITE")
    db.setDatabaseName(filepath)
    if not db.open():
        QMessageBox.critical(None, qApp.tr("Cannot open database"),
                                   qApp.tr("Unable to establish a database connection.\n"
                                                 "This example needs SQLite support. Please read "
                                                 "the Qt SQL driver documentation for information "
                                                 "how to build it.\n\n"
                                                 "Click Cancel to exit."),
                                   QMessageBox.Cancel)
        return False
dialogs.py 文件源码 项目:RRPam-WDS 作者: asselapathirana 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def should_i_save_first(self):
        close = True
        if(self.saveaction.isEnabled()):
            from PyQt5.QtWidgets import QMessageBox
            msgBox = QMessageBox()
            msgBox.setText("Current project has been modified.")
            msgBox.setInformativeText("Do you want to save your changes first?")
            msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
            msgBox.setDefaultButton(QMessageBox.Save)
            ret = msgBox.exec_()

            if (ret == QMessageBox.Save):
                if(not self._save_project()):
                    close = False
            if (ret == QMessageBox.Cancel):
                close = False
        return close
message.py 文件源码 项目:VIRTUAL-PHONE 作者: SumanKanrar-IEM 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        buttonReply = QMessageBox.question(self, 'PyQt5 message', "Do you want to save?", QMessageBox.YesToAll | QMessageBox.No | QMessageBox.Cancel, QMessageBox.Cancel)
        print(int(buttonReply))
        if buttonReply == QMessageBox.Yes:
            print('Yes clicked.')
        if buttonReply == QMessageBox.No:
            print('No clicked.')
        if buttonReply == QMessageBox.Cancel:
            print('Cancel')

        self.show()
gui_util.py 文件源码 项目:gpvdm 作者: roderickmackenzie 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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"
uamodeler.py 文件源码 项目:opcua-modeler 作者: FreeOpcUa 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def try_close_model(self):
        if self._model_mgr.modified:
            reply = QMessageBox.question(
                self.modeler,
                "OPC UA Modeler",
                "Model is modified, do you really want to close model?",
                QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel
            )
            if reply != QMessageBox.Yes:
                return False
        self._model_mgr.close_model(force=True)
        return True
menumanager.py 文件源码 项目:Mac-Python-3.X 作者: L1nwatch 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def launchError(self, error):
        if error != QProcess.Crashed:
            QMessageBox.critical(None, "Failed to launch the example",
                    "Could not launch the example. Ensure that it has been "
                    "built.",
                    QMessageBox.Cancel)
menumanager.py 文件源码 项目:examples 作者: pyqt 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def launchError(self, error):
        if error != QProcess.Crashed:
            QMessageBox.critical(None, "Failed to launch the example",
                    "Could not launch the example. Ensure that it has been "
                    "built.",
                    QMessageBox.Cancel)
Messages.py 文件源码 项目:DownloaderForReddit 作者: MalloyDelacroix 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def remove_user(self):
        reply = message.information(self, 'Remove User?', remove_user_message, message.Ok, message.Cancel)
        return reply == message.Ok
Messages.py 文件源码 项目:DownloaderForReddit 作者: MalloyDelacroix 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def remove_subreddit(self):
        reply = message.information(self, 'Remove Subreddit?', remove_subreddit_message, message.Ok, message.Cancel)
        return reply == message.Ok
Messages.py 文件源码 项目:DownloaderForReddit 作者: MalloyDelacroix 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def remove_user_list(self):
        reply = message.warning(self, 'Remove User List?', remove_user_list_message, message.Ok, message.Cancel)
        return reply == message.Ok
Messages.py 文件源码 项目:DownloaderForReddit 作者: MalloyDelacroix 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def remove_subreddit_list(self):
        reply = message.warning(self, 'Remove Subreddit List?', remove_subreddit_list_message, message.Ok, message.Cancel)
        return reply == message.Ok
Messages.py 文件源码 项目:DownloaderForReddit 作者: MalloyDelacroix 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def downloader_running_warning(self):
        text = 'The user finder is still currently running.  Closing now may cause unexpected behaviour and corrupted ' \
               'files.  Are you sure you want to close?'
        reply = message.warning(self, 'User Finder Still Running', text, message.Ok, message.Cancel)
        return reply == message.Ok
Messages.py 文件源码 项目:DownloaderForReddit 作者: MalloyDelacroix 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def update_reddit_objects_message(self):
        text = "Saved reddit objects are from a previous version of the program and are no\n" \
               "longer compatible. These objects will now be updated to the latest version\n" \
               "and the application will be saved. All of the objects settings and download list\n" \
               "will be carried over to new objects.\n" \
               "If you do not update these objects, the saved objects will not work correctly\n" \
               "and will most likely cause the application to crash"
        reply = message.information(self, "Update Reddit Objects", text, message.Ok, message.Cancel)
        return reply == message.Ok
Messages.py 文件源码 项目:DownloaderForReddit 作者: MalloyDelacroix 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def unsaved_close_message(self):
        text = "Save changes to Downloader For Reddit?"
        reply = message.question(self, "Save Changes?", text, message.Yes | message.No | message.Cancel, message.Cancel)
        if reply == message.Yes:
            return "SAVE"
        elif reply == message.No:
            return "CLOSE"
        else:
            return "CANCEL"
Messages.py 文件源码 项目:DownloaderForReddit 作者: MalloyDelacroix 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self):
        """
        A small class to display an unfinished dialog message to the user.  It is made into its own class so the names
        of the buttons can be renamed to be better understood in the situation it is used in
        """
        QDialog.__init__(self)
        self.setupUi(self)

        self.button_box.button(QDialogButtonBox.Ok).setText('Close Anyway')
        self.button_box.button(QDialogButtonBox.Cancel).setText('Do Not Close')

        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.close)
model.py 文件源码 项目:Osdag 作者: osdag-admin 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def set_databaseconnection():
    '''
    Setting connection with SQLite
    '''
    filepath = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'ResourceFiles', 'Database', 'Intg_osdag.sqlite')
    db = QSqlDatabase.addDatabase("QSQLITE")
    db.setDatabaseName(filepath)
    # db.open()
    if not db.open():

        QMessageBox.critical(None, qApp.tr("Cannot open database"),
                                   qApp.tr("Unable to establish a database connection.\n"
                                                 "This example needs SQLite support. Please read "
                                                 "the Qt SQL driver documentation for information"
                                                 "how to build it.\n\n"
                                                 "Click Cancel to exit."),
                                   QMessageBox.Cancel)
        return False


# def set_databaseconnection():
#     '''
#     Setting connection with MySQL database
#     '''
#     db = QSqlDatabase.addDatabase("QMYSQL")
#     db.setHostName("localhost")
#     db.setPort(3306)
#     db.setDatabaseName("OSDAG")
#     db.setUserName("root")
#     db.setPassword("root")
#     db.open()
#     logger.info("feching records from database")
model.py 文件源码 项目:Osdag 作者: osdag-admin 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def set_databaseconnection():
    '''
    Setting connection with SQLite
    '''
    filepath = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'ResourceFiles', 'Database', 'Intg_osdag.sqlite')
    db = QSqlDatabase.addDatabase("QSQLITE")
    db.setDatabaseName(filepath)
    # db.open()
    if not db.open():

        QMessageBox.critical(None, qApp.tr("Cannot open database"),
                                   qApp.tr("Unable to establish a database connection.\n"
                                                 "This example needs SQLite support. Please read "
                                                 "the Qt SQL driver documentation for information "
                                                 "how to build it.\n\n"
                                                 "Click Cancel to exit."),
                                   QMessageBox.Cancel)
        return False


# def set_databaseconnection():
#     '''
#     Setting connection with MySQL database
#     '''
#     db = QSqlDatabase.addDatabase("QMYSQL")
#     db.setHostName("localhost")
#     db.setPort(3306)
#     db.setDatabaseName("OSDAG")
#     db.setUserName("root")
#     db.setPassword("root")
#     db.open()
#     logger.info("feching records from database")
model.py 文件源码 项目:Osdag 作者: osdag-admin 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def set_databaseconnection():
    '''
    Setting connection with SQLite
    '''
    filepath = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'ResourceFiles', 'Database', 'Intg_osdag.sqlite')
#     filepath = "D:\EclipseWorkspace\OsdagWorkshop\Database\CleatSections"

#     db = QSqlDatabase.database("QSQLITE")
#     if db.IsValid():
#         return True

    db = QSqlDatabase.addDatabase("QSQLITE")
    db.setDatabaseName(filepath)
    # db.open()
    if not db.open():

        QMessageBox.critical(None, qApp.tr("Cannot open database"),
                                   qApp.tr("Unable to establish a database connection.\n"
                                                 "This example needs SQLite support. Please read "
                                                 "the Qt SQL driver documentation for information "
                                                 "how to build it.\n\n"
                                                 "Click Cancel to exit."),
                                   QMessageBox.Cancel)
        return False   


# def set_databaseconnection():
#     '''
#     Setting connection with MySQL database
#     '''
#     db = QSqlDatabase.addDatabase("QMYSQL")
#     db.setHostName("localhost")
#     db.setPort(3306)
#     db.setDatabaseName("OSDAG")
#     db.setUserName("root")
#     db.setPassword("root")
#     db.open()
#     logger.info("feching records from database")
menumanager.py 文件源码 项目:pyqt5-example 作者: guinslym 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def launchError(self, error):
        if error != QProcess.Crashed:
            QMessageBox.critical(None, "Failed to launch the example",
                    "Could not launch the example. Ensure that it has been "
                    "built.",
                    QMessageBox.Cancel)


问题


面经


文章

微信
公众号

扫码关注公众号