0
這是我正在嘗試顯示圖像的代碼。 那麼..首先應該有4張牌在屏幕上顯示;然而,只有2. 我不知道爲什麼會發生這種情況。我真的需要幫助。Tkinter顯示圖像
def __init__(self):
Frame.__init__(self)
self.master.title("Black Jack")
blackjack = Blackjack()
self.grid()
self._playerCardImage = PhotoImage(file=str(blackjack._player._cards[0].fileName))
self._playerCardLabel = Label(self, image = self._playerCardImage)
self._playerCardLabel.grid(row=0, column=0)
self._playerCardImage1 = PhotoImage(file=str(blackjack._player._cards[1].fileName))
self._playerCardLabel1 = Label(self, image = self._playerCardImage1)
self._playerCardLabel1.grid(row=0, column=1)
self._dealerCardImage = PhotoImage(file=str(blackjack._dealer._cards[0].fileName))
self._dealerCardImage = Label(self, image = self._dealerCardImage)
self._dealerCardImage.grid(row=0, column=2)
self._dealerCardImage1 = PhotoImage(file=str(blackjack._dealer._cards[1].fileName))
self._dealerCardImage1 = Label(self, image = self._dealerCardImage1)
self._dealerCardImage1.grid(row=0, column=3)
哦,天哪..我的壞。粗心的錯誤!謝謝! – user1047092 2011-12-28 05:38:32
@ user1047092沒問題:),還記得標記答案,它會讓人想要更多的幫助你。 – Serdalis 2011-12-28 05:39:52
我只是想了另一個問題。現在我正在嘗試顯示4張圖片。有沒有辦法顯示圖像,而不必像上面寫的重複代碼? – user1047092 2011-12-28 05:55:50