0001 # Dialog.py -- Tkinter interface to the tk_dialog script. 0002 0003 from Tkinter import * 0004 from Tkinter import _cnfmerge 0005 0006 if TkVersion <= 3.6: 0007 DIALOG_ICON = 'warning' 0008 else: 0009 DIALOG_ICON = 'questhead' 0010 0011 0012 class Dialog(Widget): 0013 def __init__(self, master=None, cnf={}, **kw): 0014 cnf = _cnfmerge((cnf, kw)) 0015 self.widgetName = '__dialog__' 0016 Widget._setup(self, master, cnf) 0017 self.num = self.tk.getint( 0018 self.tk.call( 0019 'tk_dialog', self._w, 0020 cnf['title'], cnf['text'], 0021 cnf['bitmap'], cnf['default'], 0022 *cnf['strings'])) 0023 try: Widget.destroy(self) 0024 except TclError: pass 0025 def destroy(self): pass 0026 0027 def _test(): 0028 d = Dialog(None, {'title': 'File Modified', 0029 'text': 0030 'File "Python.h" has been modified' 0031 ' since the last time it was saved.' 0032 ' Do you want to save it before' 0033 ' exiting the application.', 0034 'bitmap': DIALOG_ICON, 0035 'default': 0, 0036 'strings': ('Save File', 0037 'Discard Changes', 0038 'Return to Editor')}) 0039 print d.num 0040 0041 0042 if __name__ == '__main__': 0043 t = Button(None, {'text': 'Test', 0044 'command': _test, 0045 Pack: {}}) 0046 q = Button(None, {'text': 'Quit', 0047 'command': t.quit, 0048 Pack: {}}) 0049 t.mainloop() 0050
Generated by PyXR 0.9.4