打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Python tkinter.messagebox 模块,askyesnocancel() 实例源码

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

项目:zippy    作者:securesystemslab    文件:IOBinding.py | 项目源码 | 文件源码
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
项目:Mac-Python-3.X    作者:L1nwatch    文件:test_tkinter.py | 项目源码 | 文件源码
def main():    # ?????????,?????Tkinter????????Tk??.??????withdraw()??????    tk = tkinter.Tk()    tk.withdraw()  # ?????    print(dir(mb))    # ??,?????????,??ok,????????????.??????????????,??????????.    # ??,???Cancel?,??????None    mb.showinfo("Title", "Your message here")    mb.showerror("An Error", "Oops!")    mb.showwarning("Title", "This may not work...")    mb.askyesno("Title", "Do you love me?")    mb.askokcancel("Title", "Are you well?")    mb.askquestion("Title", "How are you?")    mb.askretrycancel("Title", "Go again?")    mb.askyesnocancel("Title", "Are you well?")
项目:ouroboros    作者:pybee    文件:IOBinding.py | 项目源码 | 文件源码
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
项目:kbe_server    作者:xiaohaoppy    文件:IOBinding.py | 项目源码 | 文件源码
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
项目:porcupine    作者:Akuli    文件:tabs.py | 项目源码 | 文件源码
def can_be_closed(self):        """        This overrides :meth:`Tab.can_be_closed` in order to display a        save dialog.        If the file has been saved, this returns True and the tab is        closed normally. Otherwise this method asks the user whether the        file should be saved, and returns False only if the user cancels        something (and thus wants to keep working on this file).        """        if self.is_saved():            return True        if self.path is None:            msg = "Do you want to save your changes?"        else:            msg = ("Do you want to save your changes to %s?"                   % os.path.basename(self.path))        answer = messagebox.askyesnocancel("Close file", msg)        if answer is None:            # cancel            return False        if answer:            # yes            return self.save()        # no was clicked, can be closed        return True    # TODO: document the overriding
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    文件:GUI_message_box_yes_no_cancel.py | 项目源码 | 文件源码
def _msgBox():#     msg.showinfo('Python Message Info Box', 'A Python GUI created using tkinter:\nThe year is 2017.')  #     msg.showwarning('Python Message Warning Box', 'A Python GUI created using tkinter:\nWarning: There might be a bug in this code.')#     msg.showerror('Python Message Error Box', 'A Python GUI created using tkinter:\nError: Houston ~ we DO have a serious PROBLEM!')    answer = msg.askyesnocancel("Python Message Multi Choice Box", "Are you sure you really wish to do this?")    print(answer)# Add another Menu to the Menu Bar and an item
项目:VisualPython    作者:RobinManoli    文件:filemenu.py | 项目源码 | 文件源码
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
项目:Mac-Python-3.X    作者:L1nwatch    文件:learn_notebook.py | 项目源码 | 文件源码
def main():    top = tix.Tk()    nb = tix.NoteBook(top, width=300, height=200)    nb.pack(expand=True, fill="both")    nb.add("page1", label="text")    f1 = tix.Frame(nb.subwidget("page1"))    st = tix.ScrolledText(f1)    st.subwidget("text").insert("1.0", "Here is where the text goes...")    st.pack(expand=True)    f1.pack()    nb.add("page2", label="Message Boxes")    f2 = tix.Frame(nb.subwidget("page2"))    # ??????expand,fill?anchor???????????????????????    tix.Button(f2, text="error", bg="lightblue", command=lambda t="error", m="This is bad!": mb.showerror(t, m)).pack(fill="x",                                                                                                                      expand=True)    tix.Button(f2, text="info", bg="pink", command=lambda t="info", m="Information": mb.showinfo(t, m)).pack(fill="x", expand=True)    tix.Button(f2, text="warning", bg="yellow", command=lambda t="warning", m="Don't do it!": mb.showwarning(t, m)).pack(fill="x",                                                                                                                         expand=True)    tix.Button(f2, text="question", bg="green", command=lambda t="question", m="Will I?": mb.askquestion(t, m)).pack(fill="x",                                                                                                                     expand=True)    tix.Button(f2, text="yes - no", bg="lightgrey", command=lambda t="yes - no", m="Are you sure?": mb.askyesno(t, m)).pack(            fill="x", expand=True)    tix.Button(f2, text="yes - no - cancel", bg="black", fg="white",               command=lambda t="yes - not - cancel", m="Last chance...": mb.askyesnocancel(t, m)).pack(fill="x", expand=True)    f2.pack(side="top", fill="x")    top.mainloop()
项目:network-pj-chatroom    作者:KevinWang15    文件:contacts_form.py | 项目源码 | 文件源码
def socket_listener(self, data):        if data['type'] == MessageType.login_bundle:            bundle = data['parameters']            friends = bundle['friends']            rooms = bundle['rooms']            messages = bundle['messages']            for friend in friends:                self.handle_new_contact(friend)            for room in rooms:                self.handle_new_contact(room)            for item in messages:                # [[data:bytes,sent:int]]                sent = item[1]                message = _deserialize_any(item[0])                client.util.socket_listener.digest_message(message, not sent)            self.bundle_process_done = True            self.refresh_contacts()        if data['type'] == MessageType.incoming_friend_request:            result = messagebox.askyesnocancel("????", data['parameters']['nickname'] + "?????????????(?Cancel??????)");            if result == None:                return            self.sc.send(MessageType.resolve_friend_request, [data['parameters']['id'], result])        if data['type'] == MessageType.contact_info:            self.handle_new_contact(data['parameters'])            return        if data['type'] == MessageType.add_friend_result:            if data['parameters'][0]:                messagebox.showinfo('????', '???????')            else:                messagebox.showerror('??????', data['parameters'][1])            return        if data['type'] == MessageType.friend_on_off_line:            friend_user_id = data['parameters'][1]            for i in range(0, len(self.contacts)):                if self.contacts[i]['id'] == friend_user_id and self.contacts[i]['type'] == 0:                    self.contacts[i]['online'] = data['parameters'][0]                    break            self.refresh_contacts()            return
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
太强了!Python 开发桌面小工具,让代码替我们干重复的工作!
用Python写了一个上课点名系统(附源码)(自制考勤系统)
Tkinter绘制股票K线图
【Python】GUI编程(Tkinter)教程
Python -- Gui编程 -- Tkinter的使用 -- 对话框消息框
Python写恶意代码
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服