chevron_left chevron_right
Login Register invert_colors photo_library

Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average

[Question] Python Curses: Multithreading Input | SOLVED filter_list
[Question] Python Curses: Multithreading Input | SOLVED #1
Okay, I am making a stopwatch that by pressing the up key it adds more and more watch's, right now I only have it running on one.
When the user inputs the up arrow key, another stopwatch is added, this will just be done as an array and for loop.
The issue is, when using Curses, it locks the screen. No other inputs or anything can be interpreted.

I will put a comment on what doesn't work.

from time import sleep
from curses import wrapper

import curses
import threading

class StopWatch(threading.Thread):
   seconds = 0
   minutes = 0
   hours = 0

   def run(self):
       while True:
           StopWatch.seconds = StopWatch.seconds + 1
           if StopWatch.seconds == 60:
               StopWatch.minutes = StopWatch.minutes + 1
               StopWatch.seconds = 1
           if StopWatch.minutes == 60:
               StopWatch.hours = StopWatch.hours + 1
               StopWatch.minutes = 1

# The input here does not work
class GetInput(threading.Thread):
   def run(self):
       while True:
           c = main.stdscr.getch()
           if c == 27:

def main(stdscr):
   while True:
       strToDisp = '{} Seconds | {} Minutes | {} Hours'
       strToDisp = strToDisp.format(StopWatch.seconds,
       stdscr.addstr(0, 0, strToDisp)

def exit(stdscr):

if __name__ == '__main__':
   stdscr = curses.initscr()
(This post was last modified: 04-15-2017, 12:46 AM by ProfessorChill.)


Messages In This Thread
[Question] Python Curses: Multithreading Input | SOLVED - by ProfessorChill - 04-13-2017, 08:19 PM

Users browsing this thread: 1 Guest(s)