gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.7KB

  1. # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: SWindow.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
  4. #
  5. # Tix Demostration Program
  6. #
  7. # This sample program is structured in such a way so that it can be
  8. # executed from the Tix demo program "widget": it must have a
  9. # procedure called "RunSample". It should also have the "if" statment
  10. # at the end of this file so that it can be run as a standalone
  11. # program using tixwish.
  12. # This file demonstrates the use of the tixScrolledWindow widget.
  13. #
  14. proc RunSample {w} {
  15. # We create the frame and the ScrolledWindow widget
  16. # at the top of the dialog box
  17. #
  18. frame $w.top -relief raised -bd 1
  19. # Create a complex window inside the ScrolledWindow widget.
  20. # ScrolledWindow are very convenient: unlink the canvas widget,
  21. # you don't need to specify the scroll-redions for the
  22. # ScrolledWindow. It will automatically adjust itself to fit
  23. # size of the "window" subwidget
  24. #
  25. # [Hint] Be sure you create and pack new widgets inside the
  26. # "window" subwidget and NOT inside $w.top.a itself!
  27. #
  28. tixScrolledWindow $w.top.a
  29. pack $w.top.a -expand yes -fill both -padx 10 -pady 10 -side left
  30. set f [$w.top.a subwidget window]
  31. tixNoteBook $f.nb
  32. pack $f.nb -expand yes -fill both -padx 20 -pady 20
  33. $f.nb add image -label "Image" -underline 0
  34. $f.nb add buttons -label "Buttons" -underline 0
  35. # The first page: an image
  36. #
  37. global demo_dir
  38. set p [$f.nb subwidget image]
  39. set im [image create photo -file $demo_dir/bitmaps/tix.gif]
  40. label $p.lab -image $im
  41. pack $p.lab -padx 20 -pady 20
  42. # The second page: buttons
  43. #
  44. set p [$f.nb subwidget buttons]
  45. button $p.b1 -text "Welcome" -width 8
  46. button $p.b2 -text "to" -width 8
  47. button $p.b3 -text "the" -width 8
  48. button $p.b4 -text "World" -width 8
  49. button $p.b5 -text "of" -width 8
  50. button $p.b6 -text "Tix" -width 8
  51. pack $p.b1 $p.b2 $p.b3 $p.b4 $p.b5 $p.b6 -anchor c -side top
  52. # Use a ButtonBox to hold the buttons.
  53. #
  54. tixButtonBox $w.box -orientation horizontal
  55. $w.box add ok -text Ok -underline 0 -command "destroy $w" \
  56. -width 6
  57. $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
  58. -width 6
  59. pack $w.box -side bottom -fill x
  60. pack $w.top -side top -fill both -expand yes
  61. wm geometry $w 240x220
  62. }
  63. # This "if" statement makes it possible to run this script file inside or
  64. # outside of the main demo program "widget".
  65. #
  66. if {![info exists tix_demo_running]} {
  67. wm withdraw .
  68. set w .demo
  69. toplevel $w; wm transient $w ""
  70. RunSample $w
  71. bind $w <Destroy> exit
  72. }
上海开阖软件有限公司 沪ICP备12045867号-1