global name is not defined - but this is actually a function's name

Mridula Ramesh mridula.ccpl at
Fri Sep 21 07:59:52 CEST 2007


i'm a beginner and i'm trying to get the hang of classes and functions. my
code looks like this:

class showRecord(main):
    def __init__(self):
        global gmax
        #now to create the screen by placing all the widgets
        rt = Tk()
        #call the scroller to DoSomething

    def showbuttons(self):
        # NAVIGATION BAR------
        NavBut1 = Button(rt, text="|<", width=6, height=2,
bg="DarkSeaGreen", fg="Black")
        NavBut1.grid(row=10, column=20, padx=6, pady=6, columnspan=3)
        NavBut2 = Button(rt, text="<<", width=6, height=2,
bg="DarkSeaGreen", fg="Black")
        NavBut2.grid(row=10, column=25, padx=6, pady=6, columnspan=3)
        #widget bindings
        NavBut2.bind('<Button-1>', lambda e:GoPrev(ctr))

my problem is at the 6th line: showbuttons()
the error says "global name "showbuttons" is not defined.... but it's not a
global variable. what am i doing wrong?

also, should i say ...

def showbuttons(self):
def showbuttons(self, showRecord):

thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list