def run(self, evalcommand = []): sys.ps1 = "pyrobot> " done = 0 while len(evalcommand) > 0 and done == 0: print(evalcommand[0], end=' ') retval = evalcommand[0].strip() evalcommand = evalcommand[1:] done = self.processCommand(retval) banner=("=========================================================\n"+ "Pyrobot, Python Robotics, (c) 2005, D.S. Blank\n" + "http://PyroRobotics.org\n" + "Version " + version() + "\n" + "=========================================================") if not done: self.interact(banner=banner) self.save_history()
def run(self, evalcommand = []): sys.ps1 = "pyrobot> " done = 0 while len(evalcommand) > 0 and done == 0: print evalcommand[0], retval = evalcommand[0].strip() evalcommand = evalcommand[1:] done = self.processCommand(retval) banner=("=========================================================\n"+ "Pyrobot, Python Robotics, (c) 2005, D.S. Blank\n" + "http://PyroRobotics.org\n" + "Version " + version() + "\n" + "=========================================================") if not done: self.interact(banner=banner) self.save_history()
def __init__(self, engine): tkinter.Toplevel.__init__(self, share.gui) gui.__init__(self, 'TK gui', {}, engine) self.name = "<tkgui>" # for checking sys.stdout.name self.genlist = 0 self.frame = tkinter.Frame(self) self.frame.pack(side='bottom', expand="yes", anchor="n", fill='both') self.windowBrain = 0 self.lastRun = 0 self.lasttime = 0 self.brainTreeWindow = None self.robotTreeWindow = None self.update_interval = 100 self.update_interval_detail = 1.0 self.lastButtonUpdate = 0 self.printBuffer = [] self.maxBufferSize = 50000 # 50k characters in buffer #set to 0 for infinite #store the gui structure in something nice insted of python code ##pdb.set_trace() #DEBUG menu = [ ('File', [['New brain...', self.newBrain], None, ['Editor', self.editor], ['Expression Watcher', self.makeWatcher], ['Save current config as...', self.saveConfig], None, ['Exit', self.cleanup]]), ('Window', [ ['Open all device windows', self.makeWindows], None, ['Fast Update 10/sec', self.fastUpdate], ['Medium Update 3/sec', self.mediumUpdate], ['Slow Update 1/sec', self.slowUpdate], None, ['Clear Messages', self.clearMessages], ['Send Messages to Window', self.redirectToWindow], ['Send Messages to Terminal', self.redirectToTerminal], ]), ( 'Load', [ ['Server...', self.loadSim], ['Robot...', self.loadRobot], ['Devices...', self.loadDevice], ['Brain...', self.loadBrain], #['Built-in Devices', None], ]), ('Robot', [ ['Joystick', self.joystick], ['View', self.makeRobotTree], None, ['Forward', self.stepForward], ['Back', self.stepBack], ['Left', self.stepLeft], ['Right', self.stepRight], None, ['Stop Rotate', self.stopRotate], ['Stop Translate', self.stopTranslate], ['Stop All', self.stopEngine], None, ['Unload robot', self.freeRobot], None, ['Update', self.update], ]), ('Brain', [ ['Watch', self.openBrainWindow], ['View', self.makeBrainTree], None, ['Unload brain', self.freeBrain], ]), ('Help', [ ['Help', self.help], ['About', self.about], ]) ] self.var = tkinter.StringVar() self.currentDeviceList = [] button1 = [ ('Step', self.stepEngine), ('Run', self.runEngine), ('Stop', self.stopEngine), ('Reload Brain', self.resetEngine), ] # create menu self.mBar = tkinter.Frame(self.frame, relief=tkinter.RAISED, borderwidth=2) self.mBar.pack(fill=tkinter.X) self.goButtons = {} self.menuButtons = {} # FIXED: removed tk_menubar # for entry in menu: # self.mBar.tk_menuBar(self.makeMenu(self.mBar, entry[0], entry[1])) for entry in menu: self.makeMenu(self.mBar, entry[0], entry[1]) #self.menuButtons["Built-in Devices"] = Tkinter.Menubutton(self.mBar,text="Test",underline=0) self.frame.winfo_toplevel().title("pyrobot@%s" % os.getenv('HOSTNAME')) self.frame.winfo_toplevel().protocol('WM_DELETE_WINDOW', self.cleanup) # create a command text area: self.makeCommandArea() # Display: self.loadables = [ ('button', 'Server:', self.loadSim, self.editWorld, 0), # 0 = False ('button', 'Robot:', self.loadRobot, self.editRobot, self.makeRobotTree), ('picklist', 'Devices:', self.loadDevice, self.editDevice, self.viewDevice), ('button', 'Brain:', self.loadBrain, self.editBrain, self.makeBrainTree), ] self.buttonArea = {} self.textArea = {} for item in self.loadables: self.makeRow(item) self.buttonArea["Robot:"]["state"] = 'normal' self.buttonArea["Server:"]["state"] = 'normal' ## ---------------------------------- toolbar = tkinter.Frame(self.frame) for b in button1: self.goButtons[b[0]] = tkinter.Button(toolbar, text=b[0], command=b[1]) self.goButtons[b[0]].pack(side=tkinter.LEFT, padx=2, pady=2, fill=tkinter.X, expand="yes", anchor="n") toolbar.pack(side=tkinter.TOP, anchor="n", fill='x', expand="no") ## ---------------------------------- self.makeRow(('status', 'Pose:', '', '', 0)) # 0 = False ## ---------------------------------- self.textframe = tkinter.Frame(self.frame) self.textframe.pack(side="top", expand="yes", fill="both") # could get width from config self.status = tkinter.Text(self.textframe, width=60, height=10, state='disabled', wrap='word', bg="white") self.scrollbar = tkinter.Scrollbar(self.textframe, command=self.status.yview) self.status.configure(yscroll=self.scrollbar.set) # for displaying fonts, colors, etc.: ------------------- self.status.tag_config("red", foreground="red") self.status.tag_config("black", foreground="black") self.status.tag_config("green", foreground="green") self.status.tag_config("blue", foreground="blue") # -------------------------------------------------------- self.scrollbar.pack(side="right", expand="no", fill="y") self.status.pack(side="top", expand="yes", fill="both") self.textframe.pack(side="top", fill="both") self.redirectToWindow() #self.tk_focusFollowsMouse() self.commandEntry.focus_force() self.inform("Pyrobot Version " + version() + ": Ready...") self.inform("You entered the TKintner gui") #FOR DEBUG self.updateDeviceList(select=0)
def __init__(self, engine): Tkinter.Toplevel.__init__(self, share.gui) gui.__init__(self, 'TK gui', {}, engine) self.name = "<tkgui>" # for checking sys.stdout.name self.genlist = 0 self.frame = Tkinter.Frame(self) self.frame.pack(side = 'bottom', expand = "yes", anchor = "n", fill = 'both') self.windowBrain = 0 self.lastRun = 0 self.lasttime = 0 self.brainTreeWindow = None self.robotTreeWindow = None self.update_interval = 100 self.update_interval_detail = 1.0 self.lastButtonUpdate = 0 self.printBuffer = [] self.maxBufferSize = 50000 # 50k characters in buffer #set to 0 for infinite #store the gui structure in something nice insted of python code menu = [('File',[['New brain...', self.newBrain], None, ['Editor',self.editor], ['Expression Watcher', self.makeWatcher], ['Save current config as...', self.saveConfig], None, ['Exit',self.cleanup] ]), ('Window', [['Open all device windows', self.makeWindows], None, ['Fast Update 10/sec',self.fastUpdate], ['Medium Update 3/sec',self.mediumUpdate], ['Slow Update 1/sec',self.slowUpdate], None, ['Clear Messages', self.clearMessages], ['Send Messages to Window', self.redirectToWindow], ['Send Messages to Terminal', self.redirectToTerminal], ]), ('Load',[['Server...', self.loadSim], ['Robot...',self.loadRobot], ['Devices...',self.loadDevice], ['Brain...',self.loadBrain], #['Built-in Devices', None], ]), ('Robot',[['Joystick', self.joystick], ['View', self.makeRobotTree], None, ['Forward',self.stepForward], ['Back',self.stepBack], ['Left',self.stepLeft], ['Right',self.stepRight], None, ['Stop Rotate',self.stopRotate], ['Stop Translate',self.stopTranslate], ['Stop All',self.stopEngine], None, ['Unload robot', self.freeRobot], None, ['Update',self.update], ]), ('Brain',[['Watch', self.openBrainWindow], ['View', self.makeBrainTree], None, ['Unload brain', self.freeBrain], ]), ('Help',[['Help',self.help], ['About',self.about], ]) ] self.var = Tkinter.StringVar() self.currentDeviceList = [] button1 = [('Step',self.stepEngine), ('Run',self.runEngine), ('Stop',self.stopEngine), ('Reload Brain',self.resetEngine), ] # create menu self.mBar = Tkinter.Frame(self.frame, relief=Tkinter.RAISED, borderwidth=2) self.mBar.pack(fill=Tkinter.X) self.goButtons = {} self.menuButtons = {} for entry in menu: self.mBar.tk_menuBar(self.makeMenu(self.mBar, entry[0], entry[1])) #self.menuButtons["Built-in Devices"] = Tkinter.Menubutton(self.mBar,text="Test",underline=0) self.frame.winfo_toplevel().title("pyrobot@%s" % os.getenv('HOSTNAME')) self.frame.winfo_toplevel().protocol('WM_DELETE_WINDOW',self.cleanup) # create a command text area: self.makeCommandArea() # Display: self.loadables = [ ('button', 'Server:', self.loadSim, self.editWorld, 0), # 0 = False ('button', 'Robot:', self.loadRobot, self.editRobot, self.makeRobotTree), ('picklist', 'Devices:', self.loadDevice, self.editDevice, self.viewDevice), ('button', 'Brain:', self.loadBrain, self.editBrain, self.makeBrainTree), ] self.buttonArea = {} self.textArea = {} for item in self.loadables: self.makeRow(item) self.buttonArea["Robot:"]["state"] = 'normal' self.buttonArea["Server:"]["state"] = 'normal' ## ---------------------------------- toolbar = Tkinter.Frame(self.frame) for b in button1: self.goButtons[b[0]] = Tkinter.Button(toolbar,text=b[0],command=b[1]) self.goButtons[b[0]].pack(side=Tkinter.LEFT,padx=2,pady=2,fill=Tkinter.X, expand = "yes", anchor="n") toolbar.pack(side=Tkinter.TOP, anchor="n", fill='x', expand = "no") ## ---------------------------------- self.makeRow(('status', 'Pose:', '', '', 0)) # 0 = False ## ---------------------------------- self.textframe = Tkinter.Frame(self.frame) self.textframe.pack(side="top", expand = "yes", fill="both") # could get width from config self.status = Tkinter.Text(self.textframe, width = 60, height = 10, state='disabled', wrap='word', bg = "white") self.scrollbar = Tkinter.Scrollbar(self.textframe, command=self.status.yview) self.status.configure(yscroll=self.scrollbar.set) # for displaying fonts, colors, etc.: ------------------- self.status.tag_config("red", foreground = "red") self.status.tag_config("black", foreground = "black") self.status.tag_config("green", foreground = "green") self.status.tag_config("blue", foreground = "blue") # -------------------------------------------------------- self.scrollbar.pack(side="right", expand = "no", fill="y") self.status.pack(side="top", expand = "yes", fill="both") self.textframe.pack(side="top", fill="both") self.redirectToWindow() #self.tk_focusFollowsMouse() self.commandEntry.focus_force() self.inform("Pyrobot Version " + version() + ": Ready...") self.updateDeviceList(select=0)