1 # Tix Demostration Program
3 # This sample program is structured in such a way so that it can be
4 # executed from the Tix demo program "widget": it must have a
5 # procedure called "RunSample". It should also have the "if" statment
6 # at the end of this file so that it can be run as a standalone
7 # program using tixwish.
9 # This file demonstrates the use of the tixPopupMenu widget.
14 # We create the frame and the button, then we'll bind the PopupMenu
15 # to both widgets. The result is, when you press the right mouse
16 # button over $w.top or $w.top.but, the PopupMenu will come up.
19 frame $w.top -relief raised -bd 1
21 button $w.top.but -text {Press the right mouse button over
22 this button or its surrounding area}
24 pack $w.top.but -expand yes -fill both -padx 50 -pady 50
26 tixPopupMenu $w.top.p -title "Popup Test"
28 $w.top.p bind $w.top.but
30 # Set the entries inside the PopupMenu widget.
31 # [Hint] You have to manipulate the "menu" subwidget.
32 # $w.top.p itself is NOT a menu widget.
33 # [Hint] Watch carefully how the sub-menu is created
35 set menu [$w.top.p subwidget menu]
36 $menu add command -label Desktop -under 0
37 $menu add command -label Select -under 0
38 $menu add command -label Find -under 0
39 $menu add command -label System -under 1
40 $menu add command -label Help -under 0
41 $menu add cascade -label More -menu $menu.m1
43 $menu.m1 add command -label Hello
45 pack $w.top.but -side top -padx 40 -pady 50
47 # Use a ButtonBox to hold the buttons.
49 tixButtonBox $w.box -orientation horizontal
50 $w.box add ok -text Ok -underline 0 -command "destroy $w" \
52 $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
55 pack $w.box -side bottom -fill x
56 pack $w.top -side top -fill both -expand yes
60 # This "if" statement makes it possible to run this script file inside or
61 # outside of the main demo program "widget".
63 if {![info exists tix_demo_running]} {
68 bind $w <Destroy> {if {"%W" == ".demo"} exit}