source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vrippack-0.31/src/vrip/lib/tk/demos/menubu.tcl @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 4.4 KB
Line 
1# menubutton.tcl --
2#
3# This demonstration script creates a window with a bunch of menus
4# and cascaded menus using menubuttons.
5#
6# # RCS: @(#) $Id: menubu.tcl,v 1.2 1998/09/14 18:23:29 stanton Exp $
7
8if {![info exists widgetDemo]} {
9    error "This script should be run from the \"widget\" demo."
10}
11
12set w .menubutton
13catch {destroy $w}
14toplevel $w
15wm title $w "Menu Button Demonstration"
16wm iconname $w "menubutton"
17positionWindow $w
18
19
20frame $w.body
21pack $w.body -expand 1 -fill both
22
23menubutton $w.body.below -text "Below" -underline 0 -direction below -menu $w.body.below.m -relief raised
24menu $w.body.below.m -tearoff 0 
25$w.body.below.m add command -label "Below menu: first item" -command "puts \"You have selected the first item from the Below menu.\""
26$w.body.below.m add command -label "Below menu: second item" -command "puts \"You have selected the second item from the Below menu.\""
27grid $w.body.below -row 0 -column 1 -sticky n
28menubutton $w.body.right -text "Right" -underline 0 -direction right -menu $w.body.right.m -relief raised
29menu $w.body.right.m -tearoff 0
30$w.body.right.m add command -label "Right menu: first item" -command "puts \"You have selected the first item from the Right menu.\""
31$w.body.right.m add command -label "Right menu: second item" -command "puts \"You have selected the second item from the Right menu.\""
32frame $w.body.center
33menubutton $w.body.left -text "Left" -underline 0 -direction left -menu $w.body.left.m -relief raised
34menu $w.body.left.m -tearoff 0
35$w.body.left.m add command -label "Left menu: first item" -command "puts \"You have selected the first item from the Left menu.\""
36$w.body.left.m add command -label "Left menu: second item" -command "puts \"You have selected the second item from the Left menu.\""
37grid $w.body.right -row 1 -column 0 -sticky w
38grid $w.body.center -row 1 -column 1 -sticky news
39grid $w.body.left -row 1 -column 2 -sticky e
40menubutton $w.body.above -text "Above" -underline 0 -direction above -menu $w.body.above.m -relief raised
41menu $w.body.above.m -tearoff 0
42$w.body.above.m add command -label "Above menu: first item" -command "puts \"You have selected the first item from the Above menu.\""
43$w.body.above.m add command -label "Above menu: second item" -command "puts \"You have selected the second item from the Above menu.\""
44grid $w.body.above -row 2 -column 1 -sticky s
45
46frame $w.buttons
47pack $w.buttons -side bottom -fill x -pady 2m
48button $w.buttons.dismiss -text Dismiss -command "destroy $w"
49button $w.buttons.code -text "See Code" -command "showCode .menubu"
50pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
51
52set body $w.body.center
53label $body.label -wraplength 300 -font "Helvetica 14" -justify left -text "This is a demonstration of menubuttons. The \"Below\" menubutton pops its menu below the button; the \"Right\" button pops to the right, etc. There are two option menus directly below this text; one is just a standard menu and the other is a 16-color palette."
54pack $body.label -side top -padx 25 -pady 25
55frame $body.buttons
56pack $body.buttons -padx 25 -pady 25
57tk_optionMenu $body.buttons.options menubuttonoptions one two three
58pack $body.buttons.options -side left -padx 25 -pady 25
59set m [tk_optionMenu $body.buttons.colors paletteColor Black red4 DarkGreen NavyBlue gray75 Red Green Blue gray50 Yellow Cyan Magenta White Brown DarkSeaGreen DarkViolet]
60if {$tcl_platform(platform) == "macintosh"} {
61    set topBorderColor Black
62    set bottomBorderColor Black
63} else {
64    set topBorderColor gray50
65    set bottomBorderColor gray75
66}
67for {set i 0} {$i <= [$m index last]} {incr i} {
68    set name [$m entrycget $i -label]
69    image create photo image_$name -height 16 -width 16
70    image_$name put $topBorderColor -to 0 0 16 1
71    image_$name put $topBorderColor -to 0 1 1 16
72    image_$name put $bottomBorderColor -to 0 15 16 16
73    image_$name put $bottomBorderColor -to 15 1 16 16
74    image_$name put $name -to 1 1 15 15
75
76    image create photo image_${name}_s -height 16 -width 16
77    image_${name}_s put Black -to 0 0 16 2
78    image_${name}_s put Black -to 0 2 2 16
79    image_${name}_s put Black -to 2 14 16 16
80    image_${name}_s put Black -to 14 2 16 14
81    image_${name}_s put $name -to 2 2 14 14
82
83    $m entryconfigure $i -image image_$name -selectimage image_${name}_s -hidemargin 1
84}
85$m configure -tearoff 1
86foreach i {Black gray75 gray50 White} {
87        $m entryconfigure $i -columnbreak 1
88}
89
90pack $body.buttons.colors -side left -padx 25 -pady 25
91
92
93
Note: See TracBrowser for help on using the repository browser.