ListNBK.tcl 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #
  2. # $Id: ListNBK.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
  3. #
  4. # Tix Demostration Program
  5. #
  6. # This sample program is structured in such a way so that it can be
  7. # executed from the Tix demo program "widget": it must have a
  8. # procedure called "RunSample". It should also have the "if" statment
  9. # at the end of this file so that it can be run as a standalone
  10. # program using tixwish.
  11. # This program demonstrates the ListBoteBook widget, which is very similar
  12. # to a NoteBook widget but uses an HList instead of page tabs to list the
  13. # pages.
  14. proc RunSample {w} {
  15. set top [frame $w.f -bd 1 -relief raised]
  16. set box [tixButtonBox $w.b -bd 1 -relief raised]
  17. pack $box -side bottom -fill both
  18. pack $top -side top -fill both -expand yes
  19. #----------------------------------------------------------------------
  20. # Create the ListNoteBook with nice icons
  21. #----------------------------------------------------------------------
  22. tixListNoteBook $top.n -ipadx 6 -ipady 6
  23. set img0 [tix getimage harddisk]
  24. set img1 [tix getimage network]
  25. $top.n subwidget hlist add hard_disk -itemtype imagetext \
  26. -image $img0 -text "Hard Disk" -under 0
  27. $top.n subwidget hlist add network -itemtype imagetext \
  28. -image $img1 -text "Network" -under 0
  29. $top.n add hard_disk
  30. $top.n add network
  31. #
  32. # Create the widgets inside the two pages
  33. # We use these options to set the sizes of the subwidgets inside the
  34. # notebook, so that they are well-aligned on the screen.
  35. #
  36. set name [tixOptionName $w]
  37. option add *$name*TixControl*entry.width 10
  38. option add *$name*TixControl*label.width 18
  39. option add *$name*TixControl*label.anchor e
  40. set f [$top.n subwidget hard_disk]
  41. tixControl $f.a -value 12 -label "Access Time: "
  42. tixControl $f.w -value 400 -label "Write Throughput: "
  43. tixControl $f.r -value 400 -label "Read Throughput: "
  44. tixControl $f.c -value 1021 -label "Capacity: "
  45. pack $f.a $f.w $f.r $f.c -side top -padx 20 -pady 2
  46. set f [$top.n subwidget network]
  47. tixControl $f.a -value 12 -label "Access Time: "
  48. tixControl $f.w -value 400 -label "Write Throughput: "
  49. tixControl $f.r -value 400 -label "Read Throughput: "
  50. tixControl $f.c -value 1021 -label "Capacity: "
  51. tixControl $f.u -value 10 -label "Users: "
  52. pack $f.a $f.w $f.r $f.c $f.u -side top -padx 20 -pady 2
  53. pack $top.n -expand yes -fill both -padx 5 -pady 5
  54. # Create the buttons
  55. #
  56. $box add ok -text Ok -command "destroy $w" -width 6
  57. $box add cancel -text Cancel -command "destroy $w" -width 6
  58. }
  59. #----------------------------------------------------------------------
  60. # Start-up code
  61. #----------------------------------------------------------------------
  62. if {![info exists tix_demo_running]} {
  63. wm withdraw .
  64. set w .demo
  65. toplevel $w; wm transient $w ""
  66. RunSample $w
  67. bind $w <Destroy> exit
  68. }