AttributeError: 'None' object has no attribute

phillip phillip at transwitch.co.za
Fri Jul 20 09:25:34 EDT 2001


Hi

I have the following code :

from Tkinter import *
import Image, ImageTk

class UI(Label):

    def __init__(self, master=None):
        
        im = Image.open('c:\\tm.gif')
        self.image = ImageTk.PhotoImage(im)
        Label.__init__(self, master, image=self.image, bd=0)

    def getSetupValues():
            return {'Name': 'Phillip'}

if __name__ == "__main__":
    
    root = Tk()
    root.geometry('800x600')
    root.title('Malaysian Web Site Installation')
    ui = UI(root).pack()
    root.leftFrame = Frame(width=400, height=600, bg='gray50',
relief=RAISED, bd=4)
    root.rightFrame = Frame(width=400, height=600, bg='gray50',
relief=RAISED, bd=4)
    setup = ui.getSetupValues()
    for eachKey in root.setup.keys():
        Label(root.leftFrame, text=eachKey, bg='gray50',
anchor=E).pack()
        Label(root.rightFrame, text=setup[eachKey], bg='gray50',
anchor=E).pack()
    root.rightFrame.pack(side=RIGHT)
    root.rightFrame.pack_propagate(0)
    root.leftFrame.pack(side=LEFT)
    root.leftFrame.pack_propagate(0)
    root.mainloop()

Everything is fine if i put the function in the __init__ function,
which is not a good idea, I want to keep the code compartmentilized
nicely.

any ideas?

Phill



More information about the Python-list mailing list