symbian-qemu-0.9.1-12/python-2.6.1/Demo/tkinter/guido/wish.py
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     1 # This is about all it requires to write a wish shell in Python!
       
     2 
       
     3 import _tkinter
       
     4 import os
       
     5 
       
     6 tk = _tkinter.create(os.environ['DISPLAY'], 'wish', 'Tk', 1)
       
     7 tk.call('update')
       
     8 
       
     9 cmd = ''
       
    10 
       
    11 while 1:
       
    12     if cmd: prompt = ''
       
    13     else: prompt = '% '
       
    14     try:
       
    15         line = raw_input(prompt)
       
    16     except EOFError:
       
    17         break
       
    18     cmd = cmd + (line + '\n')
       
    19     if tk.getboolean(tk.call('info', 'complete', cmd)):
       
    20         tk.record(line)
       
    21         try:
       
    22             result = tk.call('eval', cmd)
       
    23         except _tkinter.TclError, msg:
       
    24             print 'TclError:', msg
       
    25         else:
       
    26             if result: print result
       
    27         cmd = ''