Python tkMessageBox 模块,askyesnocancel() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用tkMessageBox.askyesnocancel()

项目:oil    作者:oilshell    | 项目源码 | 文件源码
def maybesave(self):
        if self.get_saved():
            return "yes"
        message = "Do you want to save %s before closing?" % (
            self.filename or "this untitled document")
        confirm = tkMessageBox.askyesnocancel(
                  title="Save On Close",
                  message=message,
                  default=tkMessageBox.YES,
                  parent=self.text)
        if confirm:
            reply = "yes"
            self.save(None)
            if not self.get_saved():
                reply = "cancel"
        elif confirm is None:
            reply = "cancel"
        else:
            reply = "no"
        self.text.focus_set()
        return reply
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def maybesave(self):
        if self.get_saved():
            return "yes"
        message = "Do you want to save %s before closing?" % (
            self.filename or "this untitled document")
        confirm = tkMessageBox.askyesnocancel(
                  title="Save On Close",
                  message=message,
                  default=tkMessageBox.YES,
                  parent=self.text)
        if confirm:
            reply = "yes"
            self.save(None)
            if not self.get_saved():
                reply = "cancel"
        elif confirm is None:
            reply = "cancel"
        else:
            reply = "no"
        self.text.focus_set()
        return reply
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def maybesave(self):
        if self.get_saved():
            return "yes"
        message = "Do you want to save %s before closing?" % (
            self.filename or "this untitled document")
        confirm = tkMessageBox.askyesnocancel(
                  title="Save On Close",
                  message=message,
                  default=tkMessageBox.YES,
                  master=self.text)
        if confirm:
            reply = "yes"
            self.save(None)
            if not self.get_saved():
                reply = "cancel"
        elif confirm is None:
            reply = "cancel"
        else:
            reply = "no"
        self.text.focus_set()
        return reply
项目:Zelda2MapEdit    作者:matal3a0    | 项目源码 | 文件源码
def quit(self):
        # Save before exit?
        if self.edited != 0:
            result = tkMessageBox.askyesnocancel("Zelda2MapEdit", "Save before exit?") 
            if result is True:
                self.saveromfile()
                self.master.destroy()
            elif result is False:
                self.master.destroy()
        else:
            self.master.destroy()
项目:cablefish    作者:michgur    | 项目源码 | 文件源码
def asktosave(root):
    s = tkMessageBox.askyesnocancel('Unsaved Packets...',
                                    'Do You Want to Save Your Packets?\n  If You Won\'t, They\'ll be Really Sad',
                                    parent=root)
    if not s: return s  # s can be None (for 'Cancel') or False (for 'No')
    filename = tkFileDialog.asksaveasfilename(title='Save As',
                                              parent=root,
                                              filetypes=[('cablefish files', '.cf'), ('all files', '.*')],
                                              initialdir='C:/Users/',
                                              defaultextension='.cf'
                                              )
    return filename
项目:VisualPython    作者:RobinManoli    | 项目源码 | 文件源码
def prompt_save(self, editor):
        fname = editor.fpathname or editor.fname
        msg = "Save '%s' before closing?" % fname
        ans = askyesnocancel(message=msg)
        if ans:
            # return cancel if selected save and then not saved
            return True if self.save(editor) else None
        return ans