home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Demo / tkinter / guido / wish.py < prev   
Encoding:
Text File  |  1994-06-20  |  506 b   |  27 lines  |  [TEXT/R*ch]

  1. # This is about all it requires to write a wish shell in Python!
  2.  
  3. import tkinter
  4.  
  5. tk = tkinter.create(':0', 'wish', 'Tk', 1)
  6. tk.call('update')
  7.  
  8. cmd = ''
  9.  
  10. while 1:
  11.     if cmd: prompt = ''
  12.     else: prompt = '% '
  13.     try:
  14.         line = raw_input(prompt)
  15.     except EOFError:
  16.         break
  17.     cmd = cmd + (line + '\n')
  18.     if tk.getboolean(tk.call('info', 'complete', cmd)):
  19.         tk.record(line)
  20.         try:
  21.             result = tk.call('eval', cmd)
  22.         except tkinter.TclError, msg:
  23.             print 'TclError:', msg
  24.         else:
  25.             if result: print result
  26.         cmd = ''
  27.