#!/usr/bin/env python """ pc.py Copyright (C) 1998 Aloril This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. """ import sys,Tkinter,_tkinter from ext_mind import ext_mind from event import * class interface: def __init__(self, c): self.c=c f = Tkinter.Frame() ; Tkinter.Pack.config(f) f.master.title(self.c.name) b = Tkinter.Button (f, {'text' : "Quit",\ 'command': self.quit}) b.pack ({'side': 'left', 'fill': 'both'}) self.f=f self.add_move("Left",(-20,0,0)) self.add_move("Right",(20,0,0)) self.add_move("Down",(0,-20,0)) self.add_move("Up",(0,20,0)) self.set_timer() def quit(self): sys.exit(0) def add_move(self,txt,dir): f=self.f def m(self=self,dir=dir): self.c.move(dir) b = Tkinter.Button (f, {'text' : txt,\ 'command': m}) b.pack ({'side': 'left', 'fill': 'both'}) def set_timer(self): _tkinter.createtimerhandler(50, self.loop) def loop(self): self.c.run(clear_screen=0) self.set_timer() class pc(ext_mind): def __init__(self, name, remote=1, invoke_steps=0, type="body", xyz=(-100,-50,0), ccode=None): ext_mind.__init__(self,name,remote,invoke_steps,type,xyz=xyz,ccode=ccode) self.send_events([event('look',what=self)]) self.run() self.i=interface(self) Tkinter.mainloop() def move(self,(xd,yd,zd)): (x,y,z)=self.xyz x=x+xd; y=y+yd; z=z+zd self.send_events([event('move',what=self,loc=(x,y,z))]) if __name__=="__main__": c=pc("Aloril")