私のチェックボタンに何をしても、変数を設定していないようです。 はここで関与しているコードの一部です:tkinter checkbuttonが変数を設定していない
class Window:
def __init__(self):
self.manualb = 0 #to set the default value to 0
def setscreen(self):
#screen and other buttons and stuff set here but thats all working fine
manual = tkr.Checkbutton(master=self.root, variable=self.manualb, command=self.setMan, onvalue=0, offvalue=1) #tried with and without onvalue/offvalue, made no difference
manual.grid(row=1, column=6)
def setMan(self):
print(self.manualb)
#does some other unrelated stuff
それはちょうど0アム私が何か間違ったことを印刷し続けますか?マニュアル以外に何もしません。
こんにちは@Jebby。誰かがなぜ自分のプログラムで何かをしている/してはいけない/してはいけないのかを説明するのは良い考えです。これにより、あなたが説明したアイデアや言語を新入者が簡単に理解できるようになります。 –
ありがとう@EthanField私は自分の記事を編集して、IntVarの情報を少し追加しました。 – Jebby