This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Canvas Widget origin is off-screen
Type: Stage:
Components: Tkinter Versions: Python 2.2
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: facundobatista, newbieroy
Priority: normal Keywords:

Created on 2003-03-08 06:21 by newbieroy, last changed 2022-04-10 16:07 by admin. This issue is now closed.

Messages (4)
msg15032 - (view) Author: Roy Keir (newbieroy) Date: 2003-03-08 06:21
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                
msg15033 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2005-01-15 12:46
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
msg15034 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2005-01-15 12:46
Logged In: YES 
user_id=752496

There's no file attached...
msg15035 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2005-05-30 19:32
Logged In: YES 
user_id=752496

Deprecated. Reopen only if still happens in 2.3 or newer. 

.    Facundo
History
Date User Action Args
2022-04-10 16:07:29adminsetgithub: 38128
2003-03-08 06:21:41newbieroycreate