console_demo.tcl 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/sh
  2. #---------------------------------------------------------------------
  3. #
  4. # console_demo.tcl
  5. #
  6. # Demonstrate console package in a little application.
  7. #
  8. #---------------------------------------------------------------------
  9. #
  10. # Restart using wish \
  11. exec wish "$0" "$@"
  12. #---------------------------------------------------------------------
  13. # Create BWIDGET GUI to demonstrate
  14. # Most of this code is non-functional.
  15. #---------------------------------------------------------------------
  16. package require Tk
  17. package require BWidget
  18. # Menu description
  19. set descmenu {
  20. "&File" all file 0 {
  21. {command "&New" {} "Create a new file" {Ctrl n}}
  22. {command "&Open" {} "Open existing file" {Ctrl o}}
  23. {command "&Save" {} "Save" {Ctrl s}}
  24. {command "Sa&ve_as" {} "Save file with new name" {}}
  25. {command "&Exit" {} "Quit" {Ctrl x}}
  26. }
  27. "View" all file 0 {
  28. {checkbutton "Console" {} "Show/hide command console" {} \
  29. -variable globalvar}
  30. {command "Show Console" {} "Show command console" {} -command console::show}
  31. {command "Hide Console" {} "Hide command console" {} -command console::hide}
  32. }
  33. "&Help" all help 0 {
  34. {command "About" {} "" {}}
  35. }
  36. }
  37. # Main window just contains a text widget
  38. set f [MainFrame .mainframe -menu $descmenu]
  39. pack [text [$f getframe].text]
  40. pack $f -fill both -expand yes
  41. #---------------------------------------------------------------------
  42. # Load the console package from the same directory as
  43. # this demo script.
  44. # Note that the "console" package name is lower case.
  45. #---------------------------------------------------------------------
  46. set auto_path [concat [file dirname [info script]] $auto_path]
  47. package require console
  48. #---------------------------------------------------------------------
  49. # Create the console, and attach it to our global variable
  50. #---------------------------------------------------------------------
  51. console::create -title "Command Console" -variable globalvar
  52. # ... and we're done...