Posted to tcl by aspect at Fri Nov 18 03:29:35 GMT 2016view raw

  1. package require Tk
  2.  
  3. pack [ttk::treeview .tree] -expand yes -fill both
  4. pack [ttk::frame .buttons] -expand yes -fill both
  5. grid [ttk::button .buttons.show -text "Show Errors" -command show_errors] \
  6. [ttk::button .buttons.hide -text "Hide Errors" -command hide_errors]
  7.  
  8. # error takes priority because it is created first
  9. .tree tag configure error ;# even without any options
  10. .tree tag configure funny -background blue
  11.  
  12. set br [.tree insert {} end -text "Funny" -tags {funny}]
  13. set br [.tree insert {} end -text "Error" -tags {error}]
  14. set rb [.tree insert {} end -text "Funny Error" -tags {funny error}]
  15. set rb [.tree insert {} end -text "Not Even Funny"]
  16.  
  17.  
  18. proc show_errors {} {
  19. .tree tag configure error -background red
  20. .buttons.show state disabled
  21. .buttons.hide state !disabled
  22. }
  23.  
  24. proc hide_errors {} {
  25. .tree tag configure error -background ""
  26. .buttons.show state !disabled
  27. .buttons.hide state disabled
  28. }
  29.  
  30. show_errors ;# initialise tag options and buttons
  31.