#!/local/bin/python from Tkinter import * from Dialog import Dialog class Hello(Frame): def __init__(self,master=None): Frame.__init__(self,master) Pack.config(self) self.createWidgets() def greet(self): print "hi" def createWidgets(self): Label(self, text='Hello popup world').pack(side=TOP) Button(self,text='Pop1', command=self.dialog1).pack() Button(self,text='Pop2', command=self.dialog2).pack() Button(self, text='Hey', command=self.greet).pack(side=LEFT) Button(self, text='Bye', command=self.quit).pack(side=RIGHT) def dialog1(self): ans=Dialog(self, title = 'Popup Fun!', text = 'An example of a popup-dialog ' 'box. "Dialog.py" has a simple ' 'interface for canned dialogs.', bitmap = 'questhead', default = 0, strings = ('Yes', 'No', 'Cancel')) if ans.num == 0: self.dialog2() if ans.num == 2: self.dialog3() def dialog2(self): Dialog(self, title = 'HAL-9000', text = "I'm afraid I can't let you do that, Dave ...", bitmap = 'hourglass', default = 0, strings = ('spam','SPAM')) def dialog3(self): print "you can't cancel this" if __name__ == '__main__': Hello().mainloop()