[Tutor] Tkinter image with "hyperregions"
Koen Bossers
koen@behindthesofa.dhs.org
Sat, 18 Aug 2001 11:17:18 +0200
Hi everybody,
I'm trying some stuff with Tkinter. Right now, I'm writing a class
MakeMap that displays an image. The user can select different regions
within that image and assign functions to them. Makemap then writes a
class that contains the image with the "hyperregions" and its
corresponding function calls as event bindings (OK this might be a bit
unclear, imagine a picture of a calculator. the user selects a square
around the "1" button and assigns a function to it).
If I use Canvas Rectangles for example for the region selection, I can
use canvas.find_overlapping() to determine which rectangle is clicked.
Unfortunately, this only works if the rectangle is visible, for example
a rectangle with transparent fill and outline will NOT work with this
method.
To avoid this, I wrote a funtion that determines if the mouse click is
in a "hyperregion", knowing the positions and sizes of the rectangles
that make up the "hyperregions". This is easy for rectangles and
probably also for ellipses, but I also like to add functionality for
polygons. I have no idea how to determine all the pixels that make up
the polygon, so I don't know whether a user clicked on the polygon or not.
So the question is, is there another method of determining if a user
clicked a canvas.rectangle than canvas.find_overlapping(), or is there a
way to determine all the pixels that a polygon contains, or is there a
way to use a COMPLETELY transparent canvas.rectangle so that
canvas.find_overlapping() works?
Sorry for the long ang probably unclear questions. Hope somebody can
help....
Cheers, Koen Bossers