OSDN Git Service

PEP8対応
[stux/ultron.git] / venv / tcl / tk8.6 / demos / ttkmenu.tcl
1 # ttkmenu.tcl --
2 #
3 # This demonstration script creates a toplevel window containing several Ttk
4 # menubutton widgets.
5
6 if {![info exists widgetDemo]} {
7     error "This script should be run from the \"widget\" demo."
8 }
9
10 package require Tk
11
12 set w .ttkmenu
13 catch {destroy $w}
14 toplevel $w
15 wm title $w "Ttk Menu Buttons"
16 wm iconname $w "ttkmenu"
17 positionWindow $w
18
19 ttk::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."
20 pack $w.msg [ttk::separator $w.msgSep] -side top -fill x
21
22 ## See Code / Dismiss
23 pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x
24
25 ttk::menubutton $w.m1 -menu $w.m1.menu -text "Select a theme" -direction above
26 ttk::menubutton $w.m2 -menu $w.m1.menu -text "Select a theme" -direction left
27 ttk::menubutton $w.m3 -menu $w.m1.menu -text "Select a theme" -direction right
28 ttk::menubutton $w.m4 -menu $w.m1.menu -text "Select a theme" \
29         -direction flush -style TMenubutton.Toolbutton
30 ttk::menubutton $w.m5 -menu $w.m1.menu -text "Select a theme" -direction below
31
32 menu $w.m1.menu -tearoff 0
33 menu $w.m2.menu -tearoff 0
34 menu $w.m3.menu -tearoff 0
35 menu $w.m4.menu -tearoff 0
36 menu $w.m5.menu -tearoff 0
37
38 foreach theme [ttk::themes] {
39     $w.m1.menu add command -label $theme -command [list ttk::setTheme $theme]
40     $w.m2.menu add command -label $theme -command [list ttk::setTheme $theme]
41     $w.m3.menu add command -label $theme -command [list ttk::setTheme $theme]
42     $w.m4.menu add command -label $theme -command [list ttk::setTheme $theme]
43     $w.m5.menu add command -label $theme -command [list ttk::setTheme $theme]
44 }
45
46 pack [ttk::frame $w.f] -fill x
47 pack [ttk::frame $w.f1] -fill both -expand yes
48 lower $w.f
49
50 grid anchor $w.f center
51 grid   x   $w.m1   x    -in $w.f -padx 3 -pady 2
52 grid $w.m2 $w.m4 $w.m3  -in $w.f -padx 3 -pady 2
53 grid   x   $w.m5   x    -in $w.f -padx 3 -pady 2