Advertisement
FranzVuttke

wiatraczek.py

Nov 19th, 2023 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | Source Code | 0 0
  1. #!/usr/bin/python
  2.  
  3. # https://stackoverflow.com/questions/11018188/python-print-using-carriage-return-and-comma-not-working
  4.  
  5. # https://pastebin.com/edit/8PyKUSxK
  6. import sys
  7.  
  8. wiatraczki = { "default" : ["-", "\\", "|", "/", "-","\\", "|", "/"],
  9.                 "bigo" : [".", "o", "O", "o"],
  10.                 "asterisk" : ["*....",  ".*...", "..*..", "...*.", "....*"],
  11.                "linux" : ["*.......", "**......", "***.....", "****....",".****...","..****..","...****.",
  12.                             "....****", ".....***","......**", ".......*", "......**",".....***","....****",
  13.                             "...****.","..****..",".****...","****....","***.....","**......"
  14.                           ]
  15. }
  16.  
  17.  
  18.  
  19. # wiatraczek = ["-", "\\", "|", "/", "-","\\", "|", "/"]
  20. # wiatraczek = [".", "o", "O", "o"]
  21. #wiatraczek = ["*....",  ".*...", "..*..", "...*.", "....*"]
  22. from time import sleep
  23.  
  24. fan_type = "default"
  25.  
  26. # default ROTATE_TIMES
  27. ROTATE_TIMES = len(wiatraczki.get(fan_type))
  28.  
  29. if len(sys.argv) > 1:
  30.     try:
  31.         ROTATE_TIMES = int(sys.argv[1])
  32.         # fan_type = sys.argv[2]
  33.         if sys.argv[2] in wiatraczki.keys():
  34.             fan_type = sys.argv[2]
  35.         else:
  36.             print(f"Dostępne rodzaje 'wiatraczków': {', '.join(list(wiatraczki.keys()))}")
  37.  
  38.  
  39.     except Exception as error:
  40.         ...
  41.  
  42. for i in range(ROTATE_TIMES):
  43.     print("Kręcioła ({1})... {0}".format(wiatraczki.get(fan_type)[i % len(wiatraczki.get(fan_type))], ROTATE_TIMES), end="\r", flush=True)
  44.     # sys.stdout.write('Kręcioła ({1})... {0}\r'.format(wiatraczek[i % len(wiatraczek)], ROTATE_TIMES))
  45.     # sys.stdout.flush()
  46.     sleep(.09)
  47. print()
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement