Advertisement
LeonardCHoo

Untitled

Jul 17th, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.37 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. """
  3. TODO: docstring here
  4. """
  5.  
  6. from task import Task
  7. from project import Project
  8.  
  9. main_menu = {
  10.     'title': 'MAIN MENU',
  11.     'items': ['1. Create a project', '2. Load a project', '3. Quit'],
  12.     'actions': {
  13.         '3': exit,
  14.     }
  15. }
  16.  
  17. project_menu = {
  18.     'title': 'PROJECT MENU',
  19.     'items': ['1. Add a task', '2. Add task dependency', '3. Set task progress',
  20.             '4. Show project', '5. Back to Main Menu'],
  21.     'actions': {
  22.         '5': main_menu,
  23.     }
  24. }
  25.  
  26. def select_menu(menu):
  27.     while True:
  28.         print()
  29.         print(menu['title']) #MAIN MENU
  30.         print('\n'.join(menu['items'])) #1. create project, 2. load project ..
  31.         selection = input('Select > ')
  32.         next_action = menu['actions'].get(selection)
  33.         #print(selection, menu['actions'])
  34.         if next_action:
  35.             return next_action
  36.         else:
  37.             print('\nPlease select from the menu')
  38.  
  39. def create_project():
  40.     global cur_project
  41.     global project_menu
  42.  
  43.     project_name = input('Enter the project name: ')
  44.     cur_project = Project(project_name)
  45.  
  46.     return project_menu
  47.  
  48. main_menu['actions']['1'] = create_project
  49.  
  50. cur_menu = main_menu
  51. cur_project = None
  52.  
  53. while True:
  54.     result = select_menu(cur_menu)
  55.  
  56.     while callable(result):
  57.         result = result()
  58.  
  59.     cur_menu = result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement