电脑
python3.6
tkinter模块
先建立一个300*190的画板(画布、canvas),然后画对角线:from tkinter import *master = Tk()canvas_width = 300canvas_height = 190w = Canvas(master, width=300,height=190)w.pack()w.create_line(0,0,300,190)mainloop()
把对角线变粗,线色改为绿色:w.create_line(0,0,300,190, fill='green', width=2,)
画一条贯穿画布的绿色横线:w.create_line(0,30,300,30, fill='green', width=2,)
再画一条纵贯画布的红色竖线:w.create_line(100,0,100,190, fill='red', width=2,)
用for语句批量画横线和竖线,就是棋盘:for i in range(10): w.create_line(0,int(190/10*i),300,int(190/10*i), fill='green', width=2,) w.create_line(int(300/10*i),0,int(300/10*i),190, fill='red', width=2,)
棋盘的网格线密集化。
用两个for循环,把横线和竖线分开来画。
本文棋盘网格线的代码在pan.baidu.com/s/1cue5St_u7oxkvauD_b1p_Q 下载密码是9dc9。