Tchae

Untitled

Feb 5th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. #! /usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. from Tkinter import*
  5.  
  6.  
  7. def manager(event):
  8.     global second,rect
  9.     if not(second):
  10.             position(event)
  11.             rect=[event.x, event.y]
  12.             second=not(second)
  13.     else:
  14.         position(event)
  15.         second=not(second)
  16.         dessine(event)
  17.  
  18. def position(click):
  19.     afficheur['text'] = '%s, %s' % (click.x,click.y)
  20.  
  21. def dessine(event):    
  22.     x,y=event.x, event.y
  23.     ew=event.widget
  24.     ew.create_rectangle(rect[0],rect[1],x,y, fill='DeepPink3', outline='')
  25.    
  26.  
  27.  
  28. rect=[0,0]
  29. second=False
  30. top=Tk()
  31. C=Canvas(top, width=750,height=700, bg='light yellow')
  32. C.pack()
  33.  
  34. C.bind("<Button-1>", manager)
  35. afficheur = Label(top)
  36. afficheur.pack()
  37.  
  38. top.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment