に私はtext
ウィジェットをcheckbutton
を置くが、毎回私は、機能checkbutton_value
が呼び出されるcheckbutton
選択して、それがコードの0PythonのTkinterののチェックボタンの値は常に同じ0
パートがある返されます
def callback():
file_name=askopenfilename()
column_1rowname,column_name=draw_column(file_name)
root = Tk()
root.resizable(width=False,height=False)
root.wm_title("Column")
S = Scrollbar(root,orient="vertical")
text=Text(root,width=15,height=10,yscrollcommand=S.set)
S.config(command=text.yview)
S.pack(side="right",fill="y")
text.pack(side="left",fill="both",expand=True)
#check the value of the checkbutton
def checkbutton_value():
if(var.get()):
print 1
else:
print 0
var=BooleanVar()
chk = Checkbutton(root, text=column_1rowname[1], variable=var, command=checkbutton_value)
text.window_create("end", window=chk)
text.config(state=DISABLED)
errmsg='Error!'
Button(text='File Open',command=callback).pack(fill=X)
mainloop()
お読みくださいhttp://www.stackoverflow.com/help/mcve –
ありがとう。私はそれを変更しました。 –
これは本当にあなたの本当のコードですか?コールバックの中に 'Tk'のインスタンスを作成するのは間違いなく問題です。 –