Python学习笔记——GUI
1. 相关文档
- EasyGui 官网:http://easygui.sourceforge.net
- 官方的教学文档:easygui-docs-0.96\tutorial\index.html
- 小甲鱼翻译改编的教学文档:http://bbs.fishc.com/thread-460069-1-1.html
2. 安装步骤
① win+R 打开命令行窗口
② 按顺序输入如下代码
f:
cd "f:\codes\python\python\fishc\gui\easygui-docs-0.96"
dir
python setup.py install
它安装在 C:\Users\nigream Lin\AppData\Local\Programs\Python\Python37-32\Lib\site-packages
3. 导入gui
import easygui
easygui.msgbox('hello world!')
# 导入模块中的所有包
# 这样,调用方法就不用写模块名
# 这样可能会导致原程序中的同名方法被覆盖
from easygui import *
msgbox('你好!')
# 模块改昵称
import easygui as g
g.msgbox('hello world!')
4. 使用Easygui
import easygui as g
import sys
while 1:
g.msgbox("嗨,欢迎进入第一个界面小游戏^ ^")
msg = "请问你希望在鱼c工作室学习到什么知识呢?"
title = "小游戏互动"
choices = ["谈恋爱", "编程","00XX","琴棋书画"]
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
5. 注意:建议不要在IDLE上运行EasyGUI
EasyGui是运行在Tkinter上并拥有自身的事件循环,而IDLE也是Tkinter写的一个应用程序并也拥有自身的事件循环。因此当两者同时运行的时候,有可能会发生冲突,且带来不可预测的结果。因此如果你发现你的EasyGui程序有这样的问题,请尝试在IDLE外去运行你的程序。
6. 修改默认的样式
默认样式如下图所示:
修改choicebox控件的宽高
① 打开C:\Users\nigream Lin\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\easygui.py
② ctrl+F搜索 def __choicebox
③ 找到 root_width = int((screen_width * 0.8)) 和 root_height = int((screen_height * 0.5))
④ 将0.8改为0.4,将0.5改为0.25
修改字体
① 打开C:\Users\nigream Lin\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\easygui.py
② ctrl+F搜索 PROPORTIONAL_FONT
③ 找到 PROPORTIONAL_FONT_FAMILY = ("MS", "Sans", "Serif")
④ 将其改为 PROPORTIONAL_FONT_FAMILY = ("微软雅黑")
Python学习笔记——GUI的更多相关文章
- OpenCV之Python学习笔记
OpenCV之Python学习笔记 直都在用Python+OpenCV做一些算法的原型.本来想留下发布一些文章的,可是整理一下就有点无奈了,都是写零散不成系统的小片段.现在看 到一本国外的新书< ...
- Python学习笔记,day5
Python学习笔记,day5 一.time & datetime模块 import本质为将要导入的模块,先解释一遍 #_*_coding:utf-8_*_ __author__ = 'Ale ...
- 近期Python学习笔记
近期Python 学习笔记--一篇文入门python 作者:Pleiades_Antares(www.cnblogs.com/irischen) 写在前面的话 想学Python已经许久,一年多以前(应 ...
- python学习笔记目录
人生苦短,我学python学习笔记目录: week1 python入门week2 python基础week3 python进阶week4 python模块week5 python高阶week6 数据结 ...
- Python学习笔记之基础篇(-)python介绍与安装
Python学习笔记之基础篇(-)初识python Python的理念:崇尚优美.清晰.简单,是一个优秀并广泛使用的语言. python的历史: 1989年,为了打发圣诞节假期,作者Guido开始写P ...
- python学习笔记整理——字典
python学习笔记整理 数据结构--字典 无序的 {键:值} 对集合 用于查询的方法 len(d) Return the number of items in the dictionary d. 返 ...
- VS2013中Python学习笔记[Django Web的第一个网页]
前言 前面我简单介绍了Python的Hello World.看到有人问我搞搞Python的Web,一时兴起,就来试试看. 第一篇 VS2013中Python学习笔记[环境搭建] 简单介绍Python环 ...
- python学习笔记之module && package
个人总结: import module,module就是文件名,导入那个python文件 import package,package就是一个文件夹,导入的文件夹下有一个__init__.py的文件, ...
- python学习笔记(六)文件夹遍历,异常处理
python学习笔记(六) 文件夹遍历 1.递归遍历 import os allfile = [] def dirList(path): filelist = os.listdir(path) for ...
随机推荐
- Web UI开发速速种草—Kendo UI for jQuery网格编辑操作概述
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- linux学习-添加多个硬盘和lvm配置
原文 一般,服务器会有多个硬盘,一块硬盘分区安装操作系统,另外多块硬盘分区做存储使用.现在测试添加多块硬盘分区,使用lvm进行实现动态磁盘分配. 1.新增硬盘查看 fdisk -l 可以看到新增的两块 ...
- go html 转字符串存mysql表中
func HTMLMarshal(str string) (returnStr string) { bf := bytes.NewBuffer([]byte{}) jsonEncoder := jso ...
- C语言学习系列(五)变量和常量
一.常量 定义:在程序运行中,其值不能改变的量称为常量 分类:常量可以是任何的基本数据类型,比如整数常量.浮点常量.字符常量,或字符串字面值,也有枚举常量. 在 C 中,有两种简单的定义常量的方式: ...
- list,tuple,set,dict基础
list # @Auther : chen # @Time : 2018/4/26 19:55 # @File : list_ex.py # @SoftWare : PyCharm # list1 = ...
- array_merge与array+array的区别
结果:
- JavaWeb_(Spring框架)注解配置
系列博文 JavaWeb_(Spring框架)xml配置文件 传送门 JavaWeb_(Spring框架)注解配置 传送门 Spring注解配置 a)导包和约束:基本包.aop包+context约束 ...
- mysql8.0.17gtid方式实现主从同步
数据库的安装: [root@node1 8.0.17]# rpm -ivh mysql-community-common-8.0.17-1.el7.x86_64.rpm 警告:mysql-commun ...
- Node解析之----模块机制篇
开篇前,我们先来看张图, 看node与W3C组织.CommonJS组织.ECMAScript之间的关系. Node借鉴来CommonJS的Modules规范实现了一套非常易用的模块系统,NPM对Pac ...
- Flutter设置Container的最大最小宽高
Flutter中设置Container宽高可直接通过width和height属性来设置:如下 Container( width: 100, height: 100, color: Colors.red ...