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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem in using Tk and Tclx package

Status
Not open for further replies.

mkanna

Programmer
Jun 16, 2009
6
US
Hi,

I have written small TCL script. One of the procedure is used to invoke TK window and another procedure use keylist. And so I have used "package require Tk" and "package require Tclx" on my main TCL script. I'm facing an issue in using above packages.

1. If I use the Tclx package then Tk procedure is not working, it doesn't show the message in Tk window.

2. If I don't use Tclx package, tk window shows the message but the other procedure which uses keylist is not working.

Here is my script,

#!/usr/bin/wish

package require Tcl
package require Tk
package require Tclx
package require Expect

set env(tag_dir) "/opt"

source [file join $env(tag_dir) local lib controllerAp.lib]
source [file join $env(tag_dir) local lib contr_cli_cmd.lib]

proc tk_CCX_DevConfig {txt} {

label .l1 -text $txt
button .b1 -text "Ok" -command "destroy ."
grid .l1 -row 2
grid .b1 -row 4 -column 0

}
...
...

# Call the above TK procedure

if [catch {tk_CCX_DevConfig "Plz configure Dev"} err] {
puts "Error in invoking Input Gui"
}

puts "User configuration is completed"

# Call another procedure that uses keylist

if [catch {devConnect "192.168.100.1"} err] {
puts "Error in connecting device which use keylist"
}
....
....

Any suggestions ?

- Kanna
 
I never use TCLx and I don't know what a keylist is. Can you elaborate what you're trying to accomplish?

_________________
Bob Rashkin
 
Hi Rob,

My mistake. It was typo error. Actually, its 'keyed list'. Basically, keyed list is a list in which each element contains a key and value pair.


I'm trying use the keyed list command - keylget and keylset and it requires Tclx package.

- Kanna
 
I'm not sure why you would want to use Tclx. I see in the help that there are "keyed list" functions but I had thought Tclx was for C extensions. Anyway, if all you want to do is read a KEY-VALUE pair from a file, I think vanilla Tcl will do just fine.
So let's say you have a list (you've already read the data) of these pairs. I imagine there is a separator, let's say "=":
{a=4 b=5 c=6}

I imagine you want to define a variable for each element and assign the value given to that variable:
Code:
% foreach e $l {
  set l2 [split $e =]
  eval {set [lindex $l2 0] [lindex $l2 1]}
}
% set a
4
% set b
5
% set c
6
%
You can actually shorten the statements in the foreach loop but the steps would become pretty abstruse.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top