更改单选按钮的标签
我正在 Tkinter 中创建一个菜单。创建菜单后,我希望能够更改单选按钮的标签。类似于 .configure 方法。我该怎么办?
我希望能够将单选按钮文本从“Hello”更改为“Hello!”。
片段:
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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要修改标签,请使用
entryconfig
方法。您为该方法提供一个索引,该索引可以是项目的整数位置,也可以是标签本身。例如: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: