Updated for 2.1a3
[python/dscho.git] / Demo / tkinter / guido / wish.py
blob4f6fdee9038f4fe2e5b5c755edc7de397e26bc31
1 # This is about all it requires to write a wish shell in Python!
3 import _tkinter
4 import os
6 tk = _tkinter.create(os.environ['DISPLAY'], 'wish', 'Tk', 1)
7 tk.call('update')
9 cmd = ''
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 = ''