环境:ubuntu18.04 LTS
EasyGUI是一个Python GUI模块
PyCharm安装第三方库
编写第一个GUI程序
一个按钮
import easygui
res = easygui.msgbox("Hello There")
print(res)
编译运行:出现错误:
import tkinter as tk # python3
ModuleNotFoundError: No module named ‘tkinter’
解决方法:
- sudo apt-get install python3-tk
运行结果:
按下按钮之后,打印:“ok”
多个按钮
import easygui
res = easygui.buttonbox("please select one:", "favorite Tag", ["C/C++", "Go", "Python", "Rust", "Ruby", "Lua"])
print(res)
运行
选择框
import easygui
res = easygui.choicebox("please select one:", "favorite Tag", ["C/C++", "Go", "Python", "Rust", "Ruby", "Lua"])
print(res)
文本输入框
import easygui
res = easygui.enterbox("please select one:", "favorite Tag")
print(res)
默认输入
import easygui
res = easygui.enterbox("please select one:", "favorite Tag", "c++")
print(res)
整数输入框
import easygui
res = easygui.integerbox("please select one:", "favorite Tag")
print(res)
只允许输入整数,不允许浮点数,字符串
修改字体
- 这个方法没有用
官网资料:http://easygui.sourceforge.net/sourceforge_site_as_of_2014_11_21/download/version_0.96/index.html