"rond"という関数をアクティブにするはずのチェックボタンを作ろうとしましたが、うまくいきません...どうしましたか?tkinter:checkbuttonが機能していない
from tkinter import*
def rond():
if okok.get()==1:
print("ok")
okok = BooleanVar()
okok.set(0)
root = Tk()
can = Canvas(root, width=200, height=150, bg="light yellow")
can.bind("<ButtonPress-1>", variable=okok, onvalue=1, offvalue=0, command=rond)
can.pack(side="top")
root.mainloop()
それは、これを実行した後は、表示されます:
Traceback (most recent call last): File "/PycharmProjects/untitled/testtest.py", line 7, in <module> okok = BooleanVar() File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/tkinter/__init__. py", line 389, in __init__ Variable.__init__(self, master, value, name) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/tkinter/__init__.py", line 233, in __init__ self._root = master._root() AttributeError: 'NoneType' object has no attribute '_root'