简体   繁体   中英

Python - Using Curses to split async in single terminal

I have this async script below, what I'd like to do is have it split it's output but in two different sections of the terminal (top and bottom). I've heard curses is a great way to go about it, but can't find an example that seems to come close to it. Would anyone happen to have an idea how to go about this? Any help is appreciated!

if __name__ == '__main__':
    pool = Pool(processes=2)
    for b in a:
        pool.apply_async(os.system,(b,))
    pool.close()
    pool.join()

I would split it up into 3 threads. Two can maintain the text to print in some shared object. The third thread can do a screen refresh loop:

while self.active:            # application is still running
    if self.touched:          # Some of the other threads made an update
        self.touched = False
        self.draw()           # Draw both sections of the other two threads
    sleep(0.01)               # Refresh rate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM