1234567891011121314151617181920212223242526272829 |
- from tkinter import *
- paint_run = False
- def paint(event):
- if paint_run:
- c.create_oval(event.x-5, event.y-5, event.x+5, event.y+5, fill = 'black')
- def run(event):
- global paint_run
- if paint_run:
- paint_run = False
- else:
- paint_run = True
- root = Tk()
- root.resizable(width = False, height = False)
- root.geometry('500x500')
- root.title('MyPaint')
- c = Canvas(width = 500, height = 500, bg = 'white')
- c.focus_set()
- c.pack()
- root.bind('<Motion>', paint)
- root.bind('<Button-1>', run)
- root.mainloop()
|