home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / Linux / Pratique / Tcltk / tkcalc5.tcl < prev    next >
Text File  |  1997-09-10  |  2KB  |  85 lines

  1.  
  2. ######################################
  3. # tkcalc5.tcl                        #
  4. ######################################
  5. # Tkcalculator v0.5                  #
  6. ######################################
  7.  
  8. #################################
  9. # Creer l'interface utilisateur #
  10. #################################
  11.  
  12. # creation d'une ligne de boutons
  13.  
  14. proc MakeRow { list } {
  15.     global NbListRow
  16.  
  17.     incr NbListRow
  18.  
  19.     frame .framerow${NbListRow}
  20.  
  21.     pack .framerow${NbListRow} -side top -fill x -expand true
  22.  
  23.     for { set i 0 } { $i < [llength $list] } { incr i } {
  24.     button .btn${i}row${NbListRow} -command "ButtonCommand $i $NbListRow" -text [ lindex $list $i]  -width 3 -height 1
  25.  
  26.     pack .btn${i}row${NbListRow} -side left -in  .framerow${NbListRow}
  27.     }
  28. }
  29.  
  30. # cette procedure est appelΘe lorsque l'on clique sur un bouton
  31. # elle affiche le numero du bouton dans la ligne (0 = premier bouton)
  32. # et le numero de ligne (entre 1 et le nombre de lignes)
  33.  
  34. proc ButtonCommand { i row } {
  35.     puts "You choosed the $i-th button of row \#$row"
  36. }
  37.  
  38. # zone d'affichage de texte
  39.  
  40. text .viewtxt -height 8 -width 32 -state disabled
  41.  
  42. pack .viewtxt -side top
  43.  
  44. # configuration des boutons
  45.  
  46. set ListRow1 { 7 8 9 \/ "CE" }
  47. set ListRow2 { 4 5 6 \* }
  48. set ListRow3 { 1 2 3 \- }
  49. set ListRow4 { 0 "+/-" \. \+ \= }
  50.  
  51. # pour l'instant, aucune ligne initialisΘe
  52.  
  53. set NbListRow 0
  54.  
  55. # crΘer les lignes de boutons
  56.  
  57. MakeRow $ListRow1
  58. MakeRow $ListRow2
  59. MakeRow $ListRow3
  60. MakeRow $ListRow4
  61.  
  62. # boutons de commande : about et quit
  63.  
  64. frame .comframe
  65.  
  66. button .comframe.aboutbtn -text "About ..." -command AboutCommand
  67. button .comframe.quitbtn -text "Quit" -command exit
  68.  
  69. pack .comframe -side top
  70. pack .comframe.aboutbtn -side left
  71. pack .comframe.quitbtn -side left
  72.           
  73. # interpreter dialogs.tcl au niveau global
  74.  
  75. uplevel 0 [list source dialogs.tcl]
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.