blob: 5cbb1b90c221b396eaa2e34f27b7a080af85bf7b [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
3import tkinter
4
5tk = tkinter.create(':0', 'wish', 'Tk', 1)
6tk.call('update')
7
8cmd = ''
9
10while 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')
Guido van Rossum18468821994-06-20 07:49:28 +000018 if tk.getboolean(tk.call('info', 'complete', cmd)):
Guido van Rossum8d1e4391994-06-20 08:13:02 +000019 tk.record(line)
Guido van Rossum18468821994-06-20 07:49:28 +000020 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 = ''