Hi, I have a piece of my code I want redistribute like tcl package, also there is 2 png images needed for this code. How can I access them from my code? Thank you.
arjen - 2011-10-03 07:34:23
Depending on the way you distribute your Tcl package (as source, as Tcl module or as starkit) you have several options. I will assume you have a Tcl source file and two PNG files in the same directory. Then put code like the following in the source file _outside of any procedure_:
# Get the images set dir [file dirname [info script]] set image1 [image create photo -file "$dir/image1.png"] set image2 [image create photo -file "$dir/image2.png"]
(When the file is being sourced, the command [info script] returns the full name - from that you can compute the name of other files in the same directory)
ZB Most probably there's a need to have single file - then one can use this images in encoded form. Use the tool mmencode (AKA mimencode), then insert in your script the code the way like this: