Scrollbar information with the "get" command 
Author Message
 Scrollbar information with the "get" command

--
Hello,

I have a problem related to the scrollbar information you get with the
"pathname get" command. The manual page says "These are the values from
the most recent set widget command on the scrollbar". My question is if
there's a way to get the updated values from this command without
executing the "update" command first, since "update" also causes the
canvas to be unnecessary redrawn.

Background:
-----------
I have an application where I'm scrolling and zooming a canvas. To zoom,
I use the "scale" command, but after that I need to issue xview and yview
commands to scroll automatically, so that center in the visible part of the
canvas remains the same as before the zoom.

Now I have code that does just that. It is based on reading the status of
the scrollbars before and after the scale with the "pathname get" command
and from this computing the automatic scrolling needed to preserve the
center. The disadvantage is that I need to issue an "update" command after
the scale to get the new "pathname get" info. This means the canvas is redrawn
before the automatic scroll, and then immediately redrawn after the scrolling.
I want to avoid the canvas from being drawn twice. But how?

A code example:
---------------
Definitions in main routine:
   canvas .t.frame.t.canv -scrollregion "${x_s}c ${_y_s}c ${x_e}c ${y_e}c \
           -xscroll ".t.frame.b.hscroll set" -yscroll ".t.frame.t.vscroll set"          
   scrollbar .t.frame.t.vscroll -relief sunken \
              -command ".t.frame.t.canv yview"
   scrollbar .t.frame.b.hscroll -orient horiz -relief sunken \
              -command ".t.frame.t.canv xview"

Zoom routine (parts of code):
   set w .t.frame.t.canv

  # Using get command to get scrollbar info before scale
   set xtot_o [lindex [.t.frame.b.hscroll get] 0]
   .
   puts [.t.frame.b.hscroll get]         (Here: 59 58 0 59)
   .                                     ------------------
  # Scaling with lattice upper corner as origo
   $w scale all $scroll_x_start $scroll_y_start 2 2
   .
  # Setting the new scrollregion
   $w configure -scrollregion $regbounds
   .
   puts [.t.frame.b.hscroll get]         (Here: Still 59 58 0 59)
   update                                ------------------------
   puts [.t.frame.b.hscroll get]         (Here: Now: 113 57 0 58)
   .                                      ------------------------
  # Using get command to get scrollbar info after scale
   set xtot_n [lindex [.t.frame.b.hscroll get] 0]
   .
   .
  # Automatic scrolling to center picture
   $w xview...

I want the [.t.frame.b.hscroll get] to be updated without having to use
the "update" command. Can the update command be replaced by something else,
or can the problem be solved another way? (By the way, this is Tcl7.3/Tk3.6).


--

Consultant, Software Development                Phone: +47 63 81 49 20
Division for Nuclear and Petroleum Engineering  Fax: +47 63 81 88 22
Scandpower A/S, International Consultants       Address: P.O. Box 3
--                                              N-2007 Kjeller, NORWAY



Fri, 08 May 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. scrollbar "moveto" fraction computed wrong

2. Problem "bad option delta" with Scrollbar

3. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

4. HELP: Scrollbar information with the "get" command

5. Searching information about "learningworks"

6. Searching information about "learningworks"

7. "Information about the front panel of "Measure frequency

8. Request: Information about the "S"-Language

9. Information requested about "WISL"

10. about utility program named "Winteracter "...i need any information about the program..^^

11. collecting information from "call graph"

12. .button "configure" returns wrong information

 

 
Powered by phpBB® Forum Software