# create named pipe to communicate with the entry console T = Thread(target=print_updates, args=(q,)) Q = Queue(maxsize=1) # use queue to communicate with the thread Value = queue.get(timeout=.1) # update value Minwidth = len(msg) # make sure previous output is overwritten Value = queue.get() # wait until value is available If os.name = 'nt': # or use sys.platform for more specific namesĬonsole = # or somethingĬonsole = # specify your favorite terminal View.py: Launch the entry console, print constant updates in a thread, accept input from the named pipe and pass it to the updates thread: #!/usr/bin/env python Print >file, command # pass the command to view window Print ''.join(reversed(command)) # do something with it Purely for illustration here's a not recommended non-GUI way that shows how to do it using a thread, a subprocess, and a named pipe as IPC.Įntry.py: accept commands from a user, do something with the command, pass it to the named pipe given at the command-line: #!/usr/bin/env pythonįor command in iter(lambda: raw_input('> '), ''):
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |