egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Beginner Help for using TK

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
logitech
Voice


Joined: 30 Apr 2008
Posts: 3

PostPosted: Wed Apr 30, 2008 6:23 am    Post subject: Beginner Help for using TK Reply with quote

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. Smile
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Apr 30, 2008 6:28 am    Post subject: Reply with quote

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
View user's profile Send private message
logitech
Voice


Joined: 30 Apr 2008
Posts: 3

PostPosted: Wed Apr 30, 2008 8:56 am    Post subject: @nml375 Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Apr 30, 2008 10:38 am    Post subject: Reply with quote

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
View user's profile Send private message
logitech
Voice


Joined: 30 Apr 2008
Posts: 3

PostPosted: Thu May 01, 2008 12:14 pm    Post subject: re Reply with quote

oh fine... got it now... thanks a lot,,, Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber