Shellmen/src/signal_classes/Menu.py

89 lines
2.3 KiB
Python
Raw Normal View History

2020-04-18 19:46:19 +00:00
# Python imports
from __future__ import print_function, unicode_literals
# from pprint import pprint
import json
# Lib imports
from PyInquirer import style_from_dict, Token, prompt, Separator
# Application imports
from .mixins import StylesMixin
2020-11-19 01:24:04 +00:00
GROUPS = [ "Search...", "Favorites", "Accessories", "Multimedia", "Graphics", "Office",
2020-10-25 01:13:26 +00:00
"Development", "Internet", "Settings", "System", "Game", "Wine",
2020-11-19 02:43:06 +00:00
"Other", "[ Set Favorites ]", "[ Exit ]"
2020-10-25 01:13:26 +00:00
]
2020-04-18 19:46:19 +00:00
2022-01-25 04:32:31 +00:00
class Menu(StylesMixin):
2020-04-18 19:46:19 +00:00
"""
The menu class has sub methods that are called per run.
"""
2022-01-25 04:32:31 +00:00
def __init__(self, settings, args):
2020-04-18 19:46:19 +00:00
"""
Construct a new 'Menu' object which pulls in mixins.
:param args: The terminal passed arguments
:return: returns nothing
"""
2022-01-25 04:32:31 +00:00
self.logger = settings.get_logger()
self.theme = self.call_method(args.theme)
2020-04-18 19:46:19 +00:00
2022-01-25 04:32:31 +00:00
def main_menu(self, _group_list = None):
2020-04-18 19:46:19 +00:00
"""
Displays the main menu using the defined GROUPS list...
"""
2022-01-25 04:32:31 +00:00
group_list = GROUPS if not _group_list else _group_list
2020-04-18 19:46:19 +00:00
menu = {
'type': 'list',
'name': 'group',
'message': '[ MAIN MENU ]',
2022-01-25 04:32:31 +00:00
'choices': group_list
2020-04-18 19:46:19 +00:00
}
return prompt(menu, style=self.theme)
2020-10-25 01:13:26 +00:00
2022-01-25 04:32:31 +00:00
def set_favorites_menu(self, _group_list = None):
GROUPS = [{'name': '[ TO MAIN MENU ]'}, {'name': 'This is a stub method for Favorites...'}]
group_list = GROUPS if not _group_list[0] else _group_list[0]
2020-10-25 01:13:26 +00:00
menu = {
2020-11-19 02:43:06 +00:00
'type': 'checkbox',
'qmark': '>',
'message': 'Select Favorites',
'name': 'set_faves',
2022-01-25 04:32:31 +00:00
'choices': group_list
2020-11-19 02:43:06 +00:00
}
2020-10-25 01:13:26 +00:00
2020-10-28 23:26:28 +00:00
return prompt(menu, style=self.theme)
2020-10-25 01:13:26 +00:00
2022-01-25 04:32:31 +00:00
def sub_menu(self, data = ["NO GROUP NAME", "NO PROGRAMS PASSED IN"]):
group = data[0]
prog_list = data[1]
2020-04-18 19:46:19 +00:00
menu = {
'type': 'list',
'name': 'prog',
2022-01-25 04:32:31 +00:00
'message': f'[ {group} ]',
'choices': prog_list
2020-04-18 19:46:19 +00:00
}
return prompt(menu, style=self.theme)
2022-01-25 04:32:31 +00:00
def search_menu(self):
2020-04-18 19:46:19 +00:00
menu = {
'type': 'input',
'name': 'query',
'message': 'Program you\'re looking for: ',
}
return prompt(menu, style=self.theme)