1
votes

I have come across this weird behavior of Tkinter where the first 3 lines in both x and y directions (x=0,1,2 and y=0,1,2) don't actually show up.

For example if I run the following code,

from tkinter import *
master = Tk()

w = Canvas(master, width=200, height=200)

w.pack()

w.create_line(0, 0, 0, 100, fill="red")
w.create_line(1, 0, 1, 100, fill="blue")
w.create_line(2, 0, 2, 100, fill="green")
w.create_line(3, 0, 3, 100, fill="black")

w.create_line(0, 0, 100, 0, fill="red")
w.create_line(0, 1, 100, 1, fill="blue")
w.create_line(0, 2, 100, 2, fill="green")
w.create_line(0, 3, 100, 3, fill="black")

mainloop()

I would get this result, note how in both directions, the red, blue and green lines don't show up. Only the black lines show up. I tried searching but couldn't find anything related to this issue. Thank you in advance!

1

1 Answers

1
votes

Set the borderwidth and highlightthickness to zero. The border is drawn inside the boundaries of the canvas.

w = Canvas(..., borderwidth=0, highlightthickness=0)