Function calling problem

Colin J. Williams cjw at connection.com
Tue Aug 31 15:03:16 CEST 1999


I've made a couple of changes.  I hope this helps.

Colin W.

'''
From:
          rainer2207 at my-deja.com

Sun 5:57 AM

  Subject:
          Function calling problem




Can someone please explain what's wrong with this code? I've tried to
call the function quit(self) but I get an error. What's wrong here?
'''

from Tkinter import *
import sys, Dialog

class Interface:


        def __init__(self, master):

                self.menu = Menu(master, tearoff=0, name="menu")
                master.configure(menu=self.menu)

                self.frame = Frame(master, width="15c", height="10c",
bd=2, relief="sunken")
                self.frame.pack(fill="both", expand=1)

                m = Menu(self.menu, tearoff=0)
                self.menu.add_cascade(label="File", menu=m, underline=0)

                n = Menu(m, tearoff=0)
                m.add_cascade(label="New", menu=n, underline=0)
                n.add_command(label="RDF Schema", underline=4)
                n.add_command(label="RDF Metadata", underline=4)

                o = Menu(m, tearoff=0)
                m.add_cascade(label="Open", menu=n, underline=0)
                o.add_command(label="RDF Schema", underline=5)
                o.add_command(label="RDF Metadata", underline=5,
                   command=self.open)

                m.add_command(label="Save", underline=0)
                m.add_command(label="Save As...", underline=5)
                m.add_command(label="Close", underline=0)
                m.add_separator()
                m.add_command(label="Exit", underline=0,
                  command=self.quit)

                m = Menu(m, tearoff=0)
                self.menu.add_cascade(label="Edit", menu=m, underline=0)
                m.add_command(label="Cut", underline=2)
                m.add_command(label="Copy", underline=0)
                m.add_command(label="Paste", underline=0)

                m = Menu(m, tearoff=0)
                self.menu.add_cascade(label="Help", menu=m, underline=0)
                a = Menu(m, tearoff=0)
                m.add_command(label="About", underline=0)

        def quit(self):
                print 'Exit'
                root.destroy()                                     #
*************
                sys.exit(0)

        def open(self):                                            #
************
          print 'What is this supposed to do?'

root = Tk()
inter = Interface(root)
root.title("Title")
root.mainloop()










More information about the Python-list mailing list