0

So, I've ran into a bit of a problem because my vocabulary isn't big enough to define it. TQDM in python has a specific function that, when printed, deletes the line above it and only the singular line above it. I've tried looking through the documentation to see if there's a simple way to do it outside of the TQDM module, but I can't seem to find anything. For reference, here is the image of my console after fully printing, and the code along with it. Screenshot of my console

while xLoad == False:
    string1 = ''' Loading Prerequisites. . . " '''
    sleep(1)
    for letter in string1:
        sleep(0.01)
        sys.stdout.write(letter)
        sys.stdout.flush()
    for i in tqdm(range(_RAND_(800, 1999))):
        sleep(.0001)
        xLoad = True
# Responsible for making a fake loading bar to simulate loading files before startup

sleep(3)

# End of File

The code above is specifically for the last lines where the actual loading bar is displayed, not the top or the rest of the file. I can send the rest if needed, but what i'm referring to in this specific post is the ability to clear a line before printing a new one without clearing console entirely. I want to keep the "Modeni" and "Thank You" Message on the screen at all times while the rest of the text is displayed below. I hope I made sense in this post, and I appreciate any and all the help.

Mokie Sz
  • 1
  • 1

1 Answers1

0

If I'm understanding your situation correctly, I was wanting to do the same thing and found a solution from this entry: TQDM Printing to Newline: Solution

Add ", position=0, leave=False" inside your tqdm call. For example:

for item in tqdm(list_of_items, desc='Item Description', position=0, leave=False):

Once the loop has finished, it will clear the line making it usable for the next thing, be that another tqdm or whatever.

Hope this helps, and thanks for articulating the question better than I could ever have hoped to have done.

graih
  • 30
  • 3