Skip to content

Commit bb66b92

Browse files
committed
Made example update the prompt less frequently
1 parent accb7d7 commit bb66b92

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

examples/async_printing.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,26 @@ def _generate_alert_str(self) -> str:
139139
return alert_str
140140

141141
def _generate_colored_prompt(self) -> str:
142-
"""Randomly generates a colored prompt
142+
"""
143+
Randomly generates a colored prompt
143144
:return: the new prompt
144145
"""
145-
fg_color = random.choice(list(ansi.FG_COLORS.keys()))
146-
bg_color = random.choice(list(ansi.BG_COLORS.keys()))
147-
return ansi.style(self.visible_prompt.rstrip(), fg=fg_color, bg=bg_color) + ' '
146+
rand_num = random.randint(1, 20)
147+
148+
status_color = 'reset'
149+
150+
if rand_num == 1:
151+
status_color = 'bright_red'
152+
elif rand_num == 2:
153+
status_color = 'bright_yellow'
154+
elif rand_num == 3:
155+
status_color = 'cyan'
156+
elif rand_num == 4:
157+
status_color = 'bright_green'
158+
elif rand_num == 5:
159+
status_color = 'bright_blue'
160+
161+
return ansi.style(self.visible_prompt, fg=status_color)
148162

149163
def _alerter_thread_func(self) -> None:
150164
""" Prints alerts and updates the prompt any time the prompt is showing """

0 commit comments

Comments
 (0)