MyPaint.py 533 B

1234567891011121314151617181920212223242526272829
  1. from tkinter import *
  2. paint_run = False
  3. def paint(event):
  4. if paint_run:
  5. c.create_oval(event.x-5, event.y-5, event.x+5, event.y+5, fill = 'black')
  6. def run(event):
  7. global paint_run
  8. if paint_run:
  9. paint_run = False
  10. else:
  11. paint_run = True
  12. root = Tk()
  13. root.resizable(width = False, height = False)
  14. root.geometry('500x500')
  15. root.title('MyPaint')
  16. c = Canvas(width = 500, height = 500, bg = 'white')
  17. c.focus_set()
  18. c.pack()
  19. root.bind('<Motion>', paint)
  20. root.bind('<Button-1>', run)
  21. root.mainloop()