origin of error message

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gordon

    origin of error message

    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=Fil eSelectBox(self .imgSelectFrame )
    ....

    def button1Click(se lf):
    starttime=datet ime.now()
    self.okButton.c onfigure(state= DISABLED)

    #will clear canvas
    self.canvorig.d elete(ALL)
    self.canvresult .delete(ALL)
    self.resultdisp lay.delete(ALL)

    #image file selection by tix widget
    self.cursel=sel f.imgsel.select ion.cget("value ")
    print "self.cursel:", self.cursel
    self.imgsel.sel ection.selectio n_clear()
    #here i want to check if anything is selected by user
    if self.cursel:
    ext=split(basen ame(self.cursel ),'.')[1]
    print "image extn:",ext
    try:

    self.selimg=Ima geTk.PhotoImage (file=self.curs el)
    except Exception,inst:
    print "xceptn::",inst .message
    self.showresult (inst.message," red")
    else:

    self.selimgtag= self.canvorig.c reate_image(70, 100,image=self. selimg)
    self.canvorig.u pdate_idletasks ()

    .....
    # some other tasks done
    .....

    else:
    #no file was selected by user
    print "self.cursel=", self.cursel
    self.showresult ("nothing selected","red" )

    self.okButton.c onfigure(state= NORMAL)
    endtime=datetim e.now()
    print "total time:", endtime-starttime,"seco nds"

    <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.Attr ibuteError: "PhotoImage instance has no
    attribute '_Pho
    toImage__photo' " in <bound method PhotoImage.__de l__ of
    <ImageTk.PhotoI mage inst
    ance at 0x00DA4F08>igno red


    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.Attr ibuteError: 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
Working...