现在,我正在编写一个代码来在按下按钮时更改所有按钮和标签的颜色。但我每次都会遇到不同的错误。
windows = []
global windows
buttons = []
global buttons
labels = []
global labels
一堆代码……然后……
def flavor(c):
if c != 0:
c = 0
for w in windows:
w.config(bg = 'black')
for l in labels:
l.config(bg = 'black', fg = 'white')
for b in buttons:
b.config(bg = 'black', fg = 'white')
elif c != 1:
c = 1
for w in windows:
w.config(bg = 'dark green')
for l in labels:
l.config(bg = 'dark green', fg = 'light green')
for b in buttons:
b.config(bg = 'dark green', fg = 'light green')
我几乎一直和大部分时间都遇到的错误是:
Traceback (most recent call last):
File "C:\Users\Ahmet\Desktop\An interesting experiment\FOBBY.py", line 153, in <module>
main()
File "C:\Users\Ahmet\Desktop\An interesting experiment\FOBBY.py", line 118, in main
thememenu.add_command(label="Plain",command = flavor(0))
File "C:\Users\Ahmet\Desktop\An interesting experiment\FOBBY.py", line 79, in flavor
l.config(bg = 'dark green', fg = 'light green')
AttributeError: 'NoneType' object has no attribute 'config'
感谢帮助