[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tk and ns



On Wed, 7 Apr 1999, John Heidemann wrote:

> On Tue, 06 Apr 1999 23:20:00 EDT, Juana Elias Nakfour wrote: 
> >Hi everyone,
> >
> >	I am trying simply to use Tk commands in a tcl file and running it 
> >under ns. Just inorder to create A graphical interface for my simulations.
> >I want something more then nam can offer. 

Well, nam is really daisy-chained on the end of the line; it only
works on completed tracefiles that ns has created.

Similarly, ns only operates on completed script files to build the
tracefiles; you could extend the daisychain by building a Tcl/Tk
application that generated these script files and then executed them
via ns, or, better, created datafiles or wrote scriptfiles and passed
them as parameters to an ns otcl program for it to load or source,
e.g. via something like: 

exec ns meniscus.tcl data/iridium66.tcl traffic/simplemcast1.tcl

or 

exec ns meniscus.tcl iridium66-param simplemcast-param

(I actually prefer the first method; more of a hack, but much more
 open-ended. I'm lazy, too.)

This is messy, not very integrated, requires a lot of duplication of
effort, and is no good for changing network parameters on the fly,
say - but it can be made to work, and since you can expect people who
have installed ns and nam to have Tcl and Tk, you can expect your
Tcl/Tk application to work under their envivronment.


> >I type in something like:
> >-------------------
> >button .text -text Hello -command {puts "Hello, World"}
> >pack .hello -padx 10 -pady 10

In any case, that should be:

button .text -text Hello -command {puts "Hello, World"}
pack .text -padx 10 -pady 10
     ^^^^^

> >somewhere in my tcl file then I run : ns file.tcl
> >I get the following:
> >
> >--------------------
> >invalid command name "button"
> >    while executing
> >"button .hello -text Hello\
> >        -command {puts stdout "Hello, World!"}"
> >    (file "wlan.tcl" line 229)
> >-----------------------------
> >
> >at the ns prompt I type:
> > % man button
> >
> >and it will give me a whole description of what the command button does.
> >I don't understand why ns can give me a man page on button 

The same way '% ls' gives you a directory listing. The man unix
command, like the ls command, is on your path, and ns knows your path.
'% netscape' should be the giveaway here; ns doesn't include netscape...


> >and yet I
> >cannot use it. Should I include something in my tcl file. Thanks in
> >advance. (I am using Solaris and ns-2.1b5)
> 
> Ns doesn't include Tk so your approach won't work.

It doesn't? Hmmm, last I looked the ns configure (1.6.3) included
Tk-relevant stuff like:

ac_help="$ac_help
--with-tk=path  specify a pathname for tk"
ac_help="$ac_help
--with-tk-ver=path specify the version of tcl/tk"

and the Makefile has a lot of tk stuff in it - ns won't build without
it.  And all of this Tk stuff doesn't do anything?


> You might be able to dynamically load it, but that might require
> Much Hacking.

Being able to utilise Tk from within otcl to build ns gui frontends
easily strikes me as a Major Useful Win - although since Tk doesn't
have a decent tty fallthrough (unlike say lucid xemacs -nw) you're
suddenly graphical displays only on those scripts; implementing
alternate tty-only interfaces and integrating them looks messy. 

An alternative approach is suggested by recent changes
to ns:    
 
http://www-mash.cs.berkeley.edu/ns/CHANGES.html
[johnh] Wed Mar 31 13:51:35 PST 1999
       Ns now knows where the tclsh is that autoconf finds, just like
       it knows about perl.
 
       The proper way to invoke a tclsh program from within ns is {
       global TCLSH; exec $TCLSH path/to/script.tcl args; }.

If ns knew where wish was, you could:

{global WISH; exec $WISH path/to/tkscript.tcl args; }

and exec some sort of tcl/Tk gui from the otcl script - although
passing information back is rather messed up, and this is
somewhat suboptimal. 

Oh, it's incr tcl/tk that is really great with Tk. Damn.
http://www.tcltk.com/itcl/

L.

has just discovered that 'exi' quits ns too. No t?

<[email protected]>PGP<http://www.ee.surrey.ac.uk/Personal/L.Wood/>