Beispiel #1
0
 def __init__(self):
     self.notebook = Notebook()
     self.choices = {
         "1": self.show_notes,
         "2": self.search_notes,
         "3": self.add_note,
         "4": self.modify_note,
         "5": self.quit
     }
Beispiel #2
0
class Menu:
    '''Display a menu and respond to choices when run.'''
    def __init__(self):
        self.notebook = Notebook()
        self.choices = {
            "1": self.show_notes,
            "2": self.search_notes,
            "3": self.add_note,
            "4": self.modify_note,
            "5": self.quit
        }

    def display_menu(self):
        print("""
        Notebook Menu
        1. Show all Notes 
        2. Search Notes 
        3. Add Note
        4. Modify Note
        5. Quit """)

    def run(self):
        '''Display the menu and respond to choices.'''
        while True:
            self.display_menu()
            choice = input("Enter an option: ")
            action = self.choices.get(choice)
            if action:
                action()
            else:
                print("{0} is not a valid choice".format(choice))

    def show_notes(self, notes=None):
        if not notes:
            notes = self.notebook.notes
            for note in notes:
                print("{0}: {1}\n{2}".format(note.id, note.tags, note.memo))

    def search_notes(self):
        filter = input("Search for: ")
        notes = self.notebook.search(filter)
        self.show_notes(notes)

    def add_note(self):
        memo = input("Enter a memo: ")
        self.notebook.new_note(memo)
        print("Your note has been added.")

    def modify_note(self):
        id = input("Enter a note id: ")
        memo = input("Enter a memo: ")
        tags = input("Enter tags: ")
        if memo:
            self.notebook.modify_memo(id, memo)
            if tags:
                self.notebook.modify_tags(id, tags)

    def quit(self):
        print("Thank you for using your notebook today.")
        sys.exit(0)
Beispiel #3
0
 def __init__(self):
     self.notebook=Notebook()
     self.choices={
         "1": self.show_notes,
         "2": self.search_notes,
         "3": self.add_note,
         "4": self.modify_note,
         "5": self.quit
         }
Beispiel #4
0
class Menu:
    def __init__(self):
        self.notebook = Notebook()
        self.options = {
            "1": self.show_notes,
            "2": self.search_notes,
            "3": self.add_note,
            "4": self.modify_note,
            "5": self.quit
        }

    def show_menu(self):
        for option, command in self.options.items():
            print(f"{option} : {str(command)}")

    def show_notes(self):

        for note in self.notebook.notes:
            print(f"{note}\n")

    def search_notes(self):
        found_list = self.notebook.search()
        print(found_list)

    def add_note(self):
        self.notebook.new_note()

    def modify_note(self):
        option = input(
            "Co chcesz edytować?\n1 : Edytuj tytuł\n2 : Edytuj tekst\n")
        if option == '1':
            self.notebook.modify_tag()
        elif option == '2':
            self.notebook.modify_text()
        else:
            print("Nie ma takiej opcji!")

    def quit(self):
        sys.exit(0)

    def run(self):
        while True:
            self.show_menu()
            choice = input("Wybierz opcję: ")

            if choice in self.options:
                self.options[choice]()
            else:
                print("Nie ma takiej opcji!")
Beispiel #5
0
from note import Note, Notebook

n1=Note("hello first")
n2=Note("hello again")
print(n1.id)
print(n2.id)
print(n1.match('hello'))
print(n2.match('second'))


n=Notebook()
n.new_note("hello world")
n.new_note("hello again")
print(n.notes)
print(n.notes[0].id)
print(n.notes[1].id)
print(n.notes[0].memo)

print(n.search("hello"))
print(n.search("world"))
n.modify_memo(3,"hi world")
print(n.notes[0].memo)
Beispiel #6
0
class Menu:
    '''Display a menu and respond to choices when run.'''
    def __init__(self):
        self.notebook=Notebook()
        self.choices={
            "1": self.show_notes,
            "2": self.search_notes,
            "3": self.add_note,
            "4": self.modify_note,
            "5": self.quit
            }

    def display_menu(self):
        print("""
Notebook Menu

1. Show all Notes
2. Search Notes
3. Add Notes
4. Modify Note
5. Quit
""")

    def run(self):
        '''Display the menu and respond to choices.'''
        while True:
            self.display_menu()
            choice = input("Enter an option: ")
            action=self.choices.get(choice)
            if action:
                action()
            else:
                print("{0} is not a valid choice".format(choice))

    def show_notes(self, notes=None):
        if not notes:
            notes=self.notebook.notes
        for note in notes:
            print("{0}: {1}\n{2}".format(note.id, note.tags, note.memo))

    def search_notes(self):
        filter=input("Search for: ")
        notes=self.notebook.search(filter)
        self.show_notes(notes)

    def add_note(self):
        memo=input("Enter a memo: ")
        self.notebook.new_note(memo)
        print("Your note has been added.")

    def modify_note(self):
        id=input("Enter a note id: ")
        memo=input("Enter a memo: ")
        tags=input("Enter tags: ")
        if memo:
            self.notebook.modify_memo(id,memo)
        if tags:
            self.notebook.modify_tags(id,tags)

    def quit(self):
        print("Thank you for using your notebook today.")
        sys.exit(0)