How to run TCL/TK script in April?

Booting, installing, newbie
Post Reply
Message
Author
AustinGreen
Posts: 7
Joined: Sat 31 Oct 2015, 02:35

How to run TCL/TK script in April?

#1 Post by AustinGreen »

Just installed Quirky April and trying to run TCL/TK script.
Plain TCL works OK, but TK gives this error:

Code: Select all

invalid command name "errorInfo"
My test script contains:

Code: Select all

#!/usr/bin/tclsh
grid [ttk::button .mybutton -text "Hello there, World."]

WillM
Posts: 173
Joined: Wed 30 Dec 2009, 04:42
Location: Oakland, California

#2 Post by WillM »

Hi AustinGreen,

From reading through the man pages, you need to tell your script that it requires Tk, so you script should look like this.

Code: Select all

#!/usr/bin/tclsh

package require Tk

grid [ttk::button .mybutton -text "Hello there, World."] 

AustinGreen
Posts: 7
Joined: Sat 31 Oct 2015, 02:35

#3 Post by AustinGreen »

Thanks WillM for not saying just 'RTFM' :)

I'm trying to learn TCL/TK and I got the example from a tutorial. It ran fine on other platforms (both Linux and Windows) so assumed - wrongly - that it was a Puppy problem. More a config difference by the looks; the other platforms must have built-in loading of TK for all TCL scripts.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#4 Post by L18L »

Hi AustinGreen,

can you give an example of
Plain TCL works OK
?

Does your TK continue giving
invalid command name "errorInfo"
after following WillM's hint?

Which version of Quirky April are you running?

Just curious...

EDIT
... because this is what my tclsh does:

Code: Select all

 # tclsh
invalid command name "errorInfo"
Welcome to Jim version 0.70, Copyright (c) 2005-8 Salvatore Sanfilippo
. 
. 

AustinGreen
Posts: 7
Joined: Sat 31 Oct 2015, 02:35

#5 Post by AustinGreen »

By 'plain TCL works OK' I mean that a script containing

Code: Select all

puts "hello world"
works without any error messages.

I should have done more testing before my earlier posts! :)
Running 'tclsh' does indeed give that error message on start-up.
It does it on Precise Puppy as well as Quirky.

The inclusion of 'package require Tk' did not fix the problem, in fact any mention of 'package' immediately brings forth that same error message.

On Precise Puppy I was able to make it all work by installing tk_8.5.1 which provides the 'wish' command. Using that instead of tclsh makes everything behave properly. Unfortunately on Quirky that package is not available. Tried to configure the package manager, but I can't fathom out how to add repositories, and/or I don't know which repos to add. So this has become an entirely new question - perhaps I should repost?

AustinGreen
Posts: 7
Joined: Sat 31 Oct 2015, 02:35

SOLVED

#6 Post by AustinGreen »

In case anyone else is having similar troubles, after some experimentation I have solved it as described below. This worked for Quirky 7 April, the latest version I believe.

Removed package jimtcl.
Downloaded packages from http://archive.ubuntu.com/ubuntu/pool/main/t/
... from tcl8.6/, libtcl8.6_8.6.4+dfsg-2ubuntu1_i386.deb and tcl8.6_8.6.4+dfsg-2ubuntu1_i386.deb,
... from tk8.6/, libtk8.6_8.6.4+dfsg-2ubuntu1_i386.deb and tk8.6_8.6.4+dfsg-2ubuntu1_i386.deb.
Installed the packages by clicking on the .deb files.

Code: Select all

# export LD_LIBRARY_PATH=/usr/lib/i386-linux-gnu
# ln -s /usr/bin/tclsh8.6 /usr/bin/tclsh
# ln -s /usr/bin/wish8.6 /usr/bin/wish
Edited ~/.bashrc to include the above command that sets LD_LIBRARY_PATH.

Now commands 'tclsh' and 'wish' start without error, and run TCL scripts successfully.

Post Reply