mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	 9c6bd77e39
			
		
	
	
		9c6bd77e39
		
	
	
	
	
		
			
			svn+ssh://pythondev@svn.python.org/python/trunk ........ r78779 | benjamin.peterson | 2010-03-07 20:11:06 -0600 (Sun, 07 Mar 2010) | 1 line remove svn:executable from scripts without a shebang line ........
		
			
				
	
	
		
			30 lines
		
	
	
	
		
			701 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
	
		
			701 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| # This is about all it requires to write a wish shell in Python!
 | |
| 
 | |
| import _tkinter
 | |
| import os
 | |
| import sys
 | |
| 
 | |
| tk = _tkinter.create(os.environ['DISPLAY'], 'wish', 'Tk', 1)
 | |
| tk.call('update')
 | |
| 
 | |
| cmd = ''
 | |
| 
 | |
| while 1:
 | |
|     if cmd: prompt = ''
 | |
|     else: prompt = '% '
 | |
|     try:
 | |
|         sys.stdout.write(prompt)
 | |
|         sys.stdout.flush()
 | |
|         line = sys.stdin.readline()
 | |
|     except EOFError:
 | |
|         break
 | |
|     cmd = cmd + (line + '\n')
 | |
|     if tk.getboolean(tk.call('info', 'complete', cmd)):
 | |
|         tk.record(line)
 | |
|         try:
 | |
|             result = tk.call('eval', cmd)
 | |
|         except _tkinter.TclError as msg:
 | |
|             print('TclError:', msg)
 | |
|         else:
 | |
|             if result: print(result)
 | |
|         cmd = ''
 |