Posted to tcl by h1rag4mi at Wed Oct 30 09:40:15 GMT 2019view raw

  1. toplevel .t
  2. canvas .t.can
  3.  
  4. set point_size 10
  5. set zoom_out_factor 4
  6. set square_size [expr {256 / $zoom_out_factor}]
  7. set entry_width 80
  8. set entry_height 20
  9.  
  10. for {set y 0} {$y < $square_size} {incr y} {
  11. for {set x 0} {$x < $square_size} {incr x} {
  12. .t.can create rect [expr {$x * $point_size}] [expr {$y * $point_size}] [expr {($x + 1) * $point_size}] [expr {($y + 1) * $point_size}] -outline black -fill white
  13. }
  14. }
  15.  
  16. place .t.can -x 0 -y 0 -width [expr {$square_size * $point_size}] -height [expr {$square_size * $point_size}]
  17.  
  18. entry .t.l
  19. place .t.l -width $entry_width -x [expr {($square_size * $point_size - $entry_width) / 2}] -height $entry_height -y [expr {($square_size * $point_size - $entry_height) / 2}]
  20.  
  21. wm geometry .t "[expr {$square_size * $point_size}]x[expr {$square_size * $point_size}]"