师从:小甲鱼
图形用户界面 easygui(easy故意)
1.安装
https://sourceforge.net/projects/easygui/files/0.96(下载的比较慢,虽然只有1.83M)
解压后,点击setup.exe就行。
还可以在CMD下直接输入:pip install easygui
会自动下载并安装。
成功后测试下
>>> import easygui
>>> easygui.msgbox('嗨,我是兜兜T_T')
'OK'
>>>
也可心直接导入整个包
>>> from easygui import *
>>> msgbox('嗨,我是兜兜T_T')
'OK'
>>>
为了防止这个包中的函数复盖之前的,推荐使用第三种
>>> import easygui as g
>>> g.msgbox('嗨,我是兜兜T_T')
'OK'
>>>
下面的效果:
一个例子:
import easygui as g
import sys
while 1:
g.msgbox('嗨,欢迎进入第一个界面小游戏^_^')
msg='请问你希望用python干什么呢?'
title='界面小游戏'
choices=['谈恋爱','编程','OOXX','玩游戏']
choice=g.choicebox(msg,title,choices)
# note that we convert choice 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 Continue/Cancel dialog
pass # user chos Continue
else:
sys.exit(0) # user chose Cancel
结果: