[Tutor] Help with the following code..

John Fouhy john at fouhy.net
Thu Nov 23 23:01:57 CET 2006


On 24/11/06, Asrarahmed Kadri <ajkadri at googlemail.com> wrote:
> canvas.create_rectangle(50,340,250,330)   # this is the first HORIZONTAL BAR
> canvas.pack ()
>
> root.mainloop()
> I am not able to understand why two pairs of co-ordinates are supplied?? The
> rectangle requires 4 co-ordinate pairs, Isnt it??

Hmm, I was going to refer you to Fredrik Lundh's docs, but they're a
bit thin on the ground
(http://www.pythonware.com/library/tkinter/introduction/canvas.htm).

I can think of two possibilities:

1. The arguments represent the top-left and bottom-right corners of
the rectangle.
eg, if you call create_rectangle(x0, y0, x1, y1) then the corners will be:
  (x0, y0)   (x1, y0)   (x1, y1)   (x0, y1)

2. The arguments represent the top-left corner and the width and height.
eg, if you call create_rectangle(x0, y0, w, h) then the corners will be:
  (x0, y0)   (x0+w, y0)   (x0+w, y0+h)   (x0, y0+h)

I suggest experimenting to figure out which...

-- 
John.


More information about the Tutor mailing list