| View previous topic :: View next topic |
| Author |
Message |
logitech Voice
Joined: 30 Apr 2008 Posts: 3
|
Posted: Wed Apr 30, 2008 6:23 am Post subject: Beginner Help for using TK |
|
|
I am a beginner to TCL programming and I'm facing a problem with using the "wish" command from within a file, though the same command works perfectly in the tclsh prompt.
The following commands in the TCL command prompt ( invoked with the tclsh command) work and a new frame is created.
---
% wish
% frame .mv_ex
wm title . "Title"
pack .mv_ex
--
When written in a file "trial.tcl", the wish command doesn't seem to work and returns an error.
Contents of the file "trial.tcl"
--
#!/usr/bin/wish -f
frame .mv_ex
wm title . "Animation in canvas"
pack .mv_ex
---
Error returned when "trial.tcl" is executed.
--
tclsh trial.tcl
invalid command name "frame"
while executing
"frame .mv_ex"
(file "trial.tcl" line 3)
---
Please help!! Thanks in advance.  |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Apr 30, 2008 6:28 am Post subject: |
|
|
wish is a tcl/tk shell, whereas tclsh is a tcl shell... the difference is the Tk-extensions, which is basically a graphical interface API.
Much simplified, Tk-commands won't work in tclsh...
Edit:
Might add, wish is not a tcl command, but a separate interpreter. When you type "wish" in tclsh, tcl simply forks a child and executes the external application wish within here. Hence, any further text written on stdin is directed to wish, rather than tclsh. When scripting however, the whole script is executed in tclsh...
Solution: if you wish to develop Tk-tclets, use wish, not tclsh.. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
logitech Voice
Joined: 30 Apr 2008 Posts: 3
|
Posted: Wed Apr 30, 2008 8:56 am Post subject: @nml375 |
|
|
Thanks!
But do you know how to use wish from within a file, so that the file containing Tk -commands executes on a tclsh shell?[/quote] |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Apr 30, 2008 10:38 am Post subject: |
|
|
Yes, use wish, not tclsh.
wish can take a script-file as argument just like tclsh does...
You'll have to accept that whenever you're using tclsh, you can't have any fancy GUI or other graphics - just print text on stdout. If you want X11/Xwin/etc graphics, use the wish interpreter... _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
logitech Voice
Joined: 30 Apr 2008 Posts: 3
|
Posted: Thu May 01, 2008 12:14 pm Post subject: re |
|
|
oh fine... got it now... thanks a lot,,,  |
|
| Back to top |
|
 |
|