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

Mridula Ramesh mridula.ccpl at gmail.com
Fri Sep 21 01:59:52 EDT 2007


hi.

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


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

    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))
</code>


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):
or
def showbuttons(self, showRecord):

thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070921/49ff1ab8/attachment.html>


More information about the Python-list mailing list