importing class

gmarkowsky at gmail.com gmarkowsky at gmail.com
Fri Oct 27 12:22:00 EDT 2006


Hi all,

I'm trying to import a class from a module. The class looks like this:
class App:

    def __init__(self, master):

        frame = Frame(master)
        frame.pack()

        self.button = Button(frame, text=text_1, command= self.comm_1)
        self.button.pack(side=LEFT)

        self.hi_there = Button(frame, text=text_2, command=self.comm_2)
        self.hi_there.pack(side=LEFT)

    def comm_1(self):
        command1()
        root.quit()

    def comm_2(self):
        command2()
        root.quit()

It's supposed to just make a Tkinter window with two choices. The
problem is that when I import it from a module, I get the following
error:

NameError: global name 'Frame' is not defined

But when I copy and paste it into the file, it works. Can anyone tell
me what's wrong?

Greg




More information about the Python-list mailing list