我正在做一個大富翁遊戲,&我試圖在畫布上繪製圖像繪製Tkinter的圖像,但它只會在功能上,如果不工作:不能在功能
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()
目前
它贏得」 t畫一張圖片,但如果我記下它的意見,它將工作(沒有功能) 它也發生在主循環後,當我想繪製球員
我真的需要它作爲一個函數。該怎麼辦?如果你需要我可以把更多的代碼
確定要在帆布上?它會更容易做一個標籤 – Veltro
其實我不知道標籤是什麼。我寫的是我們在課堂上教過的。如果你說有一個更簡單的解決方案,請添加一個答案。 (但我用帆布的一切) –
你可以請張貼另一個問題如何做到這一點與標籤? 標籤是窗口上的文本元素 – Veltro