tcl


Forum: Programming and Scripting
Topic: tcl
started by: jpeters

Posted by jpeters on April 30 2006,17:53
I get a lot of errors trying to install tcl library files (widgets, etc) from MyDsl, and can't find much relevant documentation on getting it up and running. I've tried installing tcl files from site outside DSL, but was not allowed to configure due to what looks like compatibility problems. I'm interested in rewritting some windows apps written in Boreland that I can run in linux, and was hoping tcl might be the right environmnent.
Posted by mikshaw on April 30 2006,19:00
All of the widgets available from myDSL should work with the tcl/tk 8.4 uci extension.  They haven't been tested with the tcl/tk 8.3 extension, and will probably not work without tweaking some environment variables.  The uci and widgets were built to run from /opt/tcltk-8.4, and the 8.3 version was not.

As for installing widgets that are not currently available from myDSL, I couldn't say how you'd do it.  The tcl/tk extension was packaged without the includes, so it probably works only for pre-compiled widgets.  If you get precompiled widgets from a source other than myDSL, you will probably need to set up your environment to tell them where Tcl is.

Posted by jpeters on April 30 2006,19:42
I get checksum errors when attempting to install tcl library packages from MyDsl.

"All of the widgets available from myDSL should work with the tcl/tk 8.4 uci extension"

I just found 8.4 under UCI.  I'll try that.  Thanks

Posted by mikshaw on April 30 2006,20:28
As far as I know, the checksum errors are unrelated to software compatibilty, but instead have something to do with a failed download.  I don't know if it is an issue with the ibiblio server, or with wget, or with your internet connection, but the error seems to be fairly common with the myDSL gui. You might try downloading with a web browser, ftp client, or using wget directly so you can make sure that the download actually completes.
Posted by jpeters on May 01 2006,05:08
No problem with the tcl console, but Tk doesn't appear to be loaded. I'm looking at a tutorial:


#! /usr/local/bin/wish8.1
button .hello -text "Hello, World!" -command { exit }
pack .hello
tkwait window .
_
wish8.4 is in /opt/tcltk-8.4/bin/wish8.4. , and if I substitute this path, I get a window telling me that Tk isn't loaded.

I noted the info file in MyDsl stated that the $PATH variable needs to be set to the /opt/...   path. I'm guessing there's someplace to do this, or does the PATH variable need to be set in the code?  Thanks

Posted by mikshaw on May 01 2006,13:05
The PATH variable, as well as any other environment variable, can be set from anywhere.  Typically if you just need the change applied to the current shell you'd set and/or export the variable from the shell (in bash: export PATH="/opt/tcltk-8.4/bin:$PATH") and then start the application from that same shell.  This is one thing a shell wrapper will do, automating the task.  
If it's a change that you will need to make permanently, the typical location would be /home/dsl/.bash_profile for your user, or /etc/profile for all users.  .bashrc can be used instead of .bash_profile, but the new path will be added to $PATH every time you open a new shell. If you never use the console you could export it from .xinitrc instead, which would mean having only to restart X rather than drop to console, source .bash_profile, and then restart X.

Once wish is in your path, you will still need to modify the script, because it calls /usr/local/bin/wish8.1 specifically.  One common way to avoid this problem is to start the script with this instead:
Code Sample
#!/bin/sh
#\
exec wish "$0" "$@"
Note the commented backslash...this is vital to allow bash to run exec, but to prevent it from being rerun in wish.

The tkcon menu item/icon sets the path for the consoles, which is why that works. I didn't include wrappers for Tcl because that would be an extra complication just to make things more convenient for the newbie.  I assumed that a person who is scripting would already be familiar with common tasks like setting envrironment variables =o)

Posted by jpeters on May 01 2006,15:49
1. I set the path in bash: export PATH="/opt/tcltk-8.4/bin:$PATH"
2. I attempt to load "wish":
 
#!/bin/sh
#\
exec wish "$0" "$@"

This results in the terminal window closing and nothing happening

I assumed that a person who is scripting would already be familiar with common tasks like setting envrironment variables =o)  LOL

Posted by mikshaw on May 01 2006,17:23
That example of loading wish will not work from the commandline, if that's what you tried.  It's meant to replace "#!/path/to/wish" at the start of a script.  What it's doing is running the script initially with /bin/sh. Then sh will run the script ("$0") and any commandline parameters ("$@") with wish.  It's kinda sloppy, but it's necessary because wish is often installed in places other than /bin or /usr/bin, and using just #!wish doesn't work.  It could also be done with #!/usr/bin/env wish, but that assumes env is always in /usr/bin.

Can you now get an empty Tk window by running the command "wish" from a terminal?

Posted by jpeters on May 01 2006,18:22
"Can you now get an empty Tk window by running the command "wish" from a terminal?"

Yes, both from the terminal and the console. When I now write:

"button .hello -text "Hello, World!" -command { exit }
pack .hello
tkwait window . "

I get an empty window with Tkcon #2 at the top. The path to .button.tcl is:
/opt/tcltk-8.4/standard_libs/tk8.4

I'm guessing I should be seeing a button with "Hello, World!" on it.

Posted by clacker on May 01 2006,19:09
I just tried this.  Loaded the tcltk-8.4.uci in the embeded version 2.3 of dsl and opened an xterminal.  Typed

export PATH=/opt/tcltk-8.4/bin:$PATH

then typed wish and used your example (without the surrounding quotes) in that same xterminal and it did make the button.

Posted by jpeters on May 01 2006,20:30
You must be doing something different than I am,  because typing "wish" followed by "button....." (without the quotes)   in the terminal window gets me an error about button not being a command.
Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.