Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

assigning STDIN/STOUT to a widget

Status
Not open for further replies.

Bong

Programmer
Dec 22, 1999
2,063
US
I know this can be done because Tkcon and ASED seem to do it. Never the less, I seem to be too thick to figure out how they do it.

Nevermind that it's a silly idea; that I should just use entry and label widgets, now I'm intrigued. The purpose is to have only a small proc that does a little dialog to get some data. For example, I have a program that reads a certain kind of file of data and does some math. I want a secret binding that allows me to build a data file (say, rightClick in a certain window). Then I don't want to have a whole big deal of widgets and geometry. I just want to take an existing text box and use it as STDIN/STDOUT to input variables (as if I were in a Tcl shell instead of a Tk shell).

Can it be done?

Bob Rashkin
rrashkin@csc.com
 
Why not simply a text box and a button to append the content of the text box in a predetermined file and then destroy the two widgets?

HTH

ulis
 
Well, that's what I do now (only with a mouse button instead of a button widget). I thought it would be fun to have a shell-like dialog instead (like old days BASIC).

Bob Rashkin
rrashkin@csc.com
 
Although I've not dived through all of its code, I'm fairly sure that TkCon works by creating a slave interpreter to run the application, while the main interpreter handles driving the console window. The main interpreter defines some aliases in the slave interpreter that intercept stdio channels and funnel all that interaction to the console. This technique is demonstrated in Practical Programming in Tcl and Tk, 3rd ed. in Chapter 22, starting on page 327.

- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting, 866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
You caught me! I'm still hanging on to the first edition. I guess I'll have to break down and catch up.

Bob Rashkin
rrashkin@csc.com
 
Thanks to all. It turns out all I really wanted was the "console show" and "console hide" commands.

Bob Rashkin
rrashkin@csc.com
 
Well, if you're going to break down and buy a newer version of Practical Programming, I'd advise that you wait just a couple more months. I'm currently in the process of helping Brent write the 4th edition, and we expect to see it hit the streets in June. :)

- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting, 866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Sounds like a plan.[thumbsup]

Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top