Stumped by PhotoImage issue

Joe joekm at earthlink.net
Tue Feb 26 19:22:11 CET 2002


I've actually seen that there are others with a similar problem that
have posted on the web.  I've read G.R's FAQ and looked at the
solutions others have used but I am still confused.....

In a program that I am writing, I have an "about" dialog box that is
written as a class that is in turned called from the "help : about"
pulldown menu item in my "menubar" class.  This "about" dialog has
three .gif images that are handled by PhotoImage.  The problem is that
they appear to be displaying transparant.

Now, if I pull the class out of my main program and wrap a minimalist
mainloop around it, everything works fine.  Also, if I intentionally
put an error in the part of the class that draws the button, the gif's
are drawn without a problem (but I get an error message and the button
does not draw).  

I've tried setting instance variables, global variables, etc. and I'm
running out of ideas.  Any suggestions would be appreciated.  Just so
you know, this is my first original python program and my first real
intro into object oriented programming.  OTOH, I have read everything
I could download and purchased a couple of books on the subject
including "Python and Tkinter Programming".

..and no, I do not wish to use PMW at this time, I wish to gain
experience with Tkinter first.

The class follows (needs to be un-word-wrapped):

class About:

    def __init__(self, parent, GraphicsPath):

        self.parent = parent

        self.deltaLogo = PhotoImage(file=GraphicsPath+'DeltaLogo.gif')
        self.pythonLogo =
PhotoImage(file=GraphicsPath+'PythonPowered.gif')
        self.tkLogo = PhotoImage(file=GraphicsPath+'TCL-TK_logo.gif')

        AboutDialog = Toplevel(self.parent, relief=RAISED,
borderwidth=3)
        AboutDialog.geometry('+300+150')
        AboutDialog.overrideredirect(1)
        AboutDialog.tkraise()
        self.AboutBorder = Frame(AboutDialog, relief=GROOVE,
borderwidth=2)

        title = Label(self.AboutBorder, text='Simple Airframe Fracture
Evaluation Tool [SAFE-T]',
                             font=('Ariel', 11, 'bold'))
        title.pack(side=TOP, padx=2, pady=5)
        
        global Revision_Type, Revision
        version = Label(self.AboutBorder, text=Revision_Type+'
'+Revision)
        version.pack(pady=5)
        
        copyright1 = Label(self.AboutBorder, text='Copyright 200X by
Joseph K. Mooney and')
        copyright1.pack(pady=5)

        self.delta = Label(self.AboutBorder, image=self.deltaLogo)
        self.delta.pack() 

        copyright2 = Label(self.AboutBorder, text='ALL RIGHTS
RESERVED\nSee License Agreement for Further Information\n')
        copyright2.pack()
        
        description = Label(self.AboutBorder, text="Programed in
PYTHON - GUI  built with Tkinter")
        description.pack(pady=8)

        self.python = Label(self.AboutBorder, image=self.pythonLogo)
        self.python.pack(side=LEFT) 

        self.tclTk = Label(self.AboutBorder, image=self.tkLogo)
        self.tclTk.pack(side=RIGHT) 

        self.AboutBorder.pack(fill=X, expand=YES)

        self.OK = Button(self.AboutBorder, text='OK', font=('Arial',
9, 'bold'), command=AboutDialog.destroy)
        self.OK.place(relx=.48, rely=.8, anchor=NW)
#



More information about the Python-list mailing list