Posted to tcl by aspect at Tue Dec 30 06:28:42 GMT 2014view raw

  1. package require tablelist
  2. namespace import tablelist::tablelist
  3. pack [tablelist .t -columns {0 foo 0 bar 0 baz 0 quuuux}]
  4. .t insert end {there once was a}
  5. .t insert end {who took a young}
  6. .t insert end {back of the barn}
  7. .t insert end {where he gave her}
  8.  
  9. bind .t <<TablelistSelect>> {select %W}
  10. bind .t.body <Button-1> {press %W}
  11.  
  12. proc select args {
  13. set cur [.t curselection]
  14. set val [.t get $cur]
  15. puts "select: $val"
  16. }
  17.  
  18. proc press args {
  19. lassign [winfo pointerxy .t] x y
  20. incr x [expr {-[winfo rootx .t]}]
  21. incr y [expr {-[winfo rooty .t]}]
  22. set cell [.t containingcell $x $y]
  23. set cur [lindex [split $cell ,] 0]
  24. set val [.t get $cur]
  25. puts "press: $val"
  26. }
  27.  
  28. if {!$tcl_interactive} {
  29. wm protocol . WM_DELETE_WINDOW exit
  30. vwait forever
  31. }
  32.