用python tkinter创造画布 后用鼠标画画
from tkinter import *
root = Tk()
root.title('Canvas draw tool')
w = Canvas(root, width=500, height=600, background='white')
w.pack()
def paint(event):
x1, y1 = (event.x - 1), (event.y - 1)
x2, y2 = (event.x + 1), (event.y + 1)
w.create_oval(x1, y1, x2, y2, fill='red')
w.bind('<B1-Motion>', paint) #<B1-Motion>绑定鼠标左键事件
Label(root, text='按住鼠标左键并移动,开始绘制吧!~~').pack(side=BOTTOM)
mainloop()