I create a Button, and set its callback, but how can I get the attribute of the button like fg
?
from Tkinter import *
def callback(self):
tkMessageBox.showinfo("button", color)
top = Tk()
frame = Frame(top)
frame.pack()
greenbutton = Button(frame, text="Brown", fg="brown", command=callback)
greenbutton.pack( side = RIGHT )
bluebutton = Button(frame, text="Blue", fg="blue", command=callback)
bluebutton.pack( side = LEFT )
top.mainloop()
I just want when I click the button blue and it will tell me it is blue.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…