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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [demos/] [samples/] [DirDlg.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 tixDirSelectDialog widget:
10
# it allows the user to select a directory.
11
#
12
proc RunSample {w} {
13
 
14
    # Create an entry for the user to input a directory. If he can't
15
    # bother to type in the name, he can press the "Browse ..." button
16
    # and call up the diretcory dialog
17
    #
18
    frame $w.top -border 1 -relief raised
19
 
20
    tixLabelEntry $w.top.ent -label "Select A Directory:" -labelside top \
21
        -options {
22
            entry.width 25
23
            entry.textVariable demo_ddlg_dirname
24
            label.anchor w
25
        }
26
    bind [$w.top.ent subwidget entry] <Return> "ddlg:okcmd $w"
27
 
28
    uplevel #0 set demo_ddlg_dirname {}
29
 
30
    button $w.top.btn -text "Browse ..." -command "ddlg:browse"
31
 
32
    pack $w.top.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4
33
    pack $w.top.btn -side left -anchor s -padx 4 -pady 4
34
 
35
    # Use a ButtonBox to hold the buttons.
36
    #
37
    tixButtonBox $w.box -orientation horizontal
38
    $w.box add ok     -text Ok     -underline 0 -command "ddlg:okcmd $w" \
39
        -width 6
40
    $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
41
        -width 6
42
 
43
    pack $w.box -side bottom -fill x
44
    pack $w.top -side top -fill both -expand yes
45
}
46
 
47
# Pop up a directory selection dialog
48
#
49
proc ddlg:browse {} {
50
    set dialog .dirdlg_popup
51
    if ![winfo exists $dialog] {
52
        tixDirSelectDialog $dialog
53
    }
54
    $dialog config -command ddlg:select_dir
55
 
56
    $dialog popup
57
}
58
 
59
proc ddlg:select_dir {dir} {
60
    global demo_ddlg_dirname
61
 
62
    set demo_ddlg_dirname $dir
63
}
64
 
65
proc ddlg:okcmd {w} {
66
    global demo_ddlg_dirname
67
 
68
    if {$demo_ddlg_dirname != {}} {
69
        puts "You have selected the directory $demo_ddlg_dirname"
70
    } else {
71
        puts "You haven't selected any directory"
72
    }
73
 
74
    destroy $w
75
}
76
 
77
# This "if" statement makes it possible to run this script file inside or
78
# outside of the main demo program "widget".
79
#
80
if {![info exists tix_demo_running]} {
81
    wm withdraw .
82
    set w .demo
83
    toplevel $w
84
    RunSample $w
85
    bind .demo <Destroy> exit
86
}

powered by: WebSVN 2.1.0

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