I am a novice programmer who started python 4 months ago. For awhile now I've been trying to get my squares not to touch, however I'm not skillful enough to know how...anyone have any suggestions on going about this?
from tkinter import *
from random import *
root = Tk()
## Creates canvas that will be used to create squares
canvas = Canvas(root, width=3000, height=3000)
canvas.pack(fill=BOTH)
#will keep square at a max size of 30
squareSize = 30
squareMAX = 200
square = 0
square2 = 0
## when squares are created, this array will allow them to randomly choose a color
arrayColors =["blue","green","yellow","red","white","black","cyan","magenta","purple","orange"]
#Coordinate plane
# we need an atleast one array
array = [square]
while square < squareMAX:
## REPRESENTS THE TOP LEFT CORNER OF THE SQUARE
x = randrange(0, 1200)
y = randrange(0, 650)
i = array
abs(squareSize)
square = canvas.create_rectangle(x, y, x + squareSize, y + squareSize, fill=arrayColors[randrange(0, 8)])
square = square + 1
## I need to find a way to store squares that way the newly generated squares won't overlap, perhaps using array. Append
## to store the remove squares that way we can put them back on the grid without touching.
root.mainloop()
##abs is use to compare the distance between two squares
Result: