origin of error message
gordon
nodrogbrown at gmail.com
Fri Jul 4 09:10:21 EDT 2008
hi
i was trying to create an image using user selection of a file in tix
fileselection box ..and i check for exception like below
<start of code snippet>
...
from string import split
from os.path import basename
...
#this is done inside __init__method
self.imgsel=FileSelectBox(self.imgSelectFrame)
...
def button1Click(self):
starttime=datetime.now()
self.okButton.configure(state=DISABLED)
#will clear canvas
self.canvorig.delete(ALL)
self.canvresult.delete(ALL)
self.resultdisplay.delete(ALL)
#image file selection by tix widget
self.cursel=self.imgsel.selection.cget("value")
print "self.cursel:",self.cursel
self.imgsel.selection.selection_clear()
#here i want to check if anything is selected by user
if self.cursel:
ext=split(basename(self.cursel),'.')[1]
print "image extn:",ext
try:
self.selimg=ImageTk.PhotoImage(file=self.cursel)
except Exception,inst:
print "xceptn::",inst.message
self.showresult(inst.message,"red")
else:
self.selimgtag=self.canvorig.create_image(70,100,image=self.selimg)
self.canvorig.update_idletasks()
.....
# some other tasks done
.....
else:
#no file was selected by user
print "self.cursel=",self.cursel
self.showresult("nothing selected","red")
self.okButton.configure(state=NORMAL)
endtime=datetime.now()
print "total time:", endtime-starttime,"seconds"
<end of code snippet>
user is supposed to select an image to be displayed.
when i select some file with a non compatible extension (say .zip)
i get the following output
>>>>
self.cursel: F:/docs/python/gui3.zip
image extn: zip
xceptn:: cannot identify image file
total time: 0:00:00.341000 seconds
Exception exceptions.AttributeError: "PhotoImage instance has no
attribute '_Pho
toImage__photo'" in <bound method PhotoImage.__del__ of
<ImageTk.PhotoImage inst
ance at 0x00DA4F08>> ignored
My belief was that the message
'total time: 0:00:00.341000 seconds '
should have been the last output message .I don't know where the
Exception exceptions.AttributeError: etc comes from. Already i am
catching the exception when creating PhotoImage .The message 'xceptn::
cannot identify image file' comes from there
Can someone help me find how this error msg happens
gordon
More information about the Python-list
mailing list