def build_menu(): menu = Menu('Menu') menu.add_item(Item('1 - Show timeline', show_timeline)) menu.add_item(Item('2 - Follow username', follow_user)) menu.add_item(Item('3 - Send message', send_msg)) menu.add_item(Item('0 - Exit', exit_loop)) return menu
def run(self): student_menu = Menu([ Entry(1, 'Add student', self.__add_student), Entry(2, 'Update student', self.__update_student), Entry(3, 'Remove student', self.__remove_student), Entry(4, 'Show students', self.__show_students), Entry(5, 'Search students', self.__search_students), Entry(6, 'Add random students', self.__add_random_students), Entry(7, 'Back', self.__noop), ]) discipline_menu = Menu([ Entry(1, 'Add discipline', self.__add_discipline), Entry(2, 'Update discipline', self.__update_discipline), Entry(3, 'Remove discipline', self.__remove_discipline), Entry(4, 'Show disciplines', self.__show_disciplines), Entry(5, 'Search disciplines', self.__search_disciplines), Entry(6, 'Back', self.__noop), ]) grade_menu = Menu([ Entry(1, 'Add grade', self.__add_grade), Entry(2, 'Show grades', self.__show_grades), Entry(3, 'Back', self.__noop), ]) report_menu = Menu([ Entry(1, 'Grades for discipline sorted by name', self.__report_grades_sorted_by_name), Entry(2, 'Grades for discipline sorted by value', self.__report_grades_sorted_by_value), Entry(3, 'Students sorted by average grade', self.__report_students_sorted_by_average), Entry(4, 'Student with most grades over a given value', self.__report_student_with_most_grades_over), ]) main_menu = Menu([ Entry(1, 'Students', student_menu.run), Entry(2, 'Disciplines', discipline_menu.run), Entry(3, 'Grades', grade_menu.run), Entry(4, 'Report', report_menu.run), Entry('x', 'Exit', self.__exit), ]) while True: main_menu.run()
from Menu.Menu import Menu if __name__ == "__main__": # Run the program Menu()