本周将进行python图形编程的介绍
图形基本介绍
Python图形基本介绍
图形工具包:
tkinter(简称tk接口)
Graphics
turtle
图形用户界面
Graphical User Interface (GUI)
Tkinter——Pyhton标注GUI
Graphics——基于Tkinter扩展
Turtle——python内置的图形库
例:简单图形编程
1.导入图形模块
import graphics
2.创建图形窗口
win = graphics.GraphWin()
3.关闭窗口
win.close()
简单表达
>>> from graphics import *
>>> win = GraphWin()
>>>
参考坐标系
1.Graphics\Tkinter
点(0.0)表示屏幕左上角
2.X轴正方向为从左到右
3.Y轴正方向为从上到下
4.默认窗口大小为200*200
>>> from graphics import *
>>> p1=Point(100,100) #在(100,100)位置创建点对象
>>> p1.getX() #获得左边点横坐标,同样方法可得纵坐标
100.0
>>> p2=Po