Pmw.Counter and Pmw.ScrolledCanvas questions

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Fri Jul 12 11:13:45 EDT 2002


On Thursday 11 Jul 2002 11:54 pm, John McMonagle wrote:
> > As for the ScrolledCanvas are you using the .scale() canvas method.  If
> > so the call looks somthing like
> >
> > mycanvas.scale("ALL", xorigin, yorigin, xscale, yscale)
> >
> > and setting xorigin and yorigin to the top left points from you 'zoom
> > box' should do what you want, to get those I would bbox the rectangle I
> > guess you are drawing when they do the button-3-press-move-release dance.
> >  Oh and don;t forget to call resizescrollregion() after zooming.
> >
> > This is an example that seems to work (for me!)
>
> Thanks for those suggestions Martin.
>
> Unfortunately I'm not using the scale method to zoom.  I actually need
> to redraw all the canvas objects because I'm mapping canvas xy coords
> to eastings/northings on a map.  So, from the size of the zoom box I
> calculate a new scale factor at which to draw my map, I draw my map,
> then I want the canvas to be scrolled to the point where the zoom box
> began.
>
> What I've got now is my map is correctly drawn after the zoom box drag
> but it's starting position is at the top left of the scrolled canvas.
> After drawing items on a scrolled canvas and resizing the scrolled
> region how do you programatically scroll the canvas to a desired
> point.
>
> Any ideas ?

Take a look at the Canvas '*view' methods and set their position.


from pydoc Tkinter.Canvas

 |  xview(self, *args)
 |      Query and change horizontal position of the view.
 |  
 |  xview_moveto(self, fraction)
 |      Adjusts the view in the window so that FRACTION of the
 |      total width of the canvas is off-screen to the left.
 |  
 |  xview_scroll(self, number, what)
 |      Shift the x-view according to NUMBER which is measured in "units" or 
"pages" (WHAT).
 |  
 |  yview(self, *args)
 |      Query and change vertical position of the view.
 |  
 |  yview_moveto(self, fraction)
 |      Adjusts the view in the window so that FRACTION of the
 |      total height of the canvas is off-screen to the top.
 |  
 |  yview_scroll(self, number, what)
 |      Shift the y-view according to NUMBER which is measured in "units" or 
"pages" (WHAT).

Cheers






More information about the Python-list mailing list