Exemplo n.º 1
0
def add_subject_afterwards_to_file(subject_name, window, entry):
    # Try to add the new subject to the file
    added = Task.add_new_subject_to_file("ToDoList.txt", subject_name)

    # Pop up a messagebox says the subject is existed
    if added == "Repeated":
        response = messagebox.askyesno(
            "Repeated Subject",
            "It seems like this subject has been already added. Want to add another one?"
        )
        if response == 0:
            window.destroy()
        else:
            entry.delete(0, END)
    # Pop up a messagebox says the subject has been added successfully
    elif added == "Success":
        entry.delete(0, END)
        response = messagebox.showinfo("Successfully Added",
                                       "Done! The new subject has been added")