blob: 0a61ad88d865e9d9d228e2b4e56d5f79747b889b [file] [log] [blame]
Guido van Rossum18468821994-06-20 07:49:28 +00001# This is about all it requires to write a wish shell in Python!
2
Jack Jansen10d0f8f1995-10-23 14:36:05 +00003import _tkinter
Guido van Rossum55618ef1995-09-07 19:44:48 +00004import os
Guido van Rossum18468821994-06-20 07:49:28 +00005
Jack Jansen10d0f8f1995-10-23 14:36:05 +00006tk = _tkinter.create(os.environ['DISPLAY'], 'wish', 'Tk', 1)
Guido van Rossum18468821994-06-20 07:49:28 +00007tk.call('update')
8
9cmd = ''
10
11while 1:
Tim Peters182b5ac2004-07-18 06:16:08 +000012 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 = ''