summaryrefslogtreecommitdiff
path: root/examples/async_printing.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-08-01 13:43:22 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-08-01 13:43:22 -0400
commitbb66b9201b8a33fa176cc11b4c49956a96e678a8 (patch)
treed67c1332ee9256b9ad0b0cb7c67a16fac2879543 /examples/async_printing.py
parentaccb7d78675fffe9aa031fa073aa950c8241ee1c (diff)
downloadcmd2-git-bb66b9201b8a33fa176cc11b4c49956a96e678a8.tar.gz
Made example update the prompt less frequently
Diffstat (limited to 'examples/async_printing.py')
-rwxr-xr-xexamples/async_printing.py22
1 files changed, 18 insertions, 4 deletions
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 """