From a3714dec6f4cb102344cc1f47f45b099f8d822fb Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Tue, 28 May 2019 20:23:23 -0600 Subject: [PATCH] Support disabled entries --- .bin/Scripts/functions/advanced_menu.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.bin/Scripts/functions/advanced_menu.py b/.bin/Scripts/functions/advanced_menu.py index 2e672801..d3dd748b 100644 --- a/.bin/Scripts/functions/advanced_menu.py +++ b/.bin/Scripts/functions/advanced_menu.py @@ -4,6 +4,19 @@ import os from collections import OrderedDict +# STATIC VARIABLES +COLORS = { + 'CLEAR': '\033[0m', + 'RED': '\033[31m', + 'ORANGE': '\033[31;1m', + 'GREEN': '\033[32m', + 'YELLOW': '\033[33m', + 'BLUE': '\033[34m', + 'PURPLE': '\033[35m', + 'CYAN': '\033[36m', + } + + # Classes class MenuState(): """Class to track various parts of a menu.""" @@ -61,6 +74,14 @@ class MenuState(): display_list.append('{}: {}'.format(_prefix, name)) valid_answers[_prefix] = name + # Disable entry if necessary + if details['Disabled']: + display_list[-1] = '{ORANGE}{text}{CLEAR}'.format( + text=display_list[-1], + **COLORS, + ) + valid_answers.pop(_prefix) + # Show Menu and make selection _answer = '' while _answer.upper() not in valid_answers: