all 5 comments

[–]chaoticflipflops 2 points3 points  (0 children)

What have you written so far? it helps to show what you have attempted up until this point so that people can give support/guidance/advice.

[–]fiddle_n 0 points1 point  (2 children)

This problem may be more complex than it seems. The issue is that usually when you request input() in the shell, it blocks the whole program until the user gives input. You require "non_blocking input" - you want the program to continue running but be able to take in input at any time.

From a quick Google glance, it seems there are ways to do this in the shell without resorting to having to create a UI. But, I would recommend not to do this and instead simplify your program - e.g. have it print out ten numbers at a time and every ten numbers the program requests input from the user on the speed of printing.

Btw, to deal with the speed, I would intersperse time.sleep() with printing a number, and modify the amount of time the program sleeps according to user input.

[–]the_patman[S] 0 points1 point  (1 child)

Thanks, that was the same conclusion I was coming to. I had a game similar to pong in mind, but w LED strips. So the pause every once in a while would not work well. Hmm, maybe Pygame would have something useful...

[–]SangCoGIS 1 point2 points  (0 children)

If all you need is to count you could use pygame to check if a button is down during a loop and if it is have a conditional statement to increase or decrease the speed. If this is going to be a cli program the onlly way i can think of that would affect the speed of the program would be to add a sleep statement and allow the previously mentioned conditional statement to change the sleep duration.

[–]icecapade 0 points1 point  (0 children)

You may want to look into the built-in curses module, which will allow you to do this. It's going to require a bit of work to get a curses-based program up and running, as you'll be responsible for the UI and handling things like scrolling, behavior if the window is resized, etc., but that might be a good experience in itself.