change the label of the radiobutton

半世苍凉 提交于 2020-05-01 05:49:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!