小编Pau*_*jak的帖子

如何使用tkinter更改按钮颜色

我一直收到以下错误:AttributeError:'NoneType'对象没有属性'configure'

# create color button
self.button = Button(self,
                     text = "Click Me",
                     command = self.color_change,
                     bg = "blue"
                    ).grid(row = 2, column = 2, sticky = W)

def color_change(self):
    """Changes the button's color"""

    self.button.configure(bg = "red")
Run Code Online (Sandbox Code Playgroud)

python tkinter button

10
推荐指数
1
解决办法
8万
查看次数

标签 统计

button ×1

python ×1

tkinter ×1