Can someone tell me, is it possible to use expect and/or file handles to execute a command line based sub-program, such that whenever the sub-program needs user input, it can be entered in a pop-up tk entry box, and passed back to the sub program?
Yes, it is possible, and using Expect or fileevent handlers would be the way you could accomplish that. In practice, I'd use Expect if possible, as it handles some buffering issues that can otherwise cause serious problems in many cases. The actual implementation is very dependent on what program you're trying to drive using Tcl.
Another approach would be to present the equivalent of a console window for your application. In his book Practical Programming in Tcl and Tk, 3rd ed., Brent Welch builds a simple version of such a console using the Text widget. See pages 327-332 for information. Also, many people use Jeff Hobbs's TkCon application (which is written as a full-featured Tcl shell window for Tcl development and debugging) as a basis for their own interactive consoles. You can download TkCon from the Tcl Developer Xchange,
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.