[Python-bugs-list] [ python-Bugs-699816 ] Canvas Widget origin is off-screen
SourceForge.net
noreply@sourceforge.net
Fri, 07 Mar 2003 22:21:41 -0800
Bugs item #699816, was opened at 2003-03-07 23:21
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=699816&group_id=5470
Category: Tkinter
Group: Python 2.2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Roy Keir (newbieroy)
Assigned to: Nobody/Anonymous (nobody)
Summary: Canvas Widget origin is off-screen
Initial Comment:
I'm a Python newbie, so be patient. I noticed that create-<item> didn't place the item where I expected.
My help@Python.org guru Matt Cowles suggested that highlightthickness (hT hereinafter) might be the
culprit. I wasn't using hT, but I was using borderwidth (bd to all), and I eventually found the problem. I
believe that it is an error in Tkinter, but I'll be happy to be corrected.
I wrote a program to display the canvases with the four combinations of hT and bd, and later I doubled up
to see if 'relief' with bd==0 had any effect. I'll try to upload the code (oops. It invoves two modules. I may
have to send two messages, one with each module).
Here is what I think happens, and what I think should happen :
DOES: SHOULD:
Tkinter finds screen coordinates cx, cy of Canvas same
(crucial step omitted) tx, ty = cx, cy
Tkinter translates cx, cy = cx - bd, cy -bd tx, ty = tx- bd, ty - bd
Tkinter draws the border (width is 2*bd wider than the Canvas) draws the border
Tkinter translates cx, cy = cx - hT, cy - hT tx, ty = tx - hT, ty - hT
Tkinter draws the highlight box (width is 2*hT wider than the border) draws the hightlight box
Tkinter delivers cx, cy as the origin of the Canvas delivers cx, cy as the origin
The attached program, if it arrives, demonstrates this effect. Any one doing serious graphics will need to
adjust the x,y values of every Canvas item they draw. Putting a wrapper around each to .get() the values
of hT and bd (and others I haven't discovered yet ?) is feasible but awful. Putting a function at the top of
each event callback function to correct the event object x and y is even more awkward.
To preserve backwards compatibility, I suggest that Tkinter Canvas items all be given an extra set of x
and y values, with distinctive names. The user can put any old values in the current x,y positional spots
and use xcorrected = NN, ycorrected=NN to override the stuff in the positional spots. To handle the
variable number of x,y pairs in create_polygon(), create_line(), and perhaps other, Tkinter might require
that the new values be given in a tuple of pairs or two tuples (x0,x1,x2) & (y0,y1,y2)
The attached file is TkCoords03.py The next error will include algGrid03.py. Hope you can get them
together.
Roy Keir newbieroy rmkeir@earthlink.net
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=699816&group_id=5470