Hello Michael,

> An example would be to have a command button to run "ps -ef" (under
> UNIX) and get the results to open in a tcl/tk window, instead of using
> an xterm or other such Xbased terminal.

below I have inserted an example which does what you want. It was created by
usage of vTcl 1.09. If you implement it manually (without vTcl), it would be
more simple (means shorter). The magic call is 'exec'.

Much fun. If you have any further question, you're welcome to ask.

Bye,
Cle.

---------------------------BEGIN OF DEMO SCRIPT--------------------------------
#!/home/omcr/public/bin/solaris/wish4.2
#############################################################################
# Visual Tcl v1.09 Project
#

#################################
# GLOBAL VARIABLES
#
global widget; 
    set widget(rev,.top29.cpd32.03) {text:log}
    set widget(text:log) {.top29.cpd32.03}

#################################
# USER DEFINED PROCEDURES
#
proc init {argc argv} {

}

init $argc $argv


proc main {argc argv} {

}

proc Window {args} {
global vTcl
    set cmd [lindex $args 0]
    set name [lindex $args 1]
    set newname [lindex $args 2]
    set rest [lrange $args 3 end]
    if {$name == "" || $cmd == ""} {return}
    if {$newname == ""} {
        set newname $name
    }
    set exists [winfo exists $newname]
    switch $cmd {
        show {
            if {[info procs vTclWindow(pre)$name] != ""} {
                eval "vTclWindow(pre)$name $newname $rest"
            }
            if {[info procs vTclWindow$name] != ""} {
                eval "vTclWindow$name $newname $rest"
            }
            if {[info procs vTclWindow(post)$name] != ""} {
                eval "vTclWindow(post)$name $newname $rest"
            }
        }
        hide    { if $exists {wm withdraw $newname; return} }
        iconify { if $exists {wm iconify $newname; return} }
        destroy { if $exists {destroy $newname; return} }
    }
}

#################################
# VTCL GENERATED GUI PROCEDURES
#

proc vTclWindow. {base} {
    global widgetlabels
    if {$base == ""} {
        set base .
    }
    ###################
    # CREATING WIDGETS
    ###################
    wm focusmodel $base passive
    wm geometry $base 200x200+0+0
    wm maxsize $base 1265 994
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 1 1
    wm withdraw $base
    wm title $base "vt.tcl"

    if {$base == "."} {
        set base ""
    }
    ###################
    # SETTING GEOMETRY
    ###################
}

proc vTclWindow.top29 {base} {
    global widgetlabels
    if {$base == ""} {
        set base .top29
    }
    if {[winfo exists $base]} {
        wm deiconify $base; return
    }
    ###################
    # CREATING WIDGETS
    ###################
    toplevel $base -class Toplevel \
        -background lightgray -cursor fleur -highlightbackground lightgray 
    wm focusmodel $base passive
    wm geometry $base 498x260+245+229
    wm maxsize $base 1265 994
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 1 1
    wm deiconify $base
    wm title $base "top29"

    if {$base == "."} {
        set base ""
    }
    button $base.but31 \
        -activebackground gray86 -activeforeground black \
        -background lightgray \
        -command {$widget(text:log) insert end "[exec ps]\n"
$widget(text:log) yview moveto 1} \
        -cursor fleur -font -*-helvetica-medium-r-normal-*-14-*-*-*-*-*-*-* \
        -foreground black -highlightbackground lightgray -padx 13 -pady 4 \
        -text {ps} 
    frame $base.cpd32 \
        -background lightgray -borderwidth 1 -cursor fleur -height 30 \
        -highlightbackground lightgray -relief raised -width 30 
    scrollbar $base.cpd32.01 \
        -activebackground gray86 -background lightgray -borderwidth 1 \
        -command {.top29.cpd32.03 xview} -highlightbackground lightgray \
        -orient horiz -troughcolor gray92 -width 10 
    scrollbar $base.cpd32.02 \
        -activebackground gray86 -background lightgray -borderwidth 1 \
        -command {.top29.cpd32.03 yview} -highlightbackground lightgray \
        -orient vert -troughcolor gray92 -width 10 
    text $base.cpd32.03 \
        -background gray95 -cursor fleur \
        -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-* \
        -foreground black -height 1 -highlightbackground lightgray \
        -insertbackground black -selectbackground lightblue \
        -selectborderwidth 0 -selectforeground black -width 8 \
        -xscrollcommand {.top29.cpd32.01 set} \
        -yscrollcommand {.top29.cpd32.02 set} 
    button $base.but33 \
        -activebackground gray86 -activeforeground black \
        -background lightgray -command {exit 0} -cursor fleur \
        -font -*-helvetica-medium-r-normal-*-14-*-*-*-*-*-*-* \
        -foreground black -highlightbackground lightgray -padx 13 -pady 4 \
        -text Quit 
    ###################
    # SETTING GEOMETRY
    ###################
    grid columnconf $base 0 -weight 1
    grid rowconf $base 0 -weight 1
    grid $base.but31 \
        -column 0 -row 1 -columnspan 1 -rowspan 1 -padx 5 -pady 2 -sticky w 
    grid $base.cpd32 \
        -column 0 -row 0 -columnspan 2 -rowspan 1 -sticky nesw 
    grid columnconf $base.cpd32 0 -weight 1
    grid rowconf $base.cpd32 0 -weight 1
    grid $base.cpd32.01 \
        -column 0 -row 1 -columnspan 1 -rowspan 1 -sticky ew 
    grid $base.cpd32.02 \
        -column 1 -row 0 -columnspan 1 -rowspan 1 -sticky ns 
    grid $base.cpd32.03 \
        -column 0 -row 0 -columnspan 1 -rowspan 1 -sticky nesw 
    grid $base.but33 \
        -column 1 -row 1 -columnspan 1 -rowspan 1 -padx 5 -pady 2 
}

Window show .
Window show .top29

main $argc $argv
------------------------------END OF DEMO SCRIPT--------------------------------


-- 
| Clemens Hintze * ACB/EO   ____   OMC-R Software Developement
| Phone: +49 30 7002-3241   \  /   ALCATEL Mobile Communication Division ITD
| Fax  : +49 30 7002-3851    \/    Colditzstr. 34-36, D-12099 Berlin, Germany
|            mailto:[EMAIL PROTECTED]

Reply via email to