def edit_categories(self): menu = list_choice(['add', 'edit', 'delete', 'back']) if menu == 'add': new = Category(name=str_input('Name')) self.db.add(new) elif menu == 'edit': edit = query_choice(self.db.query(Category)) edit.name = str_input('New name') elif menu == 'delete': rm = query_choice(self.db.query(Category)) self.db.delete(rm) self.db.commit()
def main_menu(self): menu = '' while menu != 'exit': menu = list_choice(['track expense', 'last month', 'edit categories', 'exit']) if menu == 'exit': self.end() if menu == 'track expense': self.track_expense() if menu == 'last month': self.history() self.stats() if menu == 'edit categories': self.edit_categories()