From: Bruce S. <Bru...@nc...> - 2009-09-29 15:00:33
|
Works for me on Windows, though it's a little complicated, because you have to click on the shell window in order to enter the command (to be accepted by the "input" routine), and then after entering the command you have to click on the VPython graphics window for VPython to pick up inputs using scene.kb.getkey(). Bruce Sherwood Kadir Haldenbilen wrote: > Hello All, > > I am trying to write a little routine, which will enable intreacting > with the program while it is looping. > It is basically intended for debugging, butit may also be useful for > changing some attributes (and hence the logic) in flight. > > I am using the keyboard events to break-into the loop. I am using the > "@" character as a special character, > then, once detected I input my command from the shell (with > preceeding/following quote signs). > > It works OK for the first time. > > But, after the first one, "scene.kb.keys" does not sense the input key. > > Most probably, with the input() command I am breaking some stack, etc., > so that visual can not detect the keyboard input. > > You can find the sample code below. > > Any ideas will be appreciated. > > Thanks, > > Kadir > > ====================================== > > from visual import * > > bb = box() > > while 1: > > if scene.kb.keys: # event waiting to be processed? > s = scene.kb.getkey() # get keyboard info > print "s ", s # this is the key pressed > if s == "@": # see if it is the break character "@" > df = input("Enter Command: ") # If True, then > wait for command input > print df # This is the command entered > try: # it may be an invalid command, be > prepared > print eval(df) # execute the command > and print the result > except: > pass # if invalid command do nothing > > s = "" # reset the input key > print scene.kb.keys # check if there are any > other keyboard events > > bb.rotate(axis=(0,1,0), angle=0.01) # set something going on in > the loop > rate(25) > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > > > ------------------------------------------------------------------------ > > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users |