图形显示:图素法、像素法
对应矢量图和标量图
python图形工具包:tkinter、Graphics、turtle
图形用户界面GUI,pyhon中为tkinter
http://mcsp.wartburg.edu/zelle/python/graphics.py
将graphics.py放到C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\Lib\site-packages下
默认左上角点为(0,0)
图形用户界面(图形用户接口):图形方式计算机操作界面,用于程序的输入和输出,事件驱动
TKinter创建GUI程序基本步骤:
1.导入TKinter模块
2.创建GUI程序的主窗口
3.添加控件或者GUI应用程序
4.进入主事件循环,等待响应用户触发事件
三种几何管理方法:pack(),grid(),place()
模板:
from tkinter import *
tk = Tk()
#添加控件码
tk.mainloop()
GraphWin对象:
程序可定义任意数量窗体
GraphWin(),默认标题,默认大小
Point对象方法:
point(X,Y) 以指定坐标值(X,Y)构造一点
getX()
getY()
Line对象方法:
Line(point1,point2)
setArrow(string) string=first;last;both;none
getCenter()
getP1(),getP2()
Circle对象方法:
Circle(centerPoint,radius)
getCenter()
getRadius()
getP1(),getP2() 返回圆形外接正方形的对角点的克隆值
Retangle对象方法:
Retangle(point1,point2)
getCenter()
getP1(),getP2()
Oval对象方法:
Oval(point1,point2) 长轴界和短轴界
getCenter()
getP1(),getP2() 对角点
Polygon对象方法:
Polygon(point1,point2,point3...)
getPoints() 返回顶点值列表
pyhon中颜色由字符串确定,如red1,red2等
color_rgb(red,green,blue)亦可指定颜色
界面设计的实现过程:
界面布局设计
创建所需控件
设定事件和命令响应
对控件进行布局
完成程序代码