代码如下:

from tkinter import *
import webbrowser

root = Tk()

w = Canvas(root,width=400,height=200)

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)

Label(root,text="使用鼠标左键开始画图").pack(side=BOTTOM)
mainloop()

运行截图:

pythonGUI编程用Canvas模拟画板

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-03-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-28
  • 2021-06-10
  • 2022-12-23
  • 2021-06-09
相关资源
相似解决方案