home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Lib / tkinter / Dialog.py < prev    next >
Encoding:
Python Source  |  1994-08-30  |  1018 b   |  40 lines  |  [TEXT/R*ch]

  1. # Dialog.py -- Tkinter interface to the tk_dialog script.
  2. from Tkinter import *
  3.  
  4. class Dialog(Widget):
  5.     def __init__(self, master=None, cnf={}):
  6.         Widget._setup(self, master, cnf)
  7.         self.num = self.tk.getint(
  8.             apply(self.tk.call,
  9.                   ('tk_dialog', self._w,
  10.                    cnf['title'], cnf['text'], 
  11.                    cnf['bitmap'], cnf['default'])
  12.                   + cnf['strings']))
  13.         try: Widget.destroy(self)
  14.         except TclError: pass
  15.     def destroy(self): pass
  16.  
  17. def _test():
  18.     d = Dialog(None, {'title': 'File Modified',
  19.               'text':
  20.               'File "Python.h" has been modified'
  21.               ' since the last time it was saved.'
  22.               ' Do you want to save it before'
  23.               ' exiting the application.',
  24.               'bitmap': 'warning',
  25.               'default': 0,
  26.               'strings': ('Save File', 
  27.                       'Discard Changes', 
  28.                       'Return to Editor')})
  29.     print d.num
  30.  
  31.  
  32. if __name__ == '__main__':
  33.     t = Button(None, {'text': 'Test',
  34.               'command': _test,
  35.               Pack: {}})
  36.     q = Button(None, {'text': 'Quit',
  37.               'command': t.quit,
  38.               Pack: {}})
  39.     t.mainloop()
  40.