You are already doing what you need. Your sample code sets self.diceListto some value. You can use it directly anywhere in your code self.diceList.
, , . , , "Dice One" "One", "Dice 1"? , , . , . , , , .
, chooseDice, . :
self.button1.configure(command=lambda btn=self.button1: self.chooseDice(btn, 1))
chooseDice: ( ) ( , )
, . :
from Tkinter import *
class GraphicsInterface:
def __init__(self):
self.window = Tk()
self.window.geometry("720x500")
self.clicked=[]
self.buttons = []
for n in range(1, 3):
btn = Button(text="Button " + str(n))
btn.configure(command=lambda btn=btn, n=n: self.chooseDice(btn, n))
btn.pack()
self.buttons.append(btn)
btn = Button(text="Go!", command=self.go)
btn.pack()
self.window.mainloop()
def go(self):
print "buttons:", self.clicked
self.reset()
def reset(self):
'''Reset all the buttons'''
self.clicked = []
for button in self.buttons:
button.configure(state="normal")
def chooseDice(self, widget, number):
self.clicked.append(number)
widget.configure(state="disabled")
app = GraphicsInterface()
, :
place, GUI, , , .. pack grid . , . , . , , , .
, , , , ( ?), ( N N) ( 1 N). , , .