Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_basic_paint_demo.py
- from Tkinter import *
- canvas_width=500
- canvas_height=400
- px=py=None
- def oRGB(rgb): # pass
- r,g,b = rgb
- return "#%02x%02x%02x" % (r,g,b)
- def paint(event):
- global px,py
- x,y=event.x, event.y
- w.create_line((x, y, px, py), width=3, fill=oRGB([255,128,0]))
- px,py=x,y
- def mouse_btn_down(event):
- global px,py
- px,py=event.x, event.y
- master=Tk()
- master.title("Tk Basic Paint Demo")
- w = Canvas(master,
- width=canvas_width,
- height=canvas_height)
- w.pack(expand=YES, fill=BOTH)
- w.bind("<B1-Motion>", paint)
- w.bind('<1>', mouse_btn_down)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement