Shellmen/src/core/Context.py

91 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 .utils import Logger
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 01:24:04 +00:00
"Other", "[ Exit ]"
2020-10-25 01:13:26 +00:00
]
2020-04-18 19:46:19 +00:00
class Context(StylesMixin):
"""
The menu class has sub methods that are called per run.
"""
def __init__(self, args):
"""
Construct a new 'Menu' object which pulls in mixins.
:param args: The terminal passed arguments
:return: returns nothing
"""
self.logger = Logger().get_logger("MAIN")
# Set the theme
self.theme = self.call_method(args.theme)
self.menuData = None
def mainMenu(self, _grouplist = None):
"""
Displays the main menu using the defined GROUPS list...
"""
grouplist = GROUPS if not _grouplist else _grouplist
menu = {
'type': 'list',
'name': 'group',
'message': '[ MAIN MENU ]',
'choices': grouplist
}
return prompt(menu, style=self.theme)
2020-10-25 01:13:26 +00:00
def favoritesMenu(self, _grouplist = None):
2020-10-28 23:26:28 +00:00
GROUPS = ["[ TO MAIN MENU ]", "This is a stub method for Favorites..."]
2020-10-25 01:13:26 +00:00
grouplist = GROUPS if not _grouplist else _grouplist
menu = {
'type': 'list',
'name': 'faves',
'message': '[ Favorites ]',
'choices': grouplist
}
2020-10-28 23:26:28 +00:00
return prompt(menu, style=self.theme)
2020-10-25 01:13:26 +00:00
2020-04-18 19:46:19 +00:00
def subMenu(self, data = ["NO GROUP NAME", "NO PROGRAMS PASSED IN"]):
group = data[0]
progList = data[1]
menu = {
'type': 'list',
'name': 'prog',
'message': '[ ' + group + ' ]',
'choices': progList
}
return prompt(menu, style=self.theme)
def searchMenu(self):
menu = {
'type': 'input',
'name': 'query',
'message': 'Program you\'re looking for: ',
}
return prompt(menu, style=self.theme)