如何用python编写弹出对话框,并选择yes/no

如题所述

如果使用 python 自带的 tkinter 库 是这样实现的。

其他库的话可以查看一下api。

from Tkinter import *

from tkMessageBox import *


def answer():

    showerror("Answer", "Sorry, no answer available")


def callback():

    if askyesno('Verify', 'Really quit?'):

        showwarning('Yes', 'Not yet implemented')

    else:

        showinfo('No', 'Quit has been cancelled')


Button(text='Quit', command=callback).pack(fill=X)

Button(text='Answer', command=answer).pack(fill=X)

mainloop()

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-06-02
下个easygui模块,然后可以这样:
import easygui
Yes_or_No = easygui.buttonbox("Yes of No?", choices = ['Yes','No'])

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网