その1
# ボタンを押した時の動作 proc push_button_A {} { global buffer set buffer "ボタンAを押しましたね" pack forget .b_A pack forget .b_B pack forget .b_C pack forget .b_D pack forget .b_E pack forget .b_F pack .next } # ボタンを押した時の動作 proc push_button_B {} { global buffer set buffer "ボタンBを押しましたね" pack forget .b_A pack forget .b_B pack forget .b_C pack forget .b_D pack forget .b_E pack forget .b_F pack .next } # ボタンを押した時の動作 proc push_button_C {} { global buffer set buffer "ボタンCを押しましたね" pack forget .b_A pack forget .b_B pack forget .b_C pack forget .b_D pack forget .b_E pack forget .b_F pack .next } # ボタンを押した時の動作 proc push_button_D {} { global buffer set buffer "ボタンDを押しましたね" pack forget .b_A pack forget .b_B pack forget .b_C pack forget .b_D pack forget .b_E pack forget .b_F pack .next } # ボタンを押した時の動作 proc push_button_E {} { global buffer set buffer "ボタンEを押しましたね" pack forget .b_A pack forget .b_B pack forget .b_C pack forget .b_D pack forget .b_E pack forget .b_F pack .next } # ボタンを押した時の動作 proc push_button_F {} { global buffer set buffer "ボタンFを押しましたね" pack forget .b_A pack forget .b_B pack forget .b_C pack forget .b_D pack forget .b_E pack forget .b_F pack .next } # ボタンを押した時の動作 proc push_button_NEXT {} { global buffer set buffer "ボタンを押して下さい" pack forget .next # オプションの追加 pack .b_A pack .b_B pack .b_C pack .b_D pack .b_E pack .b_F } button .b_A -text "button A" -command "push_button_A" button .b_B -text "button B" -command "push_button_B" button .b_C -text "button C" -command "push_button_C" button .b_D -text "button D" -command "push_button_D" button .b_E -text "button E" -command "push_button_E" button .b_F -text "button F" -command "push_button_F" button .next -text "NEXT" -command "push_button_NEXT" # ラベルの作成 label .l -textvariable buffer pack .l global buffer set buffer "ボタンを押して下さい" # オプションの追加 pack .b_A pack .b_B pack .b_C pack .b_D pack .b_E pack .b_Fその2
global button_num set button_num 0 global buffer set buffer "tmp" # ボタンを押した時の動作 proc push_button_A {} { global buffer set buffer "ボタンAを押しましたね" global button_num if {$button_num == 6} then {del_button_6} elseif {$button_num == 2} then {del_button_2} pack .next } # ボタンを押した時の動作 proc push_button_B {} { global buffer set buffer "ボタンBを押しましたね" global button_num if {$button_num == 6} then {del_button_6} elseif {$button_num == 2} then {del_button_2} pack .next } # ボタンを押した時の動作 proc push_button_C {} { global buffer set buffer "ボタンCを押しましたね" del_button_6 pack .next } # ボタンを押した時の動作 proc push_button_D {} { global buffer set buffer "ボタンDを押しましたね" del_button_6 pack .next } # ボタンを押した時の動作 proc push_button_E {} { global buffer set buffer "ボタンEを押しましたね" del_button_6 pack .next } # ボタンを押した時の動作 proc push_button_F {} { global buffer set buffer "ボタンFを押しましたね" del_button_6 pack .next } proc del_button_2 {} { pack forget .b_A pack forget .b_B } proc del_button_6 {} { pack forget .b_A pack forget .b_B pack forget .b_C pack forget .b_D pack forget .b_E pack forget .b_F } proc set_button_2 {} { pack .b_A pack .b_B } proc set_button_6 {} { pack .b_A pack .b_B pack .b_C pack .b_D pack .b_E pack .b_F } # ボタンを押した時の動作 proc push_button_NEXT {} { global buffer set buffer "選択肢は?" pack forget .next # オプションの追加 pack .b_few pack .b_many } global button_num # ボタンを押した時の動作 proc push_button_few {} { global buffer set buffer "ボタンを押して下さい" pack forget .b_few pack forget .b_many # オプションの追加 set_button_2 global button_num set button_num 2 } # ボタンを押した時の動作 proc push_button_many {} { global buffer set buffer "ボタンを押して下さい" pack forget .b_few pack forget .b_many # オプションの追加 set_button_6 global button_num set button_num 6 } button .b_few -text "少ない" -command "push_button_few" button .b_many -text "多い" -command "push_button_many" button .b_A -text "button A" -command "push_button_A" button .b_B -text "button B" -command "push_button_B" button .b_C -text "button C" -command "push_button_C" button .b_D -text "button D" -command "push_button_D" button .b_E -text "button E" -command "push_button_E" button .b_F -text "button F" -command "push_button_F" button .next -text "NEXT" -command "push_button_NEXT" # ラベルの作成 label .l -textvariable buffer pack .l global buffer set buffer "選択肢は?" pack forget .next # オプションの追加 pack .b_few pack .b_many
タグ
コメントをかく