Closed Illegal-Services closed 1 year ago
import ctypes
import time
import sys
from alive_progress import alive_it
def set_console_title(title) -> None:
sys.stdout.flush()
ctypes.windll.kernel32.SetConsoleTitleW(f"{title}")
for i in alive_it(range(10), theme="classic", bar="classic2", enrich_print=False):
set_console_title(i)
time.sleep(0.3)
Here is a work-around method that does the job alternatively of the "print title" method.
Hi @Illegal-Services, thank you!
Well, are you sure you're using the codes correctly? I've never seen \033]
, just \033[
...
What are you trying to do?
"What are you trying to do?"
Just to set the console title
I'm not sure what ChatGPT is talking about, as [
is the correct way to do it as far as I know. Try it. Works for me, at least...
Don't use the \007
with [
though. That might be what's confusing chatgpt.
EDIT: Nevermind - I thought you were trying to do colours, not set titles. Looks like ]
is indeed the correct one for that. Sorry!
Ahh, ok, now I got what you're trying to do. That is indeed a different kind of escape code, look:
Anyway, I know what is happening. I install an automatic system print hook that captures all bytes sent to stdout until a newline is found. When this happens, I prepare the line header and send the whole text to the actual stdout including a newline, since the bar is refreshing itself very fast, and to see the printed text we need the cursor on a new line. Disabling enrich_print doesn't really do anything here because I still need to clean the line after anything is printed, and move the bar to the next line, or garbage characters from a previous bar refresh would remain there. The fix should be in a layer above, regardless of whether enrich_print is enabled or not.
I'm working on it.
Hello there, first of all this is an awesome project, thanks for it! I'm new to it and I think I've found a bug where I set the title of my script using ANSI escape code.
I just don't want to display any text/newlines at all when I run this code but I keep getting:
Can someone light me up if I'm doing something wrong or if this really is a problem with alive-progress project please? Here's a minimalistic code snippet, and my Python version if needed? Python 3.11.2: