[ python-Bugs-699816 ] Canvas Widget origin is off-screen
SourceForge.net
noreply at sourceforge.net
Sat Jan 15 13:46:40 CET 2005
Bugs item #699816, was opened at 2003-03-08 03:21
Message generated for change (Comment added) made by facundobatista
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 at 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 at earthlink.net
----------------------------------------------------------------------
>Comment By: Facundo Batista (facundobatista)
Date: 2005-01-15 09:46
Message:
Logged In: YES
user_id=752496
There's no file attached...
----------------------------------------------------------------------
Comment By: Facundo Batista (facundobatista)
Date: 2005-01-15 09:46
Message:
Logged In: YES
user_id=752496
Please, could you verify if this problem persists in Python 2.3.4
or 2.4?
If yes, in which version? Can you provide a test case?
If the problem is solved, from which version?
Note that if you fail to answer in one month, I'll close this bug
as "Won't fix".
Thank you!
. Facundo
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=699816&group_id=5470
More information about the Python-bugs-list
mailing list