所以我试图重新创建这个:
self.button1 = tkinter.Button(self.user_frame, image = self.image1, state = 'disabled', command = self.press1)
self.button1.pack(side = 'left')
self.buttonList.append(self.button1)
self.button2 = tkinter.Button(self.user_frame, image = self.image2, state = 'disabled', command = self.press2)
self.button2.pack(side = 'left')
self.buttonList.append(self.button2)
self.button3 = tkinter.Button(self.user_frame, image = self.image3, state = 'disabled', command = self.press3)
self.button3.pack(side = 'left')
self.buttonList.append(self.button3)
等..直到self.button10。
有了这个:
for x in range [1, 11]:
self.button(x)=tkinter.Button(self.user_frame, image=self.image(x), state = 'disabled', command = self.press(x))
self.button(x).pack(side='left')
self.buttonList.append(self.button(x))
我得到语法错误:无法分配给函数调用。我知道这与我如何命名按钮有关,但我无法弄清楚。有小费吗?