I work with Python (PyCharm as IDE) and tkinter and I'm trying to create a four in a row game. As such I'm struggling to visualise the build-up of the empty fields.
I have the following Code:
Main:
def generate_field(mainframe):
empty_cell = PhotoImage\
("C:\\... Pseudopath which works")
column = 7
row = 6
cell = [None] * column * row
c = 0
for x in range (0, 7):
for y in range (0, 6):
cell[c] = Field(x,y, empty_cell)
pen = Label(mainframe, image = cell[c].Graphic)
pen.pack(side="right")
c = c + 1
mainframe.mainloop()
Field:
class Field:
def __init__(self, x, y, graphic):
self.Value = 0 #0 = empty, 1 = red, 2 = yellow
self.Graphic = graphic
self.X = x
self.Y = y
The code compiles properly but for no apparent reason it doesn't want to pack the PhotoImages (path is 100% valid) Tkinter shows just the empty window, without my graphics of an empty cell.
It worked once, but after I changed my code to a less hard-coded structure, out of mystery all my attempts to reproduce my earlier results are destined to fail.