使用的環境:
- Window10+64位操作系統
- PyCharm+Python3.7
一、安裝easygui
1. 安裝方法
1.1 方法一:CMD命令行安裝
安裝命令:
pip install easygui
1.2 方法二:PyCharm安裝
- File->Settings->Progect: Python->Progect Interpreter->+
- 搜索 easygui
- 安裝成功
1.3 方法三:通過安裝包安裝
-
下載地址: easygui
-
下載文件:
-
解壓:
-
找到easygui.py,拷貝進電腦Python安裝目錄下的Lib\site-packages文件夾下
這時打開IDLE,輸入
import easygui
回車,如果沒報錯,那就是識別到了。但是運行時會報錯,比如 AttributeError: module ‘easygui’ has no attribute ‘msgbox’ 。
不要急,這時打開cmd,直接輸入:pip uninstall easygui
。
然後等待系統自動完成,發現是最新的0.98版,沒關係,可以使用的。
2. 驗證
import easygui as g
import sys
while 1:
g.msgbox("哈嘍,帥哥!")
msg = "你喜歡我嗎?"
title = "(๑′ᴗ‵๑)I Lᵒᵛᵉᵧₒᵤ❤"
choices = ["非常喜歡", "喜歡", "好感", "不喜歡"]
choice = g.choicebox(msg, title, choices)
g.msgbox("你的選擇:" + str(choice), "結果")
msg = "重新選擇?"
title = "請選擇"
if g.ccbox(msg, title):
pass
else:
sys.exit(0)
msg = "QQ"
title = "賬號中心"
fieldNames = ["*暱稱","*電話號碼","個性簽名"]
fieldValues = []
fieldValues = g.multenterbox(msg,title,fieldNames)
while True:
if fieldValues == None :
break
errmsg = ""
print(len(fieldNames))
for i in range(len(fieldNames)):
option = fieldNames[i].strip()
if fieldValues[i].strip() == "" and option[0] == "*":
errmsg += ("【%s】:必填項 " %fieldNames[i])
if errmsg == "":
break
fieldValues = g.multenterbox(errmsg,title,fieldNames,fieldValues)