Simplest Form edit
pack [text .text] set result [exec my_command] .text insert 1.0 $result
Can someone show us what is needed to do things like add scrollbars that get displayed if the text is bigger than the text widget's display, as well as perhaps some key bindings to scroll back and forth?Here's what I am trying - but it doesn't display anything...
#! /usr/tcl84/bin/tclsh # Needed: # 1. scrollbar # 2. exit button or binding package require Tk package require BWidget set b [ScrolledWindow .base -auto both] pack $b text $b.text pack $b.text set result [exec cat $argv] $b.text insert 1.0 $result puts "Done"
See documentation on exec for information about how to pass in command-line arguments and "stdin" data.[Is there no comparably reduced example already in the Wiki?]
If the process is a long running process, this will lock up your GUI. Checkout the fileevent page to see how to run the command with open & just get updates as they are available. (Change the line puts "got: $line" to .text insert end $line and possibly add a .text see end)bbh
What about a tk app that talks to a running tcl app in a separate process - is there an example that shows doing this?Well, yes, although perhaps it's not obviously labeled that way yet. "Inventory of IPC methods" aims to point to all the ways to get two such processes in communication.
See also tailf and Tailing widget.