russian on-screen keyboard

aleksanteri, 20th of August 2008: As my russian courses started last week I felt that a little program that showed an on-screen russian keyboard would be pretty handy, so I went and made one:

 package require Tk
 package require tile
 
 ttk::frame .mf
 ttk::frame .mf.maj
 ttk::frame .mf.min
 ttk::entry .mf.out
 
 ttk::label .mf.maj_l -text "Majuscule"
 ttk::label .mf.min_l -text "Miniscule"
 
 grid .mf -sticky nsew
 grid .mf.maj_l -row 0 -column 0 -padx 5 -pady 5
 grid .mf.min_l -row 0 -column 1 -padx 5 -pady 5
 grid .mf.maj -sticky nsew -row 1 -column 0 -padx 5 -pady 5
 grid .mf.min -sticky nsew -row 1 -column 1 -padx 5 -pady 5
 grid .mf.out -sticky nsew -row 2 -column 0 -columnspan 2 -padx 5 -pady 5
 
 wm title . {Russian on-screen keyboard}
 wm attributes . -topmost 1
 wm resizable . 0 0
 
 set i 0
 for {set x 1040} {$x <= 1071} {incr x} {
         set c [format %c $x]
         ttk::button .mf.maj.$x -text $c -width 2 -command [list insert $x]
         grid .mf.maj.$x -row [expr {$i / 11}] -column [expr {$i % 11}]
         
         set y [expr {$x + 32}]
         set c [format %c $y]
         ttk::button .mf.min.$y -text $c -width 2 -command [list insert $y]
         grid .mf.min.$y -row [expr {$i / 11}] -column [expr {$i % 11}]
 
         if {$x == 1045} {
                 set x 1024
         }
 
         if {$x == 1025} {
                 set x 1045
         }
         incr i
 }
 
 proc insert {code} {
         .mf.out insert end [format %c $code]
 }