更改单选按钮的标签

2024-10-01 17:23:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在Tkinter中创建一个菜单。创建菜单后,我希望能够更改radiobutton的标签。类似于.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)

Tags: 方法文本self内容hellotkinterconfigure菜单
1条回答
网友
1楼 · 发布于 2024-10-01 17:23:06

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

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

相关问题 更多 >

    热门问题