📄 xsc.in
字号:
set num_var_params 0 } catch { destroy .top } frame .top frame .top.mbar -relief raised -bd 2 menubutton .top.mbar.help -text [ T_ "Help" ] -underline 0 -menu .top.mbar.help.menu menu .top.mbar.help.menu .top.mbar.help.menu add command -label [ T_ "What now ?" ] -command what_now -underline 0 pack .top.mbar.help -side right pack .top.mbar -in .top -side top -fill x set num_rows [ expr ($num_fix_params + $num_var_params + 1) / 2 ] frame .top.params frame .top.params.lframe frame .top.params.rframe set itemno 0 for { set i 1 } { $i <= $num_fix_params } { incr i } { incr itemno if { $itemno <= $num_rows } { set pw .top.params.lframe } else { set pw .top.params.rframe } frame $pw.line$i label $pw.line$i.label -width $textwidth -text [ T_ $prompts($i) ] case $types($i) in { s { entry $pw.line$i.value -width $entrywidth -textvariable values($i) } b { checkbutton $pw.line$i.value -onvalue 1 -offvalue 0 -variable values($i) } } if { $i == $num_var_sp_idx } { bind $pw.line$i.value <Return> show_win } bind $pw.line$i.value <F1> "help_on $i" bind $pw.line$i.value <F2> "help_on $i" bind $pw.line$i.value <Escape> "help_on $i" pack $pw.line$i.label $pw.line$i.value -side left -fill x pack $pw.line$i -in $pw -side top -anchor w -fill x -expand 1 } if { $num_var_params > 0 } { if { $num_var_params > 1 } { for { set i 0 } { $i < $num_var_params } { incr i } { set l [ expr $num_fix_params + $i + 1 ] if { ! [ info exists values($l) ] } { set values($l) "" } incr itemno if { $itemno <= $num_rows } { set pw .top.params.lframe } else { set pw .top.params.rframe } frame $pw.line$l set prompt [ replSubstring [ T_ $prompts($var_param_idx) ] "#num#" [expr $i + 1] ] label $pw.line$l.label -width $textwidth -text $prompt case $types($var_param_idx) in { s { entry $pw.line$l.value -width $entrywidth -textvariable values($l) } b { checkbutton $pw.line$l.value -onvalue 1 -offvalue 0 -variable values($l) } } bind $pw.line$l.value <F1> "help_on $l" bind $pw.line$l.value <F2> "help_on $l" bind $pw.line$l.value <Escape> "help_on $l" pack $pw.line$l.label $pw.line$l.value -side left -fill x pack $pw.line$l -in $pw -side top -anchor w -fill x -expand 1 } } else { incr itemno if { $itemno <= $num_rows } { set pw .top.params.lframe } else { set pw .top.params.rframe } frame $pw.line$fix_param_idx label $pw.line$fix_param_idx.label -width $textwidth -text [ T_ $prompts($fix_param_idx) ] case $types($fix_param_idx) in { s { entry $pw.line$fix_param_idx.value -width $entrywidth -textvariable values($fix_param_idx) } b { checkbutton $pw.line$fix_param_idx.value -onvalue 1 -offvalue 0 -variable values($fix_param_idx) } } bind $pw.line$fix_param_idx.value <F1> "help_on $fix_param_idx" bind $pw.line$fix_param_idx.value <F2> "help_on $fix_param_idx" bind $pw.line$fix_param_idx.value <Escape> "help_on $fix_param_idx" pack $pw.line$fix_param_idx.label $pw.line$fix_param_idx.value -side left -fill x pack $pw.line$fix_param_idx -in $pw -side top -anchor w -fill x -expand 1 } } pack .top.params.lframe .top.params.rframe -side left -expand 1 -fill y pack .top.params -in .top -side top -expand 1 frame .top.cmds button .top.cmds.save -text [ T_ "Save" ] -command save_settings button .top.cmds.cancel -text [ T_ "Exit" ] -command "exit 0" pack .top.cmds.save .top.cmds.cancel -side left pack .top.cmds -in .top -side top pack .top}proc save_settings { } { global names values comments configfile num_var_sp_idx global fix_param_idx var_param_idx num_fix_params num_var_params set errfl [ catch { set fp [ open $configfile w ] } ] if { $errfl } { tk_dialog .error [ T_ "Error" ] [ format [ T_ "Error: Cannot open file `%s' for writing." $configfile ] ] -1 [ T_ "Ok" ] return } for { set i 1 } { $i <= $num_fix_params } { incr i } { set comment "# " append comment [ replSubstring [ T_ $comments($i) ] "\n" "\n# " ] puts $fp $comment if { [ string length [ string trim $values($i) ] ] == 0 } { puts $fp "#$names($i):\t\t$values($i)" } else { puts $fp "$names($i):\t\t$values($i)" } } if { $num_var_params > 0 } { if { $num_var_params > 1 } { for { set i 0 } { $i < $num_var_params } { incr i } { set comment "# " append comment [ replSubstring [ T_ $comments($var_param_idx) ] "\n" "\n# " ] set comment [ replSubstring $comment "#num#" [ expr $i + 1 ] ] set l [ expr $num_fix_params + 1 + $i ] puts $fp $comment set name [ replSubstring $names($var_param_idx) "#num#" [ expr $i + 1 ] ] if { [ string length [ string trim $values($l) ] ] == 0 } { puts $fp "#${name}:\t\t$values($l)" } else { puts $fp "${name}:\t\t$values($l)" } } } else { set comment "# " append comment [ replSubstring [ T_ $comments($fix_param_idx) ] "\n" "\n# " ] puts $fp $comment if { [ string length [ string trim $values($fix_param_idx) ] ] == 0 } { puts $fp "#$names($fix_param_idx):\t\t$values($fix_param_idx)" } else { puts $fp "$names($fix_param_idx):\t\t$values($fix_param_idx)" } } } close $fp}proc help_on { idx } { global helps num_fix_params var_param_idx values global fix_param_idx num_var_sp_idx num_var_params if { $idx > $num_fix_params } { if { $num_var_params > 1 } { set num [ expr $idx - $var_param_idx + 2 ] set msg [ replSubstring [ T_ $helps($var_param_idx) ] "#num#" $num ] } else { set msg [ T_ $helps($fix_param_idx) ] } } else { set msg [ T_ $helps($idx) ] } set msg [ replSubstring $msg "\n" " " ] set msg [ replSubstring $msg "\\" "\n" ] GGUI_genericDialog .help [ T_ "Help" ] $msg "" -1 [ T_ "Ok" ]}show_win# Workaround for strange wish behaviour: window to smallupdate idletasksset h [ winfo height .top.cmds.save ]if { $h < 20 } { show_win}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -