Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. from Tkinter import *
  2.  
  3. class PaintBox( Frame ):
  4.    def __init__( self ):
  5.       Frame.__init__( self )
  6.       self.pack( expand = YES, fill = BOTH )
  7.       self.master.title( "BuketFile :D" )
  8.       self.master.geometry( "500x250" )
  9.  
  10.       self.message = Label( self, text = "Presiona para colorear la figura" )
  11.       self.message.pack( side = BOTTOM )
  12.      
  13.       # crea Canvas
  14.       self.myCanvas = Canvas( self )
  15.       self.myCanvas.pack( expand = YES, fill = BOTH )
  16.  
  17.       # dibuja evento de Canvas
  18.       self.myCanvas.bind( "<B1-Motion>", self.paint )
  19.       self.myCanvas.create_oval( 10,10, 100,100, fill = 'gray' )
  20.       self.myCanvas.create_rectangle( 300,200, 100,100, fill = 'gray' )
  21.      #buket()
  22.      
  23.  
  24.    def paint( self, event ):
  25.       x1, y1 = ( event.x - 4 ), ( event.y - 4 )
  26.       x2, y2 = ( event.x + 4 ), ( event.y + 4 )
  27.       #if x1 ==10 and y1==10:
  28.       for x1 in range(100):
  29.          for y1 in range(100):
  30.             self.myCanvas.create_rectangle( x1, y1, x2, y2, fill = "red" )
  31.        #while event.x > 0:
  32.         #    x1++
  33.          #   while event.y > 0:
  34.           #     y1++
  35.                
  36.  
  37.    #def floodfill_queue(self, target, repl):  
  38.     #if target != self.color:  
  39.      #   return  
  40.  
  41.     #q = [self]  
  42.     #while q:  
  43.         #n = q.pop(0)  
  44.         #n.color = repl  
  45.         #for x in [n.west(), n.east(), n.north(), n.south()]:
  46.             #if x.color == target:  
  47.                 #x.color = repl  
  48.                 #q.append(x)        
  49.    #def buket(self,event):
  50.     #  if event.x ==10 and event.y==10:
  51.      #    while event.x > 0:
  52.       #      while event.y > 0:
  53.        #         paint()
  54.        
  55.    
  56. def main():
  57.    PaintBox().mainloop()
  58.  
  59. if __name__ == "__main__":
  60.    main()