~malept/ubuntu/lucid/python2.6/dev-dependency-fix

« back to all changes in this revision

Viewing changes to Demo/tkinter/guido/wish.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-02-13 12:51:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090213125100-uufgcb9yeqzujpqw
Tags: upstream-2.6.1
ImportĀ upstreamĀ versionĀ 2.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 = ''