tkinerを使用している時に、よく出てくる
StringVar() や intVar()について、
定義されていませんとなります。
⇒以前の質問で、自己解決しましたので、編集して質問させてください。
連続で何度もラジオボタンをon、offにはどうしたらいいですか。
下記コードだと、一回チェックしたら2回目は変わりません。
状態の変更
# 状態の変更 def change_state(): # チェックされているラジオボタンを取得 checked = v.get() if ( checked == 1 ): # radio1がチェックされていたら radio2.configure( state = "disabled" ) radio3.configure( state = "disabled" ) elif ( checked == 2 ): # radio2がチェックされていたら radio1.configure( state = "disabled" ) radio3.configure( state = "disabled" ) elif ( checked == 3 ): # radio3がチェックされていたら radio1.configure( state = "disabled" ) radio2.configure( state = "disabled" ) else: print("error") # ラジオボタンのグループ v = tkinter.IntVar() v.set(0) # ラジオボタン radio1 = tkinter.Radiobutton(text = u"項目1", variable = v, value = 1, command = change_state) radio1.place(x=50, y=160) radio2 = tkinter.Radiobutton(text = u"項目2", variable = v, value = 2, command = change_state) radio2.place(x=150, y=160) radio3 = tkinter.Radiobutton(text = u"項目3", variable = v, value = 3, command = change_state) radio3.place(x=250, y=160)
intVarの定義はどのようにしたら良いのでしょうか。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/14 02:52