1.easygui安装
#cmd中输入 pip install easygui自动下载与安装
2.导入easygui
>>>import easygui #导入
>>>easygui.msgbox("123") #创建easygui简单窗口
'ok' #表示创建成功
3.导入整个easygui包
第一种,可能存在变量名重复
>>>from easygui import *
>>>msgbox("")
"ok"
#另一种,推荐
>>>import easygui as g
>>>g.msgbox("123")
"ok"
3.easygui的使用
小游戏示例如下
import easygui as g
import sys
while 1:
g.msgbox("嗨,这是第一个小游戏")
msg = "你想知道什么"
title = "小游戏互动"
choices = ['恋爱', '编程', '你懂的', '文艺']
choice = g.choicebox(msg.title, choices)
#note that we convert choise to string, in case
#the user cancelled the choice, and we got None.
g.msgbox('你的选择是:' + str(choice), '结果')
msg = '想重新开始吗?'
title = '请选择'
if g.ccbox(msg.title): #show a contiune/cancle dialog
pass #user chose contine
else:
sys.exit(0) #user chose cancel