My question is listed here--Please help!!!

Hello,

I am trying to make a tcl/tk GUI front end for a python script which returns a figure. I am trying to display the figure in a frame and try as I might I cannot get this to work. I have tried reading the image/photo stuff and also tried to embed picture viewer into the frame with no avail. I can also (if absolutely need be) have the python script save the image to a temp file so tk can display it (would most likely be a png if we went that route). Please help! This has been an on going issue for me. Thank you!


Well, I have no idea about your specific application. However, it seems, to me, that a good place to start would be to write a basic Tcl/Tk program that reads a static image file and displays it. Once you have that program written, then at the very least you could have your python program write out a static image file and display it from your tcl/tk program.

To move along farther, you have to then make some decision on how to get the image data from the python program to the tcl/tk program in a fashion that could be displayed. A number of techniques for exchanging data between two processes are mentioned at inventory of ipc methods.


A simple example of what Larry mentioned above would be:

  • Download and install ActiveTcl (or build Tcl, Tk, and Img on your own).
  • Create your image and save it into a file, such as 'mypngimg.png. If your image is a .jpg, .tiff, .gif, or some other format, then you will need to change the image create line below. If your image is in some other format, check the information about Img to determine whether it provides the hooks for Tk to display that format.
  • Save the following lines to the file show_img.tcl.
package require Img
set myimage [image create photo -file mypngimg.png]
label .l1 -image $myimage
pack .l1
  • Run it from a shell prompt with
wish show_img.tcl

(or wish8.5.exe, depending on your platform).


That did it guys, thank you so much! you have no idea how long i've been messing around with that.


CMcC - 2009-07-08 10:25:53

I think it would be preferable to not create pages with titles like this, for purposes like this. It seems to me to be an importunate use of the commons and (personally) I wouldn't help anyone with a problem posed in this manner.