[Tkinter-discuss] canvas.create_image
Todd Lericos
t.lericos at comcast.net
Thu Jun 30 06:50:44 CEST 2005
Hello all,
I'm new to the list and to Python. It has been tough going, but alot of
fun.
Here is my problem. I am trying to display an image on canvas. I was
searching to the list for similar problems. It does seem to be a common
problem. I tried many of the suggested fixes. For example, heading off
garbage collection of the image...etc. No dice.
Can someone take a look at the code and let me know if they see any
pitfalls I am stepping in.
Thanks in advance for any help rendered.
Todd
P.S. Please not the program in not complete yet. Thus some variables
passed to MakeGui go nowhere. I know this already.
#!/usr/local/python/bin/python
import os, sys, string
import pickle, time
from Tkinter import *
import Image
class MakeGui:
def __init__(self, tooltitle, filedir, filetype, plotelem, filelist):
self.row = 0
# Creating the Window and Row/Column stuff
self.root = root = Tk()
root.minsize(300,200)
root.rowconfigure(0, weight=1)
root.columnconfigure(0,weight=1)
root.columnconfigure(1,weight=2)
# Creating the Title Label
Label(root, text=tooltitle, font='bold').grid(columnspan=2)
self.row = self.row + 1
#Create the Canvas
self.tfile = filedir + 'image.' + filetype
print self.tfile
self.Image = PhotoImage(file = self.tfile)
self.canvas = Canvas(root, width=508, height=509)
self.canvas.create_image(250, 250, image = self.Image)
self.canvas.grid(columnspan=2)
self.row = self.row + 1
tooltitle = 'Lightning Climatology Viewer'
filedir = '/data/local/ltgdata/images/'
filetype = 'gif'
plotelem = ['500mb Map','Lightning Z','Lightning FWZ','Month Stats']
filelist =[("Type 1", "U01"),
("Type 2", "U02"),
("Type 3", "U03"),
("Type 4", "U04"),
("Type 5", "U05"),
("Type 6", "U06"),
("Type 7", "U07"),
("Type 8", "U08"),
("Type 9", "U09"),
("Type 10", "U10"),
("Type 11", "U11"),
("Type 12", "U12"),
("Type 13", "U13"),
]
MakeGui(tooltitle, filedir, filetype, plotelem, filelist)
mainloop()
More information about the Tkinter-discuss
mailing list