OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [demos/] [samples/] [PopMenu.tcl] - Blame information for rev 1781

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Tix Demostration Program
2
#
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.
8
 
9
# This file demonstrates the use of the tixPopupMenu widget.
10
#
11
 
12
proc RunSample {w} {
13
 
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.
17
    #
18
 
19
    frame $w.top -relief raised -bd 1
20
 
21
    button $w.top.but -text {Press the right mouse button over
22
this button or its surrounding area}
23
 
24
    pack $w.top.but -expand yes -fill both -padx 50 -pady 50
25
 
26
    tixPopupMenu $w.top.p -title "Popup Test"
27
    $w.top.p bind $w.top
28
    $w.top.p bind $w.top.but
29
 
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
34
    #
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
42
    menu $menu.m1
43
    $menu.m1 add command -label Hello
44
 
45
    pack $w.top.but -side top -padx 40 -pady 50
46
 
47
    # Use a ButtonBox to hold the buttons.
48
    #
49
    tixButtonBox $w.box -orientation horizontal
50
    $w.box add ok     -text Ok     -underline 0 -command "destroy $w" \
51
        -width 6
52
    $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
53
        -width 6
54
 
55
    pack $w.box -side bottom -fill x
56
    pack $w.top -side top -fill both -expand yes
57
}
58
 
59
 
60
# This "if" statement makes it possible to run this script file inside or
61
# outside of the main demo program "widget".
62
#
63
if {![info exists tix_demo_running]} {
64
    wm withdraw .
65
    set w .demo
66
    toplevel $w
67
    RunSample $w
68
        bind $w <Destroy> {if {"%W" == ".demo"} exit}
69
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.