summaryrefslogtreecommitdiffstats
path: root/library/demos/ttkmenu.tcl
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2007-10-18 14:34:06 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2007-10-18 14:34:06 (GMT)
commit07afeec69934f6b60286fb552272d2913e0614c2 (patch)
tree70afca83c8f1cf3aefff032f0256d424f9727a4a /library/demos/ttkmenu.tcl
parent1a72e7527449c754a0edde0085f4eb4ad867fde5 (diff)
downloadtk-07afeec69934f6b60286fb552272d2913e0614c2.zip
tk-07afeec69934f6b60286fb552272d2913e0614c2.tar.gz
tk-07afeec69934f6b60286fb552272d2913e0614c2.tar.bz2
More Ttk demos
Diffstat (limited to 'library/demos/ttkmenu.tcl')
-rw-r--r--library/demos/ttkmenu.tcl55
1 files changed, 55 insertions, 0 deletions
diff --git a/library/demos/ttkmenu.tcl b/library/demos/ttkmenu.tcl
new file mode 100644
index 0000000..6cda290
--- /dev/null
+++ b/library/demos/ttkmenu.tcl
@@ -0,0 +1,55 @@
+# ttkmenu.tcl --
+#
+# This demonstration script creates a toplevel window containing several Ttk
+# menubutton widgets.
+#
+# RCS: @(#) $Id: ttkmenu.tcl,v 1.1 2007/10/18 14:34:06 dkf Exp $
+
+if {![info exists widgetDemo]} {
+ error "This script should be run from the \"widget\" demo."
+}
+
+package require Tk
+package require Ttk
+
+set w .ttkmenu
+catch {destroy $w}
+toplevel $w
+wm title $w "Ttk Menu Buttons"
+wm iconname $w "ttkmenu"
+positionWindow $w
+
+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."
+pack $w.msg [ttk::separator $w.msgSep] -side top -fill x
+
+## See Code / Dismiss
+pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x
+
+ttk::menubutton $w.m1 -menu $w.m1.menu -text "Select a theme" -direction above
+ttk::menubutton $w.m2 -menu $w.m1.menu -text "Select a theme" -direction left
+ttk::menubutton $w.m3 -menu $w.m1.menu -text "Select a theme" -direction right
+ttk::menubutton $w.m4 -menu $w.m1.menu -text "Select a theme" \
+ -direction flush -style TMenubutton.Toolbutton
+ttk::menubutton $w.m5 -menu $w.m1.menu -text "Select a theme" -direction below
+
+menu $w.m1.menu -tearoff 0
+menu $w.m2.menu -tearoff 0
+menu $w.m3.menu -tearoff 0
+menu $w.m4.menu -tearoff 0
+menu $w.m5.menu -tearoff 0
+
+foreach theme [ttk::themes] {
+ $w.m1.menu add command -label $theme -command [list ttk::setTheme $theme]
+ $w.m2.menu add command -label $theme -command [list ttk::setTheme $theme]
+ $w.m3.menu add command -label $theme -command [list ttk::setTheme $theme]
+ $w.m4.menu add command -label $theme -command [list ttk::setTheme $theme]
+ $w.m5.menu add command -label $theme -command [list ttk::setTheme $theme]
+}
+
+pack [ttk::frame $w.f] -fill x
+lower $w.f
+
+grid anchor $w.f center
+grid x $w.m1 x -in $w.f -padx 3 -pady 2
+grid $w.m2 $w.m4 $w.m3 -in $w.f -padx 3 -pady 2
+grid x $w.m5 x -in $w.f -padx 3 -pady 2