2016-03-22 5 views
0

TKのGui-Programmingのイベントについて何も見つかりません。ユーザーが "自動"ラジオボタンをクリックすると、他のラジオボタンは見えなくなります。ここTcl Tk hideユーザーがラジオボタンを押したときのオブジェクト

はコードです:ラジオボタンの変更にUIの応答を作る

set base .example1; 
toplevel $base 
wm geometry $base 1920x1080 

set frame_RadioBtnAuto [labelframe $base.frame_RadioBtnAuto \ 
     -text Search \ 
     -font {Calibri -12 bold} ]; 
place $frame_RadioBtnAuto -x 250 -y 135; 

set rbl [radiobutton $frame_RadioBtnAuto.rbl \ 
     -text "Automatic"\ 
     -variable "[namespace current]::optionVariable" -value one ]; 
#Standardwahl beim start 
$frame_RadioBtnAuto.rbl select 
pack $rbl -side left -anchor nw; 

set rb2 [radiobutton $frame_RadioBtnAuto.rb2 \ 
     -text "UserDef"\ 
     -variable "[namespace current]::optionVariable" -value two ]; 
pack $rb2 -side top -anchor nw; 

set frame_RadioBtnUserW1 [labelframe $base.frame_RadioBtnUserACC \ 
     -text Window\ 1\ 
     -font {Calibri -12 bold} ]; 
place $frame_RadioBtnUserACC -x 250 -y 170; 

set rba1 [radiobutton $frame_RadioBtnUserW1.rba1 \ 
     -text "Test1"\ 
     -variable "[namespace current]::optionVariable1" -value three ]; 
pack $rba1 -side top -anchor nw; 

set rba2 [radiobutton $frame_RadioBtnUserW1.rba2 \ 
     -text "Test2"\ 
     -variable "[namespace current]::optionVariable1" -value four ]; 
pack $rba2 -side top -anchor nw; 
+0

「自動」の選択を解除するにはどうすればよいですか? –

+0

@DonalFellowsユーザがランダムアレンジをしたくない場合。彼は手動オプションを選択することができます。 – ManInTheMiddle

答えて

1

はかなり簡単です。ラジオボタン-commandオプションまたはを使用してスクリプトを追加することができます。変数を変更するとUIの変更がトリガーされるように、変数に書き込みtraceを設定することができます。私はあなたが、後者は複雑なUIのようなもので、より信頼性があるでしょうと思う:

trace add variable [namespace current]::optionVariable write optionVariableWritten 
proc optionVariableWritten args { 
    variable optionVariable 
    if {$optionVariable eq "one"} { 
     # Conceal the UI here 
    } else { 
     # Reveal the UI here 
    } 
} 

あなたは正確に隠し、UIを表示する方法について慎重に検討する必要があります。複雑なUIを完全に隠すのではなく、ただ単に無効にするだけの方が、より良い(つまりあまり驚くべきではない)体験をすることがあります。

関連する問題