新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
Python交互式圖形編程的實(shí)現(xiàn)-創(chuàng)新互聯(lián)
一、
1、圖形顯示
- 圖素法
- 像素法
- 圖素法---矢量圖:以圖形對(duì)象為基本元素組成的圖形,如矩形、 圓形
- 像素法---標(biāo)量圖:以像素點(diǎn)為基本單位形成圖形
2、圖形用戶(hù)界面:Graphical User Interface,GUI
- Tkinter---Python 標(biāo)準(zhǔn)GUI
- Graphics---基于Tkinter擴(kuò)展圖形庫(kù)
- Turtle---python內(nèi)置的圖形庫(kù)。
3、安裝graphics庫(kù)
安裝在D:\Python3\Lib\site-packages,網(wǎng)址http://mcsp.wartburg.edu/zelle/python/graphics.py
4、graphics庫(kù)
(1)創(chuàng)建圖形窗口
圖形窗口
點(diǎn)(像素)的集合
GraphWin對(duì)象尺寸默認(rèn)值:高200像素,寬200像素。
參考坐標(biāo)系
- n Graphics\Tkinter
- n 點(diǎn)(0,0)表示屏幕左上角
- n X軸正方向?yàn)閺淖蟮接?/li>
- n Y軸正方向?yàn)閺纳系较隆?/li>
- n 默認(rèn)窗口大小為200*200
簡(jiǎn)潔形式
(2)點(diǎn)
移動(dòng)點(diǎn)
move(x,y)方法
清除原來(lái)點(diǎn)的圖像,并在新位置重新繪制
兩個(gè)數(shù)字參數(shù):x,y
(2)圓
from graphics import * win=GraphWin() leftEye=Circle(Point(80,80),5) leftEye.setFill("yellow") leftEye.setOutline("red") rightEye=leftEye rightEye.move(40,0) leftEye.draw(win) rightEye.draw(win)
分享文章:Python交互式圖形編程的實(shí)現(xiàn)-創(chuàng)新互聯(lián)
文章源于:http://fisionsoft.com.cn/article/depphc.html