Calling function from another module

craf prog at vtr.net
Wed Dec 15 19:46:38 EST 2010


Hi.

The query code is as follows:

------------------------------------------------------
import Tkinter
import tkMessageBox


class App:
    def __init__(self, master):
        master.protocol("WM_DELETE_WINDOW",quit)


def quit():
    if tkMessageBox.askyesno('','Exit'):
        master.quit()


master =Tkinter.Tk()
app = App(master)
master.mainloop()
-------------------------------------------------------

As you can see, when I run and close the main window displays
a text box asking if you want to quit, if so, closes
application.

Question:

Is it possible to define the quit() function in another separate
module?.
I tried it, but it throws the error that the global name
'master' is not defined.

Thanks in advance.

Regards

Cristian Abarzúa







More information about the Python-list mailing list