#! /Apps/usr-local/tcl_tk-8.4.11/bin/wish84.exe -f ## 一行目、何の意味もないですけど‥ ## ---------------------------------------------------------- ## Tcl/Tk を使った、簡単な「終了オプション」的なもの ## version 2011.02 ## ---------------------------------------------------------- ## シャットダウンに使うコマンドのパスを以下に: set Comm {/Apps/usr-local/bin/shutdown_____/shutdown.exe} # オプション -s で suspend, -p で power off, -r で reboot することを想定 ## また standby.gif, turnoff.gif, restart.gif という3つのファイルを ## 別途用意してね。iconfinder あたりで stand by などで検索して、 ## 自分で気に入ったものを入手してペイント等でちょっとサイズ調整、 ## GIF形式で保存、という手順で容易に用意できるはず。 proc my_standby { } { global Comm exec $Comm -s exit; } proc my_turnoff { } { global Comm exec $Comm -p exit; } proc my_restart { } { global Comm exec $Comm -r exit; } frame .head -bg blue label .head.title -text "コンピュータの電源を切る" -bg blue -fg white pack .head.title -side left -padx 5 -pady 5 frame .foot -bg blue button .foot.b -command { exit; } -text "キャンセル" -border 0 -overrelief sunken pack .foot.b -side right pack .head -fill x pack .foot -fill x -side bottom -ipadx 5 -ipady 5 wm title . "My Shutdown" frame .fs -bg #7777EE frame .ft -bg #7777EE frame .fr -bg #7777EE image create photo ims -file "standby.gif" image create photo imt -file "turnoff.gif" image create photo imr -file "restart.gif" button .fs.bsi -command { my_standby; } -image ims -border 0 -bg #7777EE -overrelief sunken button .ft.bti -command { my_turnoff; } -image imt -border 0 -bg #7777EE -overrelief sunken button .fr.bri -command { my_restart; } -image imr -border 0 -bg #7777EE -overrelief sunken button .fs.bst -command { my_standby; } -text "スタンバイ" -border 0 -fg white -bg #7777EE -overrelief sunken button .ft.btt -command { my_turnoff; } -text "電源を切る" -border 0 -fg white -bg #7777EE -overrelief sunken button .fr.brt -command { my_restart; } -text "再起動" -border 0 -fg white -bg #7777EE -overrelief sunken pack .fs.bsi -fill x -padx 10 -pady 5 pack .fs.bst -fill x -padx 10 -pady 5 pack .fs -side left pack .ft.bti -fill x -padx 10 -pady 5 pack .ft.btt -fill x -padx 10 -pady 5 pack .ft -side left pack .fr.bri -fill x -padx 10 -pady 5 pack .fr.brt -fill x -padx 10 -pady 5 pack .fr