Hi.

According to this code....

------------------------------------------------------------------
import Tkinter


class App:
    def __init__(self, master):
        self.root = master
        self.b1 = Tkinter.Button(master)
        self.b1.pack()
        self.b1.bind('<Button-1>', lambda
e,widget=self:greeting(widget))
        self.root.protocol('WM_DELETE_WINDOW', lambda:((lambda e,
widget=self:greeting(widget))(self.root)))

def greeting(widget):
    widget.root.destroy()


master = Tkinter.Tk()
master.geometry('400x400')
app = App(master)
master.mainloop()
-------------------------------------------------------------------

I have access to the function (greeting) from the button and the window
close button.

It works fine, but wanted to know whether the use of lambda (lambda),
can be expressed in another way more elegant and less confusing.

Regards.

Cristian Abarzua

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to