ButtonFrame = Frame(self)
OKButton = Button( ButtonFrame, text="OK", width=10,
command=self.OnOK, default=ACTIVE )
OKButton.pack(side=LEFT, padx=5, pady=5)
CancelButton = Button( ButtonFrame, text="Cancel", width=10,
command=self.OnCancel )
CancelButton.pack(side=LEFT, padx=5, pady=5)
ButtonFrame.pack()
self.bind("<Return>", self.OnOK)
self.bind("<Escape>", self.OnCancel)
def OnOK(self, event=None):
''' called by pressing the OK button - validates data, and if no error
sets a good return code and dismisses the dialog by calling OnCancel