0

I've tried various methods such as using .strip and textwrap.dedent on this following bit of code:

import animation
import time

@animation.wait('spinner')
def timer_():
  time.sleep(2)
  print("test")
  return

timer_()

My desirable output is:

test

But the output is:

   \test

The animation is also indented the same way

1 Answers1

-2

Try:

import animation
import time

@animation.wait('spinner')
def timer_():
  time.sleep(2)
  print ("\033[A  \033[A")
  print("test")
timer_()
Nguyen
  • 57
  • 5
  • All I know is that importing animation alllows me create cool little progress bars rather than doing something like slowprint(" . . . . . . ") . Unfortunately, both of your possible answers didn't work for me leaving me to " \test" again. If you have any suggestions for creating simple animations, please let me know – Dixon Cider Aug 30 '21 at 07:24
  • what have you changed and why? why is the original not working as expected? – Tibebes. M Aug 30 '21 at 07:27
  • i'm not sure your "My desirable output is:" is enough, try print("") before return. – Nguyen Aug 30 '21 at 07:30
  • 1
    @Nguyen if you unsure about anything, don't rush to answer.. ask for a clarification in the comment section. – Tibebes. M Aug 30 '21 at 07:31
  • @Tibebes.M feel bad, – Nguyen Aug 30 '21 at 07:39
  • I'm not sure why the code I have is not working as expected which is why I am trying to get help. Putting print("") before return doesn't seem to solve the issue. The animation itself is not in the correct position either anyways. – Dixon Cider Aug 30 '21 at 07:47
  • Can you share what issue you get into, did you want the waiting sign is remove after time.sleep is finish ? – Nguyen Aug 30 '21 at 08:14
  • I want there to be no text except for "test" after the animation has ended. Both the text "test" and animation text (- \ | /) aren't placed where I want it to be. Something with the code which I'm not sure of makes the text indented when displayed on the output screen. – Dixon Cider Aug 30 '21 at 08:22
  • get it, animation decorator can't help for sure, can you try clear console before printing test that maybe is a good option. find something here https://stackoverflow.com/questions/44565704/how-to-clear-only-last-one-line-in-python-output-console – Nguyen Aug 30 '21 at 08:40