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

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

问题描述

我一直在尝试在 tkinter 中构建一个相当简单的消息框,其中包含是"和否"按钮.当我在内部按下是"按钮时,它必须将 YES 写入文件.类似地,当推送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?

推荐答案

您可以使用模块 tkMessageBox 适用于 Python 2.7 或 Python 3 的相应版本,称为 tkinter.messagebox.

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天全站免登陆