-
Notifications
You must be signed in to change notification settings - Fork 0
/
barra_carga.py
66 lines (54 loc) · 1.79 KB
/
barra_carga.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import time
def get_base_element(num):
b_blassic = '▒'
b_classic_two = '▢'
b_volume = '▁'
b_circle = ' '
b_world_war = '卐'
return ' '
def get_element_selector(element):
r_classic = ['█']
r_classic_two = ['■']
r_volume = ['▁', '▂', '▃', '▅', '▆', '▇']
r_circle = ['◐', '◑', '◒', '◓']
r_world_war = ['☭']
r_cross_dotted = ['⋮', '⋰', '⋯', '⋱']
b_cross_dotted = ' '
if element == 1:
return r_classic
elif element == 2:
return r_classic_two
elif element == 3:
return r_volume
elif element == 4:
return r_circle
elif element == 5:
return r_world_war
elif element == 6:
return r_cross_dotted
else:
return r_classic
def anim_rigt(elements, type, BAR_LEN):
frame = i % len(elements)
base_element = str(get_base_element(type))
print(f'\r[{elements[frame] * i:<{BAR_LEN}}{base_element}]', end='')
def anim_left(elements, type, BAR_LEN):
frame = i % len(elements)
base_element = str(get_base_element(type))
print(f'\r[{elements[frame] * i:>{BAR_LEN}}{base_element}]', end='')
def anim_center(elements, type, BAR_LEN):
frame = i % len(elements)
base_element = str(get_base_element(type))
print(f'\r[{elements[frame] * i:^{BAR_LEN}}{base_element}]', end='')
type = int(input("Tipo de carácter > "))
BAR_LEN = int(input("Longitud de la barra > "))
elements = get_element_selector(type)
for i in range(BAR_LEN + 1):
anim_rigt(elements=elements, type=type, BAR_LEN=BAR_LEN)
time.sleep(0.1)
for i in range(BAR_LEN + 1):
anim_left(elements=elements, type=type, BAR_LEN=BAR_LEN)
time.sleep(0.1)
for i in range(BAR_LEN + 1):
anim_center(elements=elements, type=type, BAR_LEN=BAR_LEN)
time.sleep(0.1)