更改单选按钮的标签

发布于 2024-10-08 04:12:55 字数 498 浏览 0 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩于岁月 2024-10-15 04:12:55

要修改标签,请使用 entryconfig 方法。您为该方法提供一个索引,该索引可以是项目的整数位置,也可以是标签本身。例如:

self.B3Me.entryconfig("Hello", label="Goodbye!")

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!")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文