Ejemplo n.º 1
0
def addTodo(todoList):
    #Todo item
    print "Please enter something you need to do"    
    newTodoItem = raw_input(">")

    #Todo priority
    print "Now enter in a priority for your todo"
    newPriority = raw_input(">")
    print newPriority

    #Raw input comes out as a string, so it needs to get cast first
    if int(newPriority) > 0 and int(newPriority) <= 10:
        newTodo = todo.Todo(newPriority, newTodoItem)
        todoList.addTodo(newTodo)        
        print "You've created a new Todo: " \
                + newTodoItem + " with a priority of " \
                + newPriority + ". What would you like to do now?"
        print "a) View my list"
        print "b) Save and quit"
        response = raw_input(">")

        #Based on the user response, call the appropriate functions
        if response == "a":
            viewTodoList(todoList)
        elif response == "b":
            io_functions.saveTodoList(todoList)
            exit()
    else:
        print "Priority needs to be between 0 and 10"
        addTodo(todoList)
    return
Ejemplo n.º 2
0
def viewTodoList(TodoList):
    if not isinstance(TodoList.todolist, basestring) and len(TodoList.todolist) > 0:
        print "Here are the current todos on the list: "
        for todo in TodoList.todolist:
            print todo.getPriority() + ": " + todo.getTodo()

    print "What would you like to do?"
    print "a) Add a todo"
    print "b) Remove a todo"
    print "c) Sort list descending"
    print "d) Save list"
    print "e) Modify Todo"
    print "f) Exit"
    print "g) Save to file"

    response = raw_input(">")
    if response == "a":
        addTodo(TodoList)
    elif response == "b":
        print "Please enter the index of the todo to remove"
        index = int(raw_input(">"))
        removeTodo(TodoList, index)
    elif response == "c":
        TodoList.sortTodos()
        print "TodoList has been sorted"
        viewTodoList(TodoList)
    elif response == "d":
        io_functions.saveTodoList(TodoList)
    elif response == "e":
        print "Please enter in the index of the todo you'd like to modify"
        response = raw_input(">")
        modifyTodo(TodoList, response)
    elif response == "f":
        exit()   
    elif response == "g":
        io_functions.outputAsFile(TodoList, TodoList.listName)
        viewTodoList(TodoList)
    return