[Tutor] Help with the following code..

Alan Gauld alan.gauld at btinternet.com
Fri Nov 24 00:06:20 CET 2006

"Bob Gailer" <bgailer at alum.rpi.edu> wrote
> Asrarahmed Kadri wrote:

>> I am not able to understand why two pairs of co-ordinates are
>> supplied?? The rectangle requires 4 co-ordinate pairs, Isnt it??

> "6.9. The canvas rectangle object - Each rectangle is specified as 
> two
> points: (x0, y0) is the top left corner, and (x1, y1) is the bottom 
> right
> corner."

As Bob says it only needs 2 points because by definition a rectangle
has the same x value for the two left corners and the same y values
for the two top corners so only 4 values are required not 4 points.
And the 4 values can be achieved by specifying a pair of opposite
corner coordinates.

So if Top Left is x1,y1
and Bottom Right is x2,y2 then

Top Right must be x2,y1
and Bottom Left will be x1,y2

So from two corners Tkinter can derive the rest

> I highly advise you get a reference. The Tkinter module document 
> under
> the Python Manuals - Global Module Index lists several. BTW how can 
> you
> write code without a reference? Are you copying examples?

I think he has a reference but just couldn't see how you could draw
a 4 cornered shape with only two corners specified.

At least, that's how I read his post.

Alan G.

More information about the Tutor mailing list