如何用tkinter创建一个消息框? [英] How to create a message box with tkinter?

查看:70
本文介绍了如何用tkinter创建一个消息框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在tkinter中构建一个具有是"和否"按钮的相当简单的消息框.当我在内部按下是"按钮时,它必须走并将是"写入文件.同样,当按下"NO"时,必须将NO写入文件.我该怎么办?

I've been trying to build a fairly simple message box in tkinter that has "YES" and "NO" buttons. When I push the "YES" button internally it must go and write YES to a file. Similarly, when "NO" is pushed, NO must be written to a file. How can I do this?

推荐答案

您可以使用模块

You can use the module tkMessageBox for Python 2.7 or the corresponding version for Python 3 called tkinter.messagebox.

看起来askquestion()正是您想要的功能.甚至会为您返回字符串"yes""no".

It looks like askquestion() is exactly the function that you want. It will even return the string "yes" or "no" for you.

这篇关于如何用tkinter创建一个消息框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆