Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- """
- TODO: docstring here
- """
- from task import Task
- from project import Project
- main_menu = {
- 'title': 'MAIN MENU',
- 'items': ['1. Create a project', '2. Load a project', '3. Quit'],
- 'actions': {
- '3': exit,
- }
- }
- project_menu = {
- 'title': 'PROJECT MENU',
- 'items': ['1. Add a task', '2. Add task dependency', '3. Set task progress',
- '4. Show project', '5. Back to Main Menu'],
- 'actions': {
- '5': main_menu,
- }
- }
- def select_menu(menu):
- while True:
- print()
- print(menu['title']) #MAIN MENU
- print('\n'.join(menu['items'])) #1. create project, 2. load project ..
- selection = input('Select > ')
- next_action = menu['actions'].get(selection)
- #print(selection, menu['actions'])
- if next_action:
- return next_action
- else:
- print('\nPlease select from the menu')
- def create_project():
- global cur_project
- global project_menu
- project_name = input('Enter the project name: ')
- cur_project = Project(project_name)
- return project_menu
- main_menu['actions']['1'] = create_project
- cur_menu = main_menu
- cur_project = None
- while True:
- result = select_menu(cur_menu)
- while callable(result):
- result = result()
- cur_menu = result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement