From bb66b9201b8a33fa176cc11b4c49956a96e678a8 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Thu, 1 Aug 2019 13:43:22 -0400 Subject: Made example update the prompt less frequently --- examples/async_printing.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'examples/async_printing.py') diff --git a/examples/async_printing.py b/examples/async_printing.py index dd46c75f..fdba14a0 100755 --- a/examples/async_printing.py +++ b/examples/async_printing.py @@ -139,12 +139,26 @@ class AlerterApp(cmd2.Cmd): return alert_str def _generate_colored_prompt(self) -> str: - """Randomly generates a colored prompt + """ + Randomly generates a colored prompt :return: the new prompt """ - fg_color = random.choice(list(ansi.FG_COLORS.keys())) - bg_color = random.choice(list(ansi.BG_COLORS.keys())) - return ansi.style(self.visible_prompt.rstrip(), fg=fg_color, bg=bg_color) + ' ' + rand_num = random.randint(1, 20) + + status_color = 'reset' + + if rand_num == 1: + status_color = 'bright_red' + elif rand_num == 2: + status_color = 'bright_yellow' + elif rand_num == 3: + status_color = 'cyan' + elif rand_num == 4: + status_color = 'bright_green' + elif rand_num == 5: + status_color = 'bright_blue' + + return ansi.style(self.visible_prompt, fg=status_color) def _alerter_thread_func(self) -> None: """ Prints alerts and updates the prompt any time the prompt is showing """ -- cgit v1.2.1