Hey there Stack Overflow. I'm trying to build a testing script that should mix outputting changing characters (using curses) on multiple lines (creating them over time), creating new lines based on the thread number. I have the below code:
# -*- coding: utf-8 -*-
import curses, time, threading
def threadedFunction(linePos):
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
try:
stdscr.clear()
for i in range(50):
stdscr.addstr(linePos, 0, "testing %s..." % i)
stdscr.refresh()
time.sleep(.1)
finally:
curses.echo()
curses.nocbreak()
curses.endwin()
pass
pass
if __name__ == "__main__":
for x in xrange(0, 4): # should produce 5 lines maximum
exec("process" + str(x) + " = threading.Thread(target = threadedFunction, args = (" + str(x) + ",))")
exec("process" + str(x) + ".start()")
I tried using the multithreading library before, but I had no hope with it. The threading library at least will display the numbers I want on a few lines before it goes crazy. Here's an example of what it does when I run it:
All I want is for the program to just simply start a new thread, and display a line that counts to 50 while adding new lines doing the same thing. How would I go about doing this?? Thanks in advance :)
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)