问题
I'm creating a menu in Tkinter. After my menu has been created I'd like to be able to change the label of the radiobutton. Something similar to the .configure method. How do I go about this?
I want to be able to change the radiobuttons text from "Hello" to "Hello!".
Snippet:
self.B3Me = Tkinter.Menu(self, tearoff=0,
activebackground='grey15',
activeforeground='grey95')
self.B3MeVar = Tkinter.StringVar()
self.B3Me.add_radiobutton(label='Hello', variable=self.B3MeVar,
command=self.B3_menu_beh)
回答1:
To modify the label use the entryconfig
method. You give this method an index which can be the integer position of the item, or the label itself. For example:
self.B3Me.entryconfig("Hello", label="Goodbye!")
来源:https://stackoverflow.com/questions/4482055/change-the-label-of-the-radiobutton