Hi,

    This is the updated version of my previous query which has the 
subject "Pmw ScrolledCanvas Issues". Iam using Pmw 
"ScrolledCanvas" in my application and want to place the scroll 
bars to center of the canvas after scalling (using "scale"). As 
per the guidelines given by "Abel Daniel" i used  
"update_idletasks()" to place the scrollbars to canvas center 
after scalling. It is working fine in all aspect except iam 
getting some flickering since "scale" places canvas objects in one 
place and subsequent "update_idletasks()" call moves the objects 
to the desired location.

    My code is given below:

import Tkinter
import Pmw

class Demo:
      def __init__(self, parent):
  	# Create the ScrolledCanvas.
  	self.sc = Pmw.ScrolledCanvas(parent,
  		borderframe = 1,
  		labelpos = 'n',
  		label_text = 'ScrolledCanvas',
  		usehullsize = 1,
                 hscrollmode = 'dynamic', #'static', #
 		vscrollmode = 'dynamic',
  		hull_width = 1500,
  		hull_height = 1400,
  	)

  	# Pack this last so that the buttons do not get shrunk when
  	# the window is resized.
  	self.sc.pack(padx = 5, pady = 5, fill = 'both', expand = 1)

  	self.sc.component('canvas').bind('<1>', self.addcircle)
  	self.sc.component('canvas').bind('<2>', self.scalecanvas)
  	self.sc.component('canvas').bind('<3>', self.zoomout)
          testEntry = Tkinter.Entry(parent)
  	self.sc.create_line(20, 20, 100, 100)
  	self.sc.create_oval(100, 100, 200, 200, fill = 'green',tag =
'oval')
  	# Set the scroll region of the canvas to include all the 
items
  	# just created.
  	self.sc.resizescrollregion()

          self.colours = ('red', 'green', 'blue', 'yellow', 
'cyan',
'magenta','black', 'white')
  	self.oval_count = 0
          self.rand = 12345

      def zoomout(self,event):
          self.sc.scale('all',0,0,0.5,0.5)
  	 self.sc.resizescrollregion()

      def scalecanvas(self,event):
          self.sc.scale('all',0,0,2,2)
          self.sc.resizescrollregion()
          self.sc.update_idletasks()
        	 self.centerPage()

       def centerPage(self):
          top, bottom = self.sc.yview()
          size = bottom - top
          middle = 0.5 - size / 2
          self.sc.yview('moveto', middle)
          left,right = self.sc.xview()
          size = right - left
           middle = 0.5 - size / 2
          self.sc.xview('moveto', middle)

######################################################################

# Create demo in root window for testing.
if __name__ == '__main__':
      root = Tkinter.Tk()
      Pmw.initialise(root, fontScheme = 'pmw1')
      exitButton = Tkinter.Button(root, text = 'Exit', command =
root.destroy)
      exitButton.pack(side = 'bottom')
      widget = Demo(root)
      root.mainloop()

    How can i stop flickering or "double movement" to avoid 
flickering?

With Regard
V.Suresh Kumar

___________________________________________________
Get email that means BUSINESS! me @ mycompany.com.
Just Rs.1499/year.
To start, click http://www.rediffmailpro.com




