From a9e5985f90905afcd5ee190533f5a0cbc01d8f72 Mon Sep 17 00:00:00 2001 From: Robert Maikher Date: Fri, 31 Aug 2018 13:48:06 +0200 Subject: [PATCH] Move c and cs commands to the mainmenu class This makes it so that it only works on the main menu, too. --- text_interface/helpermenus.py | 15 --------------- text_interface/mainmenu.py | 12 +++++++++++- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/text_interface/helpermenus.py b/text_interface/helpermenus.py index 795cf93..6866aa6 100644 --- a/text_interface/helpermenus.py +++ b/text_interface/helpermenus.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- -import os -import random import re import sys from select import select @@ -174,19 +172,6 @@ class Menu(object): result = self.input_str(prompt, end_prompt) if result == '': print('Please enter something') - #TODO: Move this into mainmenu.py special options - # 'c' in main menu to change colours - elif result == 'c': - os.system('echo -e "\033[' + str(random.randint(40, 49)) + ';' + str(random.randint(30, 37)) + ';5m"') - os.system('clear') - self.show_context() - - # 'cs' in main menu to change colours back to default - elif result == 'cs': - os.system('echo -e "\033[0m"') - os.system('clear') - self.show_context() - else: if result.isdigit(): choice = int(result) diff --git a/text_interface/mainmenu.py b/text_interface/mainmenu.py index 335099b..86cd90e 100644 --- a/text_interface/mainmenu.py +++ b/text_interface/mainmenu.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import os - +import random import sys from db import Session @@ -43,6 +43,16 @@ class MainMenu(Menu): restart() pass return True + elif result == 'c': + os.system('echo -e "\033[' + str(random.randint(40, 49)) + ';' + str(random.randint(30, 37)) + ';5m"') + os.system('clear') + self.show_context() + return True + elif result == 'cs': + os.system('echo -e "\033[0m"') + os.system('clear') + self.show_context() + return True return False def invalid_menu_choice(self, in_str):