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

Subversion Repositories or1k

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

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 tixDirList widget -- you can
10
# use it for the user to select a directory. For example, an installation
11
# program can use the tixDirList widget to ask the user to select the
12
# installation directory for an application.
13
#
14
proc RunSample {w} {
15
 
16
    # Create the tixDirList and the tixLabelEntry widgets on the on the top
17
    # of the dialog box
18
    #
19
    frame $w.top -border 1 -relief raised
20
 
21
    # Create the DirList widget. By default it will show the current
22
    # directory (returned by [pwd])
23
    #
24
    #
25
    tixDirList $w.top.dir
26
 
27
    # When the user presses the ".." button, the selected directory
28
    # is "transferred" into the entry widget
29
    #
30
    button $w.top.btn -text "  >>  " -pady 0 \
31
        -command "dlist:copy_name $w.top.dir"
32
 
33
    # We use a LabelEntry to hold the installation directory. The user
34
    # can choose from the DirList widget, or he can type in the directory 
35
    # manually
36
    #
37
    tixLabelEntry $w.top.ent -label "Installation Directory:" -labelside top \
38
        -options {
39
            entry.width 25
40
            entry.textVariable demo_dlist_dir
41
            label.anchor w
42
        }
43
    bind [$w.top.ent subwidget entry] <Return> "dlist:okcmd $w"
44
 
45
    uplevel #0 set demo_dlist_dir [list [pwd]]
46
 
47
    pack $w.top.dir -side left -expand yes -fill both -padx 4 -pady 4
48
    pack $w.top.btn -side left -anchor s -padx 4 -pady 4
49
    pack $w.top.ent -side left -fill x -anchor s -padx 4 -pady 4
50
 
51
    # Use a ButtonBox to hold the buttons.
52
    #
53
    tixButtonBox $w.box -orientation horizontal
54
    $w.box add ok     -text Ok     -underline 0 -command "dlist:okcmd $w" \
55
        -width 6
56
    $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
57
        -width 6
58
 
59
    pack $w.box -side bottom -fill x
60
    pack $w.top -side top -fill both -expand yes
61
}
62
 
63
 
64
proc dlist:copy_name {w} {
65
    global demo_dlist_dir
66
 
67
    set demo_dlist_dir [$w cget -value]
68
}
69
 
70
proc dlist:okcmd {w} {
71
    global demo_dlist_dir
72
 
73
    puts "You have selected the directory $demo_dlist_dir"
74
 
75
    destroy $w
76
}
77
 
78
# This "if" statement makes it possible to run this script file inside or
79
# outside of the main demo program "widget".
80
#
81
if {![info exists tix_demo_running]} {
82
    wm withdraw .
83
    set w .demo
84
    toplevel $w
85
    RunSample $w
86
    bind .demo <Destroy> "exit"
87
}

powered by: WebSVN 2.1.0

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