python - 如何禁用 Pmw.ButtonBox 中的特定按钮?

标签 python tkinter

我添加了一个按钮:

def addButtons(self):
    self.buttonBox = Pmw.ButtonBox(self.dataFrame,
            labelpos = 'nw',
            label_text = '',
            frame_borderwidth = 1,
            frame_relief = 'groove')
    self.buttonBox.pack()
    self.buttonBox.place(relx=.75, rely=.750, anchor=W)

    # Add some buttons to the ButtonBox.
    self.buttonBox.add('Login', command = self.login)

    # Set the default button (the one executed when <Return> is hit).
    self.buttonBox.setdefault('Login')
    self.dataFrame.bind('<Return>', self._processReturnKey)
    self.dataFrame.focus_set()

现在,我想在用户按下登录按钮时禁用它。我怎样才能做到这一点?我找到了简单按钮的答案,但该按钮位于按钮框中。

最佳答案

根据pmw.ButtonBox documentationadd 方法返回对所创建按钮的引用。因此,只需保存它返回的引用,然后像配置任何其他按钮一样配置该按钮。

关于python - 如何禁用 Pmw.ButtonBox 中的特定按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7000081/

相关文章:

python - 使用 Python 3 和 tkinter 创建一个可以打开/关闭相机图像的 GUI

python - 终端问题-cd导航返回“不是目录”

python - 新选择后将标记保留在下拉菜单 tkinter 中

python-3.x - Ubuntu Tkinter 安装不包括 PyImagingPhoto

python - Tkinter 复选框问题

python - 更改 tkinter 菜单栏的颜色

python - 在 Pandas 数据框中加速 iloc 解决方案

python - Scikit 学习管道类型错误 : zip argument #2 must support iteration

python - 未绑定(bind)本地错误 : local variable 'y' referenced before assignment

python - 有哪些方法可以为 Flask 应用做种?