gui_help.tcl 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #----------------------------------------------------------------
  2. #
  3. # gui_help.tcl
  4. #
  5. # Basic help functions for TNT gui.
  6. #
  7. # Based on a topic, this will display the help.
  8. #
  9. # Copyright 2002-2004 Mayo Foundation. All Rights Reserved
  10. # $Id: gui_help.tcl,v 1.7 2004/07/26 13:37:52 techenti Exp $
  11. #
  12. #----------------------------------------------------------------
  13. package provide gui 2.0
  14. #------------------------------------------------------------
  15. #
  16. # ::gui::tnt_help
  17. #
  18. # Online help functions
  19. #
  20. #------------------------------------------------------------
  21. proc ::gui::tnt_help { helpTopic } {
  22. switch -exact $helpTopic {
  23. userguide {
  24. display_online_help ../share/tnt-mmtl/user-guide/index.html
  25. }
  26. }
  27. }
  28. #------------------------------------------------------------
  29. #
  30. # ::gui::display_online_help
  31. #
  32. # Display online help in a web browser.
  33. #
  34. #------------------------------------------------------------
  35. proc ::gui::display_online_help { helpTopic } {
  36. # Compute a full path spec, which isn't really a url.
  37. set url [file normalize [file join $::docDirPath $helpTopic]]
  38. switch $::tcl_platform(platform) {
  39. windows {
  40. # must convert to short form because this won't
  41. # work with spaces in the file names. :-(
  42. set url [file attributes $url -shortname]
  43. eval exec [auto_execok start] [list $url] &
  44. }
  45. default {
  46. # Try firefox, mozilla, opera, then netscape
  47. foreach browser {firefox mozilla opera netscape} {
  48. set prog [auto_execok $browser]
  49. if {$prog ne ""} {
  50. if {[catch {exec $prog $url &}] == 0} {
  51. # display temporary message window, then exit
  52. after 2000 {destroy .helpstartmsg}
  53. tk_dialog .helpstartmsg "Starting Browser" \
  54. "Starting $browser for online help . . ." \
  55. "" 0 "Close"
  56. return
  57. }
  58. }
  59. }
  60. # else we've failed
  61. error "Unable to start HTML browser on '$url'"
  62. }
  63. }
  64. }