grassabout.tcl 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. ##################### some scroll widgets
  2. proc scrollx_widget {widget path args} {
  3. frame $path
  4. eval $widget $path.$widget $args {-xscrollcommand [list $path.xscroll set]}
  5. scrollbar $path.xscroll -width 10 -orient horizontal \
  6. -command [list $path.$widget xview]
  7. grid $path.$widget -sticky news
  8. grid $path.xscroll -sticky news
  9. grid rowconfigure $path 0 -weight 1
  10. grid columnconfigure $path 0 -weight 1
  11. return $path.$widget
  12. }
  13. proc scrolly_widget {widget path args} {
  14. frame $path
  15. eval $widget $path.$widget $args {-yscrollcommand [list $path.yscroll set]}
  16. scrollbar $path.yscroll -width 10 -orient vertical \
  17. -command [list $path.$widget yview]
  18. grid $path.$widget $path.yscroll -sticky news
  19. grid rowconfigure $path 0 -weight 1
  20. grid columnconfigure $path 0 -weight 1
  21. return $path.$widget
  22. }
  23. proc scrollxy_widget {widget path args} {
  24. frame $path
  25. eval $widget $path.$widget $args { \
  26. -xscrollcommand [list $path.xscroll set] \
  27. -yscrollcommand [list $path.yscroll set] \
  28. }
  29. scrollbar $path.xscroll -width 10 -orient horizontal \
  30. -command [list $path.$widget xview]
  31. scrollbar $path.yscroll -width 10 -orient vertical \
  32. -command [list $path.$widget yview]
  33. grid $path.$widget $path.yscroll -sticky news
  34. grid $path.xscroll -sticky news
  35. grid rowconfigure $path 0 -weight 1
  36. grid columnconfigure $path 0 -weight 1
  37. return $path.$widget
  38. }
  39. proc children {path} {
  40. set list {}
  41. foreach child [winfo children $path] {
  42. eval lappend list $child [children $child]
  43. }
  44. return $list
  45. }
  46. proc setfont {path font} {
  47. if {[llength $font] > 0} {
  48. foreach child [children $path] {
  49. catch {$child configure -font $font}
  50. }
  51. }
  52. }
  53. #########################################################################
  54. #write text in window with close button
  55. set help_font [font create -family Times -size 10]
  56. proc helptext {title textopts tagopts message} {
  57. global help_font
  58. toplevel .helptext
  59. wm title .helptext $title
  60. bind .helptext <Return> {destroy .helptext}
  61. button .helptext.ok -text OK -command "destroy .helptext"
  62. pack .helptext.ok -side bottom
  63. eval scrollxy_widget text .helptext.frame -setgrid yes -wrap none $textopts
  64. pack .helptext.frame -side top -fill both -expand yes
  65. setfont .helptext.frame $help_font
  66. .helptext.frame.text insert end $message texttag
  67. eval .helptext.frame.text tag configure texttag $tagopts
  68. .helptext.frame.text configure -state disabled
  69. focus .helptext.frame.text
  70. grab .helptext
  71. tkwait window .helptext
  72. }
  73. #########################################################################
  74. #grassabout.tcl
  75. # open g.version and print in window
  76. #
  77. if {[catch {set text [exec g.version -c]} error]} {
  78. tk_messageBox -type ok -icon error -title [G_msg "Error"] -message [G_msg $error]
  79. }
  80. helptext {About GRASS} {-width 75} {-justify left} $text