Canvas paint: controlled by Scale : Scale « GUI Tk « Python






Canvas paint: controlled by Scale

Canvas paint: controlled by Scale
from Tkinter import *

class ScaleDemo( Frame ):
   def __init__( self ):
      Frame.__init__( self )
      self.pack( expand = YES, fill = BOTH )
      self.master.title( "Scale Demo" )
      self.master.geometry( "220x270" )

      self.control = Scale( self, 
                            from_ = 0, 
                            to = 200, 
                            orient = HORIZONTAL, 
                            command = self.updateCircle )
                            
      self.control.pack( side = BOTTOM, fill = X )
      self.control.set( 10 )

      self.display = Canvas( self, bg = "white" )
      self.display.pack( expand = YES, fill = BOTH )

   def updateCircle( self, scaleValue ):
      end = int( scaleValue ) + 10
      self.display.delete( "circle" )
      self.display.create_oval( 10, 10, end, end,fill = "black", tags = "circle" )

def main():
   ScaleDemo().mainloop()   

if __name__ == "__main__":
   main()

           
       








Related examples in the same category

1.Scale Demo: random choiceScale Demo: random choice
2.Use Scale
3.Bound Scale action with a canvasBound Scale action with a canvas
4.Scale widgetScale widget
5.Scale Demo: get scale value and open different dialogsScale Demo: get scale value and open different dialogs
6.Scale: get Scale valueScale: get Scale value
7.Scale used to control the size of a circleScale used to control the size of a circle