这里在win端的xming远程显示rhel6中运行的easygui例程。
实验代码
import easygui as g
import sys
while 1:
g.msgbox("嗨,欢迎进入第一个界面小游戏^_^")
msg ="请问你希望在鱼C工作室学习到什么知识呢?"
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 chose Continue
else:
sys.exit(0) # user chose Cancel
1.Non-ASCII character ‘\xe8’ in file
SyntaxError: Non-ASCII character '\xe8' in file test.py on line 8, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
# -*- coding: UTF-8 -*- #置于文件头,更改为utf-8编码格式
2.No module named easygui
[root@ton home]#pip install easygui
-bash: pip: command not found
安装pip
yum install python-pip
pip install easygui
出错
[root@ton ~]#pip install easygui -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com #采用国内的镜像源来加速
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Collecting easygui
Downloading http://pypi.doubanio.com/packages/fb/13/87317e601d95d4e141800d3666dff54242b05d512d76f126408cc7c66b12/easygui-0.98.2-py2.py3-none-any.whl (92kB)
100% |████████████████████████████████| 94kB 1.3MB/s
Installing collected packages: easygui
Successfully installed easygui-0.98.2
3.easygui与python版本不兼容
Exception: You must run on Python 2.7+ or Python 3.4+
编译安装python3.6
https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
参考https://www.cnblogs.com/zimo-jing/p/11873413.html
为py3.6安装easygui
[root@paly bin]#cd /usr/local/python36/bin
[root@paly bin]#./pip3 install easygui #我这里安装过了
Requirement already satisfied: easygui in /usr/local/python36/lib/python3.6/site-packages
You are using pip version 9.0.1, however version 22.0.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
No module named ‘global_state’
参考https://stackoverflow.com/questions/40588444/how-to-install-python3-tk-in-centos
因为EasyGui是运行在Tkinter
,需在python3安装tkinter。
这里如果是centos7及以上可以直接yum install python3-tkinter
解决,由于我用的是centos6没有找到python3-tkinter的源资源,用如下操作解决问题。
1.
[root@ton home]#yum -y install tkinter tcl-devel tk-devel
2.
[root@ton home]#vim /home/Python-3.6.0/Modules/Setup.dist
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \
-L/usr/local/lib \
-I/usr/local/include \
-ltk8.2 -ltcl8.2 \you installed in step1
-lX11
3.
./configure --prefix=/usr/local/python36
make && make install