Hey there,
I have written some code to draw a grid on a canvas but the code is far to long.. so I was wondering what the most efficient way to write my code would be.
self._canvas = Canvas(self, width = 450, height = 450, bg ='white', highlightthickness = 0)
self._canvas.pack(padx = 20, pady = 20)
self._canvas.create_line(0, 0, 450, 0, width = 5.0)
self._canvas.create_line(50, 0, 50, 450)
self._canvas.create_line(100, 0, 100, 450)
self._canvas.create_line(150, 0, 150, 450, width = 5.0)
self._canvas.create_line(200, 0, 200, 450)
self._canvas.create_line(250, 0, 250, 450)
self._canvas.create_line(300, 0, 300, 450, width = 5.0)
self._canvas.create_line(350, 0, 350, 450)
self._canvas.create_line(400, 0, 400, 450)
self._canvas.create_line(450, 0, 450, 450, width = 5.0)
self._canvas.create_line(0, 0, 0, 450, width = 5.0)
self._canvas.create_line(0, 50, 450, 50)
self._canvas.create_line(0, 100, 450, 100)
self._canvas.create_line(0, 150, 450, 150, width = 5.0)
self._canvas.create_line(0, 200, 450, 200)
self._canvas.create_line(0, 250, 450, 250)
self._canvas.create_line(0, 300, 450, 300, width = 5.0)
self._canvas.create_line(0, 350, 450, 350)
self._canvas.create_line(0, 400, 450, 400)
self._canvas.create_line(0, 450, 450, 450, width = 5.0)
Thanks :)