Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- # -*- coding: utf-8 -*-
- from Tkinter import*
- def manager(event):
- global second,rect
- if not(second):
- position(event)
- rect=[event.x, event.y]
- second=not(second)
- else:
- position(event)
- second=not(second)
- dessine(event)
- def position(click):
- afficheur['text'] = '%s, %s' % (click.x,click.y)
- def dessine(event):
- x,y=event.x, event.y
- ew=event.widget
- ew.create_rectangle(rect[0],rect[1],x,y, fill='DeepPink3', outline='')
- rect=[0,0]
- second=False
- top=Tk()
- C=Canvas(top, width=750,height=700, bg='light yellow')
- C.pack()
- C.bind("<Button-1>", manager)
- afficheur = Label(top)
- afficheur.pack()
- top.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment