我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用tkMessageBox.askyesnocancel()。
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
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
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()
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
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