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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [itk/] [examples/] [viewfile] - Blame information for rev 1770

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

Line No. Rev Author Line
1 578 markom
#!/bin/sh
2
#\
3
exec itkwish $0
4
# ----------------------------------------------------------------------
5
#  EXAMPLE: show "TextInfo" and "MessageInfo" widgets in action
6
# ----------------------------------------------------------------------
7
#  COURSE:  Object-Oriented Programming with [incr Tcl]
8
#  AUTHOR:  Michael J. McLennan, Bell Labs Innovations
9
# ======================================================================
10
#               Copyright (c) 1996  Lucent Technologies
11
# ======================================================================
12
lappend auto_path .
13
 
14
if {[string match *color [winfo screenvisual .]]} {
15
    option add *textBackground ivory startupFile
16
    option add *MessageInfo.background DarkSeaGreen startupFile
17
    option add *TextInfo.background DarkSeaGreen startupFile
18
    option add *activeBackground ForestGreen startupFile
19
    option add *activeForeground white startupFile
20
    option add *selectForeground white startupFile
21
    option add *selectBackground ForestGreen startupFile
22
}
23
 
24
label .label -text "View File:"
25
pack .label -anchor w
26
 
27
entry .file
28
pack .file -fill x
29
 
30
bind .file  {show_file [.file get]}
31
 
32
proc show_file {file} {
33
    set cmd {
34
        set fid [open $file r]
35
        set info [read $fid]
36
        close $fid
37
    }
38
    if {[catch $cmd] == 0} {
39
        set win [TextInfo .#auto -wrap none]
40
        $win display $info
41
    } else {
42
        MessageInfo .#auto -message "Cannot read file:\n$file"
43
    }
44
}

powered by: WebSVN 2.1.0

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