How do I get the fractions of the visible part of a canvas?

Mickel Grönroos mickel at csc.fi
Wed Jul 2 09:58:07 CEST 2003


Hi,

I have a Tkinter.Canvas of variable width. Is there a standard way of
asking the canvas which parts of it that is visible? I.e. on the
horizontal scale, I would like to know at what fraction from the left the
left visibility border is and from what fraction to the right the right
visibility border is.

Consider this ascii picture as an example

+-------------------------------+
|                               |<-- the full canvas
|     a------------------+      |
|     |                  |<--------- the currently visible part
|     +------------------b      |
|                               |
+-------------------------------+

I would like to be able to ask the canvas something like:

t = canvas.visiblebox()

and it would return a two-tuple of two-tuples with coordinates (of the
a and b points in the picture above), say:

t = ((10,10), (90,30))

Using these values I could calculate the fractions myself.

Any ideas?

/Mickel

--
Mickel Grönroos, application specialist, linguistics, Research support, CSC
PL 405 (Tekniikantie 15 a D), 02101 Espoo, Finland, phone +358-9-4572237
CSC is the Finnish IT center for science, www.csc.fi






More information about the Python-list mailing list