ttknote.tcl 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # ttknote.tcl --
  2. #
  3. # This demonstration script creates a toplevel window containing a Ttk
  4. # notebook widget.
  5. if {![info exists widgetDemo]} {
  6. error "This script should be run from the \"widget\" demo."
  7. }
  8. package require Tk
  9. package require Ttk
  10. set w .ttknote
  11. catch {destroy $w}
  12. toplevel $w
  13. wm title $w "Ttk Notebook Widget"
  14. wm iconname $w "ttknote"
  15. positionWindow $w
  16. ## See Code / Dismiss
  17. pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x
  18. ttk::frame $w.f
  19. pack $w.f -fill both -expand 1
  20. set w $w.f
  21. ## Make the notebook and set up Ctrl+Tab traversal
  22. ttk::notebook $w.note
  23. pack $w.note -fill both -expand 1 -padx 2 -pady 3
  24. ttk::notebook::enableTraversal $w.note
  25. ## Popuplate the first pane
  26. ttk::frame $w.note.msg
  27. ttk::label $w.note.msg.m -font $font -wraplength 4i -justify left -anchor n -text "Ttk is the new Tk themed widget set. One of the widgets it includes is the notebook widget, which provides a set of tabs that allow the selection of a group of panels, each with distinct content. They are a feature of many modern user interfaces. Not only can the tabs be selected with the mouse, but they can also be switched between using Ctrl+Tab when the notebook page heading itself is selected. Note that the second tab is disabled, and cannot be selected."
  28. ttk::button $w.note.msg.b -text "Neat!" -underline 0 -command {
  29. set neat "Yeah, I know..."
  30. after 500 {set neat {}}
  31. }
  32. bind $w <Alt-n> "focus $w.note.msg.b; $w.note.msg.b invoke"
  33. ttk::label $w.note.msg.l -textvariable neat
  34. $w.note add $w.note.msg -text "Description" -underline 0 -padding 2
  35. grid $w.note.msg.m - -sticky new -pady 2
  36. grid $w.note.msg.b $w.note.msg.l -pady {2 4}
  37. grid rowconfigure $w.note.msg 1 -weight 1
  38. grid columnconfigure $w.note.msg {0 1} -weight 1 -uniform 1
  39. ## Populate the second pane. Note that the content doesn't really matter
  40. ttk::frame $w.note.disabled
  41. $w.note add $w.note.disabled -text "Disabled" -state disabled
  42. ## Popuplate the third pane
  43. ttk::frame $w.note.editor
  44. $w.note add $w.note.editor -text "Text Editor" -underline 0
  45. text $w.note.editor.t -width 40 -height 10 -wrap char \
  46. -yscroll "$w.note.editor.s set"
  47. if {[tk windowingsystem] ne "aqua"} {
  48. ttk::scrollbar $w.note.editor.s -orient vertical -command "$w.note.editor.t yview"
  49. } else {
  50. scrollbar $w.note.editor.s -orient vertical -command "$w.note.editor.t yview"
  51. }
  52. pack $w.note.editor.s -side right -fill y -padx {0 2} -pady 2
  53. pack $w.note.editor.t -fill both -expand 1 -pady 2 -padx {2 0}