1# ttkmenu.tcl --
2#
3# This demonstration script creates a toplevel window containing several Ttk
4# menubutton widgets.
5#
6# RCS: @(#) $Id$
7
8if {![info exists widgetDemo]} {
9    error "This script should be run from the \"widget\" demo."
10}
11
12package require Tk
13package require Ttk
14
15set w .ttkmenu
16catch {destroy $w}
17toplevel $w
18wm title $w "Ttk Menu Buttons"
19wm iconname $w "ttkmenu"
20positionWindow $w
21
22ttk::label $w.msg -font $font -wraplength 4i -justify left -text "Ttk is the new Tk themed widget set, and one widget that is available in themed form is the menubutton. Below are some themed menu buttons that allow you to pick the current theme in use. Notice how picking a theme changes the way that the menu buttons themselves look, and that the central menu button is styled differently (in a way that is normally suitable for toolbars). However, there are no themed menus; the standard Tk menus were judged to have a sufficiently good look-and-feel on all platforms, especially as they are implemented as native controls in many places."
23pack $w.msg [ttk::separator $w.msgSep] -side top -fill x
24
25## See Code / Dismiss
26pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x
27
28ttk::menubutton $w.m1 -menu $w.m1.menu -text "Select a theme" -direction above
29ttk::menubutton $w.m2 -menu $w.m1.menu -text "Select a theme" -direction left
30ttk::menubutton $w.m3 -menu $w.m1.menu -text "Select a theme" -direction right
31ttk::menubutton $w.m4 -menu $w.m1.menu -text "Select a theme" \
32	-direction flush -style TMenubutton.Toolbutton
33ttk::menubutton $w.m5 -menu $w.m1.menu -text "Select a theme" -direction below
34
35menu $w.m1.menu -tearoff 0
36menu $w.m2.menu -tearoff 0
37menu $w.m3.menu -tearoff 0
38menu $w.m4.menu -tearoff 0
39menu $w.m5.menu -tearoff 0
40
41foreach theme [ttk::themes] {
42    $w.m1.menu add command -label $theme -command [list ttk::setTheme $theme]
43    $w.m2.menu add command -label $theme -command [list ttk::setTheme $theme]
44    $w.m3.menu add command -label $theme -command [list ttk::setTheme $theme]
45    $w.m4.menu add command -label $theme -command [list ttk::setTheme $theme]
46    $w.m5.menu add command -label $theme -command [list ttk::setTheme $theme]
47}
48
49pack [ttk::frame $w.f] -fill x
50pack [ttk::frame $w.f1] -fill both -expand yes
51lower $w.f
52
53grid anchor $w.f center
54grid   x   $w.m1   x    -in $w.f -padx 3 -pady 2
55grid $w.m2 $w.m4 $w.m3  -in $w.f -padx 3 -pady 2
56grid   x   $w.m5   x    -in $w.f -padx 3 -pady 2
57