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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [demos/] [samples/] [DirTree.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 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 tixDirTree 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 DirTree widget. By default it will show the current
22
    # directory (returned by [pwd])
23
    #
24
    #
25
    tixDirTree $w.top.dir -browsecmd "dtree:browse $w.top.ent"
26
 
27
    # When the user presses the ".." button, the selected directory
28
    # is "transferred" into the entry widget
29
    #
30
 
31
    # We use a LabelEntry to hold the installation directory. The user
32
    # can choose from the DirTree widget, or he can type in the directory 
33
    # manually
34
    #
35
    tixLabelEntry $w.top.ent -label "Installation Directory:" -labelside top \
36
        -options {
37
            entry.width 25
38
            entry.textVariable demo_dtree_dir
39
            label.anchor w
40
        }
41
    bind [$w.top.ent subwidget entry] <Return> "dtree:okcmd $w"
42
 
43
    uplevel #0 set demo_dtree_dir [list [pwd]]
44
 
45
    pack $w.top.dir -side left -expand yes -fill both -padx 4 -pady 4
46
    pack $w.top.ent -side left -fill x -anchor c -padx 4 -pady 4
47
 
48
    # Use a ButtonBox to hold the buttons.
49
    #
50
    tixButtonBox $w.box -orientation horizontal
51
    $w.box add ok     -text Ok     -underline 0 -command "dtree:okcmd $w" \
52
        -width 6
53
    $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
54
        -width 6
55
 
56
    pack $w.box -side bottom -fill x
57
    pack $w.top -side top -fill both -expand yes
58
}
59
 
60
proc dtree:browse {ent filename} {
61
    uplevel #0 set demo_dtree_dir $filename
62
 
63
}
64
 
65
proc dtree:copy_name {w} {
66
    global demo_dtree_dir
67
 
68
    set demo_dtree_dir [$w cget -value]
69
}
70
 
71
proc dtree:okcmd {w} {
72
    global demo_dtree_dir
73
 
74
    puts "You have selected the directory $demo_dtree_dir"
75
 
76
    destroy $w
77
}
78
 
79
# This "if" statement makes it possible to run this script file inside or
80
# outside of the main demo program "widget".
81
#
82
if {![info exists tix_demo_running]} {
83
    wm withdraw .
84
    set w .demo
85
    toplevel $w
86
    RunSample $w
87
    bind .demo <Destroy> "exit"
88
}

powered by: WebSVN 2.1.0

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