This is for a really simple project just for fun, called Brendonio’s Big Belly - the point is that it is similar to a clicker, so I have everything in a while loop that loops and reprints.
However, when you run the code, nothing shows up until you press a key, which was not intentionally coded. In addition, after you press the key, it will wait about 1 second and then disappear again.
Does anyone have any possible solutions?
The repl is at this link.
Instead of using
print("\033[H\033[2J", end="", flush=True).
Hope this helps!
I think a more clear solution is that you should use
print("\033c", end="", flush=True) because
os.system("clear") (IIRC) literally prints enough lines to overflow the current text and push it out of the console whereas ansi commands like
\033c are used to directly clear the text on the console. Moreoever, through stress tests, the
\033c should clear the screen even on replit in a timely manner as long as it’s not a rate more than 5/second Otherwise if you want to do something more intensive, I recommend self hosting or using a smaller service with less stress on their API
Okay, I’ll try that - I will mark as solution if this works.
I think it should work I’ve fiddled around with ansi quite a bit I even made a working real time updating chat app in the console
Hmm, I tried doing it but it didn’t work. I still have the issue where it requires me to press a key to activate it which is really weird. When I press the key, though, it waits one second and clears without reprinting which is pretty odd
Oh I read the code, just delete the line that says
Huh, still doesn’t work. It still does the same thing except it barely shows the text before deleting it and failing to reprint
ah you want it to print, you need to move the clear line to directly below the readchar line
Ah, that works, but now the variables don’t update, it’s basically a static print. Thanks for helping so much btw
it should? Can I see the code
Do you want me to invite you?
alright I think that should worrk
Hmm my join link says “post needs to be approved by moderators”
oh :(( could you just go to it and input the username “bigminiboss” it happened because back in the day ppl would post join links and random ppl would join
Ok, invited It should appear in your notifications now
Just to let other people who have the same problem know, it eventually did start working, maybe it was a device issue at first
Oof this is really embarrassing but now you have to press a key to iterate the while loop because of the readchar() thing so it’s no longer functional. . .
You could also use Threads (example below).
from readchar import readkey
from threading import Thread
currentKey = ""
currentKey = readkey()
EDIT: Thanks to Firepup650 for alerting me about the bug
That example would just get stuck in a loop of printing nothing.