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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [demos/] [samples/] [SListBox.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 tixScrolledListBox widget.
10
#
11
 
12
proc RunSample {w} {
13
 
14
    # We create the frame and the two ScrolledListBox widgets
15
    # at the top of the dialog box
16
    #
17
    frame $w.top -relief raised -bd 1
18
 
19
    # The first ScrolledListBox widget always shows both scrollbars
20
    #
21
    tixScrolledListBox $w.top.a -scrollbar both
22
    pack $w.top.a -expand yes -fill both -padx 10 -pady 10 -side left
23
 
24
    # The second  ScrolledListBox widget shows the scrollbars only when
25
    # needed.
26
    #
27
    # [Hint] See how you can use the -options switch to set the options
28
    #        for the subwidgets
29
    #
30
    tixScrolledListBox $w.top.b -scrollbar auto -options {
31
        listbox.font 8x13
32
    }
33
    pack $w.top.b -expand yes -fill both -padx 10 -pady 10 -side left
34
 
35
    # Put the elements inside the two listboxes: notice that you need
36
    # to insert inside the "listbox" subwidget of the ScrolledListBox.
37
    # $w.top.a itself does NOT have an "insert" command.
38
    #
39
    $w.top.a subwidget listbox insert 0 \
40
        Alabama Alaska Arizona Arkansas California \
41
        Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois \
42
        Indiana Iowa Kansas Kentucky Louisiana Maine Maryland \
43
        Massachusetts Michigan Minnesota Mississippi Missouri \
44
        Montana Nebraska Nevada "New Hampshire" "New Jersey" "New Mexico" \
45
        "New York" "North Carolina" "North Dakota" \
46
        Ohio Oklahoma Oregon Pennsylvania "Rhode Island" \
47
        "South Carolina" "South Dakota" \
48
        Tennessee Texas Utah Vermont Virginia Washington \
49
        "West Virginia" Wisconsin Wyoming
50
 
51
    $w.top.a subwidget listbox config -cursor left_ptr
52
    raise [$w.top.a subwidget listbox ]
53
    $w.top.b subwidget listbox insert 0 \
54
        Alabama Alaska Arizona Arkansas California \
55
        Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois \
56
        Indiana Iowa Kansas Kentucky
57
 
58
    # Use a ButtonBox to hold the buttons.
59
    #
60
    tixButtonBox $w.box -orientation horizontal
61
    $w.box add ok     -text Ok     -underline 0 -command "destroy $w" \
62
        -width 6
63
    $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
64
        -width 6
65
 
66
    pack $w.box -side bottom -fill x
67
    pack $w.top -side top -fill both -expand yes
68
}
69
 
70
 
71
# This "if" statement makes it possible to run this script file inside or
72
# outside of the main demo program "widget".
73
#
74
if {![info exists tix_demo_running]} {
75
    wm withdraw .
76
    set w .demo
77
    toplevel $w
78
    RunSample $w
79
        bind $w <Destroy> exit
80
}
81
 

powered by: WebSVN 2.1.0

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