Re: New to this tcl lark... Why won't the exec do what I want?
- From: Jonathan Bromley <jonathan.bromley@xxxxxxxxxxxxx>
- Date: Mon, 22 Oct 2007 14:06:51 +0100
On Mon, 22 Oct 2007 05:49:09 -0700, yonorri <yonorri@xxxxxxxxxxxxxx>
wrote:
The following nearly does what I want it to do, except that the exec
part of the button -command only ever packs as the last option in the
servers list, so in this case all four buttons display the correct
server name but only ever run 'DCV3.nxs'
It's actually worse than that....
[snip initialization gunk]
foreach {server} $servers {
button .mF.[string tolower $server] -text $server \
-width 20 -font $font1 -bg #8fb3d9 \
-activebackground #334a73 \
so far so good, although it might be a neat idea to capture the
result of the [button] command for later use in the [pack] so
you don't need to recompute its name
-command {exec /usr/NX/bin/nxclient \
--session /home/mnorris/.nx/config/$server.nxs &}
Ahah! The culprit! The whole [exec] command is in braces, so
$server goes into the exec string LITERALLY, and isn't substituted
until you push the button some time later. By this stage, $server
contains the value from its very last trip around the loop.
In fact you've lucked-out because you're doing this at the top
level of your script, so 'server' is global; if you had
built the GUI in a proc, as you surely will in due course,
then 'server' would have been local to that proc, and
nonexistent at the future time when the [exec] gets to run.
Consider building your [exec] command using the [list]
command instead:
-command [list exec /usr/kruft --session /kruft/$server.nxs &]
Now your $server gets substituted by the [list] command, and
each button gets the appropriate -command value.
hth
--
Jonathan Bromley, Consultant
DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@xxxxxxxxxxxxx
http://www.MYCOMPANY.com
The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
.
- Follow-Ups:
- Re: New to this tcl lark... Why won't the exec do what I want?
- From: Jonathan Bromley
- Re: New to this tcl lark... Why won't the exec do what I want?
- References:
- Prev by Date: Re: New to this tcl lark... Why won't the exec do what I want?
- Next by Date: Re: New to this tcl lark... Why won't the exec do what I want?
- Previous by thread: Re: New to this tcl lark... Why won't the exec do what I want?
- Next by thread: Re: New to this tcl lark... Why won't the exec do what I want?
- Index(es):
Relevant Pages
|