i'm making a monopoly game, & i am trying to draw image on canvas, but it will only work if not in function:
def make_image(root, location, canvas):
photo = PhotoImage(file = root)
canvas.create_image(location["X"],location["Y"], image = photo, anchor = "nw")
class something():
def start(self, controller):
self.controller = controller
#photo = PhotoImage(file = "googolopoly.png")
#self.canvas.create_image(0,0, image = photo, anchor = "nw")
make_image("googolopoly.png", {"X":0,"Y":0}, self.canvas)
make_text(self.canvas, "MONOPOLY!!!!", {"X":1050,"Y":20})
make_button(self.main_tk, self.canvas, "roll dice", lambda: self.roll_dice(), {"X":1100, "Y":50}, 100)
for i in range(controller.player_number):
self.players.append(make_text(self.canvas, str(i+1), {"X":902+i*10, "Y":946}))
self.main_tk.mainloop()
currently it won't draw a picture, but if i get down the comments it will work (no function) it also happens after main loop, when i want to draw players
i really need it as a function. what to do? if you need i can put some more code