当前位置:K88软件开发文章中心编程语言PythonPython01 → 文章内容

画图,学用line画直线。

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-6 1:23:40

无。

实例


#!/usr/bin/python

# -*- coding:
UTF-8 -*-
if __name__ == '__main__':
from Tkinter import *canvas = Canvas(width=300, height=300, bg='green')canvas.pack(expand=YES, fill=BOTH)x0 = 263y0 = 263y1 = 275x1 = 275for i in range(19):
canvas.create_line(x0,y0,x0,y1, width=1, fill='red')x0 = x0 - 5y0 = y0 - 5x1 = x1 + 5y1 = y1 + 5x0 = 263y1 = 275y0 = 263for i in range(21):
canvas.create_line(x0,y0,x0,y1,fill = 'red')x0 += 5y0 += 5y1 += 5mainloop()

以上实例输出结果为:

Python 100例

2 篇笔记 写笔记


  1. #2

       bihar

      sbh***163.com

    参考实例:


    #!/usr/bin/python
    # -*- coding:
    UTF-8 -*-from Tkinter import *canvas=Canvas(width=300,height=300,bg='white')canvas.pack(expand=YES, fill=BOTH)x1,y1=50,20x2,y2=100,20x3,y3=75,40x4,y4=75,100canvas.create_line(x1,y1,x3,y3, width=3, fill='red')canvas.create_line(x2,y2,x3,y3, width=3, fill='red')canvas.create_line(x1,y1,x4,y4, width=3, fill='red')canvas.create_line(x2,y2,x4,y4, width=3, fill='red')mainloop()

画图,学用line画直线。