From: Chris C. <scc...@gm...> - 2009-09-28 09:58:19
|
You should look into the threading module: http://docs.python.org/library/threading.html On Sun, Sep 27, 2009 at 9:05 PM, Kadir Haldenbilen <kha...@ya...> 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 > > |