[Tutor] Pmw ScrolledCanvas Issues ..........

Abel Daniel abli@freemail.hu
Tue Jun 10 05:02:29 2003


Suresh  Kumar wrote:
> The problem is setting sroll bar to the center 
> of the canvas after scalling. I have placed some rectangles, ovals 
> in the canvas and used "scale" to scall the canvas. After scalling 
> i called "resizescrollregion()" and tried to place the scroll bar 
> to the center (Using yview('moveto',...)). But the scroll bars are 
> moving only one direction. This means, verticalscrollbar is moving 
> "Up" and   horizantalscroll bar is moving "Right". It is not 
> moving to center. My coding is given below.
So, the problem is that even though you call self.centerPage() in
scalecanvas, it does nothing and doesn't center the canvas, right?

I'm not exactly sure what causes this, (most likely an optimization in
Tkinter or Tcl/Tk) but the problem is that you call centerPage after
self.sc.resizescrollregion() and somehow centerPage still gets the old
size, i.e. the resizeing didn't happen yet. 
Inserting a call to self.sc.update_idletasks() between the two makes
the problem go away.

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


Abel Daniel