home *** CD-ROM | disk | FTP | other *** search
/ PC Extra 07 & 08 / pca1507.iso / Software / psp8 / Data1.cab / tkMessageBox.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2003-04-22  |  5.0 KB  |  90 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.2)
  3.  
  4. from tkCommonDialog import Dialog
  5. ERROR = 'error'
  6. INFO = 'info'
  7. QUESTION = 'question'
  8. WARNING = 'warning'
  9. ABORTRETRYIGNORE = 'abortretryignore'
  10. OK = 'ok'
  11. OKCANCEL = 'okcancel'
  12. RETRYCANCEL = 'retrycancel'
  13. YESNO = 'yesno'
  14. YESNOCANCEL = 'yesnocancel'
  15. ABORT = 'abort'
  16. RETRY = 'retry'
  17. IGNORE = 'ignore'
  18. OK = 'ok'
  19. CANCEL = 'cancel'
  20. YES = 'yes'
  21. NO = 'no'
  22.  
  23. class Message(Dialog):
  24.     '''A message box'''
  25.     command = 'tk_messageBox'
  26.  
  27.  
  28. def _show(title = None, message = None, icon = None, type = None, **options):
  29.     if icon:
  30.         options['icon'] = icon
  31.     
  32.     if type:
  33.         options['type'] = type
  34.     
  35.     if title:
  36.         options['title'] = title
  37.     
  38.     if message:
  39.         options['message'] = message
  40.     
  41.     return apply(Message, (), options).show()
  42.  
  43.  
  44. def showinfo(title = None, message = None, **options):
  45.     '''Show an info message'''
  46.     return apply(_show, (title, message, INFO, OK), options)
  47.  
  48.  
  49. def showwarning(title = None, message = None, **options):
  50.     '''Show a warning message'''
  51.     return apply(_show, (title, message, WARNING, OK), options)
  52.  
  53.  
  54. def showerror(title = None, message = None, **options):
  55.     '''Show an error message'''
  56.     return apply(_show, (title, message, ERROR, OK), options)
  57.  
  58.  
  59. def askquestion(title = None, message = None, **options):
  60.     '''Ask a question'''
  61.     return apply(_show, (title, message, QUESTION, YESNO), options)
  62.  
  63.  
  64. def askokcancel(title = None, message = None, **options):
  65.     '''Ask if operation should proceed; return true if the answer is ok'''
  66.     s = apply(_show, (title, message, QUESTION, OKCANCEL), options)
  67.     return s == OK
  68.  
  69.  
  70. def askyesno(title = None, message = None, **options):
  71.     '''Ask a question; return true if the answer is yes'''
  72.     s = apply(_show, (title, message, QUESTION, YESNO), options)
  73.     return s == YES
  74.  
  75.  
  76. def askretrycancel(title = None, message = None, **options):
  77.     '''Ask if operation should be retried; return true if the answer is yes'''
  78.     s = apply(_show, (title, message, WARNING, RETRYCANCEL), options)
  79.     return s == RETRY
  80.  
  81. if __name__ == '__main__':
  82.     print 'info', showinfo('Spam', 'Egg Information')
  83.     print 'warning', showwarning('Spam', 'Egg Warning')
  84.     print 'error', showerror('Spam', 'Egg Alert')
  85.     print 'question', askquestion('Spam', 'Question?')
  86.     print 'proceed', askokcancel('Spam', 'Proceed?')
  87.     print 'yes/no', askyesno('Spam', 'Got it?')
  88.     print 'try again', askretrycancel('Spam', 'Try again?')
  89.  
  90.