Sid
Sid

Reputation: 1269

Drawing rectangle on python Tkinter canvas that covers the entire canvas does not show border on top and left

I'm trying to create a rectangle inside a Tkinter (Python 2.7) canvas that is the same dimension as the canvas. Here is the relevant part of the code:

self.canvas = Canvas(self, width=100, height=100, backround="yellow")
self.canvas.create_rectangle(0,0,100,100)

This draws a rectangle but I can't see the left and top border of the rectangle. If I start the rectangle from let's say 5,5 instead of 0,0 I can see the border of the rectangle. Any ideas as to why this happens, and how I can get around it?

Upvotes: 1

Views: 2838

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386382

Unfortunately, the canvas border is included in the drawable region. Try setting the borderwidth and highlightthickness attributes to zero on the canvas.

You'll also want to adjust the coordinates of your rectangle to end at 99, since counting starts at zero (if the width is 100, the coordinates go from 0 to 99).

Upvotes: 2

Related Questions