表示されたピザプレビューを任意のピザに変更できるようにコードを作成したいが、フレーズの仕方を理解できない。 今リストtkinterから画像を変更
from tkinter import *
from itertools import cycle
class buttonInitialize:
def __init__ (self,enabler):
leftframe=Frame(enabler)
leftframe.pack(side=LEFT)
rightframe=Frame(enabler)
rightframe.pack(side=RIGHT)
pizzaList=[]
pizzaList.append(PhotoImage(file="0.png").zoom(10))
pizzaList.append(PhotoImage(file="1.png").zoom(10))
self.otherButton=Button(leftframe,text="??",command=self.makePizza(1))
self.otherButton.pack()
self.printButton=Button(rightframe,image=pizzaList[0])
self.printButton.pack()
def makePizza(self,index):
self.printButton["image"]=self.pizzaList[index]
root=Tk()
c=buttonInitialize(root)
root.mainloop()
を(私は小さな画像を使用していますので、私は中にズームしています)、私はエラー
AttributeError: 'buttonInitialize' object has no attribute 'pizzaList'
はありがとうを取得しています!
'pizzaList'は' self.pizzaList'とは異なります。 – Lafexlos
私は両方の方法で試してみましたが、それでも同じエラーが発生します。私はイメージをどのように更新できるか知っていますか? –
回答を追加しました。希望、少しクリアする。 – Lafexlos