Apps :: tcl



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)

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

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?

"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.

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.

Next Page...
original here.