| 
									
										
										
										
											1994-06-20 07:49:28 +00:00
										 |  |  | # This is about all it requires to write a wish shell in Python! | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-10-23 14:36:05 +00:00
										 |  |  | import _tkinter | 
					
						
							| 
									
										
										
										
											1995-09-07 19:44:48 +00:00
										 |  |  | import os | 
					
						
							| 
									
										
										
										
											1994-06-20 07:49:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-10-23 14:36:05 +00:00
										 |  |  | tk = _tkinter.create(os.environ['DISPLAY'], 'wish', 'Tk', 1) | 
					
						
							| 
									
										
										
										
											1994-06-20 07:49:28 +00:00
										 |  |  | tk.call('update') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | cmd = '' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | while 1: | 
					
						
							| 
									
										
										
										
											2004-07-18 06:16:08 +00:00
										 |  |  |     if cmd: prompt = '' | 
					
						
							|  |  |  |     else: prompt = '% ' | 
					
						
							|  |  |  |     try: | 
					
						
							|  |  |  |         line = raw_input(prompt) | 
					
						
							|  |  |  |     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, msg: | 
					
						
							|  |  |  |             print 'TclError:', msg | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             if result: print result | 
					
						
							|  |  |  |         cmd = '' |