Help with use of windows on a canvas.

ngs (N.G.Smith@ukc.ac.uk)
Fri, 03 Feb 95 15:06:09 GMT

I have been using Tkinter with the Life Preserver documentation and the
manual pages, but have now hit a bit of a problem. I have come up with
my own solution, but would appreciate advice as to whether it is the
best.

I have taken the example canvas scripts, and had a canvas with scrollbars
creating and moving ovals. No problem. I then replaced the oval with a
window. The behaviour changes such that it is no longer possible to move
this window in the way that I could move the oval.

I am guessing that this is because the window gets mouse events before
the canvas. So what I did was to bind mouse motion events to something
within the window, and call the move method on the canvas. This strikes
me as kludgy for a number of reasons.

1. I also lost the canvas notion of "current", (presumably because mouse enter
and leave events are also being caught by the window.

2. I have to keep the object id when I create_window it and pass it back into
the object so that when it knows that it is being moved it can call
canvas.move with the correct id, (we've lost "current", see 1.)

3. When I receive the motion event in the window, the coordinates are no
longer relative to the canvas and I have to do some pretty gross munging
to get them relative to the canvas.

As someone said. ``there's got to be a better way!'' Can someone point me
in the right direction?

Thanks,

Neil.