Posted to tcl by stu at Mon Jan 03 10:21:53 GMT 2022view raw

  1. $ cat 4x4.gob
  2.  
  3. # Gub example
  4. # Turn a row of 16 buttons into a 4x4 grid
  5.  
  6. # 16 buttons in a row
  7. b b b b b b b b b b b b b b b b
  8.  
  9. # Push b4, b8 and b12 each down by 1 row
  10. !:-b4-12*4 +1
  11.  
  12. # Put b4, b8 and b12 in column 0
  13. !:|b4-12*4 0
  14.  
  15.  
  16.  
  17. $ gubtool 4x4.gob
  18.  
  19. grid [tk::button .b0] -row 0 -column 0
  20. grid [tk::button .b1] -row 0 -column 1
  21. grid [tk::button .b2] -row 0 -column 2
  22. grid [tk::button .b3] -row 0 -column 3
  23. grid [tk::button .b4] -row 1 -column 0
  24. grid [tk::button .b5] -row 1 -column 1
  25. grid [tk::button .b6] -row 1 -column 2
  26. grid [tk::button .b7] -row 1 -column 3
  27. grid [tk::button .b8] -row 2 -column 0
  28. grid [tk::button .b9] -row 2 -column 1
  29. grid [tk::button .b10] -row 2 -column 2
  30. grid [tk::button .b11] -row 2 -column 3
  31. grid [tk::button .b12] -row 3 -column 0
  32. grid [tk::button .b13] -row 3 -column 1
  33. grid [tk::button .b14] -row 3 -column 2
  34. grid [tk::button .b15] -row 3 -column 3
  35.