Example #1
0
    def __init__(self, deck, master=None):
        super().__init__(master)
        self.app = master
        self.selectedDeck = deck
        self.data = Data()
        self.deckService = DeckService(Data())
        self.clear()

        self.fontTitle = tkFont.Font(family="Lucida Grande", size=20)
        self.title = tkinter.Label(text="AnkiLike - Creator Mode",
                                   font=self.fontTitle)
        self.str_line = "_" * 20
        self.line = tkinter.Label(text=self.str_line, font=self.fontTitle)
        self.frame_menu = tkinter.LabelFrame(self.app, text="Delete card")
        self.form_one = tkinter.Frame(self.frame_menu)
        self.label_choose = tkinter.Label(self.form_one, text="Delete card : ")
        self.tst = ttk.Combobox(self.form_one)
        self.tst['values'] = [c.title for c in self.selectedDeck._get_cards()]
        self.delete_btn = tkinter.Button(self.frame_menu,
                                         text="Delete",
                                         command=self.delete)
        self.back_btn = tkinter.Button(self.frame_menu,
                                       text="Back",
                                       command=self.load_back_view)

        self.create_view()
Example #2
0
    def setUp(self) -> None:
        self.card = Card("card title", "question", "answer", 1)
        self.deck = Deck("deck name", [self.card])
        self.data = Data()
        self.data.box = Box("box name", [self.deck])

        self.deck_service = DeckService(self.data)
Example #3
0
    def __init__(self, master=None):
        super().__init__(master)
        self.app = master
        self.clear()

        self.deckService = DeckService(Data())

        self.fontTitle = tkFont.Font(family="Lucida Grande", size=20)
        self.title = tkinter.Label(text="AnkiLike - Creator Mode",
                                   font=self.fontTitle)
        self.str_line = "_" * 20
        self.line = tkinter.Label(text=self.str_line, font=self.fontTitle)
        self.frame_menu = tkinter.LabelFrame(self.app, text="Create Deck")
        self.form_one = tkinter.Frame(self.frame_menu)
        self.label_name = tkinter.Label(self.form_one, text="Name : ")
        self.var_name_entry = tkinter.StringVar()
        self.name_entry = tkinter.Entry(self.form_one,
                                        textvariable=self.var_name_entry)
        self.save_btn = tkinter.Button(self.frame_menu,
                                       text="Save",
                                       command=self.save_deck)
        self.back_btn = tkinter.Button(self.frame_menu,
                                       text="Back",
                                       command=self.load_back_view)
        self.confirm_text = tkinter.StringVar()
        self.confirm_label = tkinter.Label(self.app,
                                           textvariable=self.confirm_text)

        self.create_view()
Example #4
0
class CreateDeck(tkinter.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.app = master
        self.clear()

        self.deckService = DeckService(Data())

        self.fontTitle = tkFont.Font(family="Lucida Grande", size=20)
        self.title = tkinter.Label(text="AnkiLike - Creator Mode",
                                   font=self.fontTitle)
        self.str_line = "_" * 20
        self.line = tkinter.Label(text=self.str_line, font=self.fontTitle)
        self.frame_menu = tkinter.LabelFrame(self.app, text="Create Deck")
        self.form_one = tkinter.Frame(self.frame_menu)
        self.label_name = tkinter.Label(self.form_one, text="Name : ")
        self.var_name_entry = tkinter.StringVar()
        self.name_entry = tkinter.Entry(self.form_one,
                                        textvariable=self.var_name_entry)
        self.save_btn = tkinter.Button(self.frame_menu,
                                       text="Save",
                                       command=self.save_deck)
        self.back_btn = tkinter.Button(self.frame_menu,
                                       text="Back",
                                       command=self.load_back_view)
        self.confirm_text = tkinter.StringVar()
        self.confirm_label = tkinter.Label(self.app,
                                           textvariable=self.confirm_text)

        self.create_view()

    def create_view(self):
        self.title.pack()
        self.line.pack()
        self.frame_menu.pack(pady=20)
        self.form_one.pack()
        self.label_name.pack(side="left")
        self.name_entry.pack(pady=10)
        self.save_btn.pack(pady=10)
        self.back_btn.pack(padx=100, pady=25)
        self.confirm_label.pack(pady=40)

    def save_deck(self):
        to_validate = self.var_name_entry.get()
        if not to_validate:
            self.confirm_text.set("Error : name cannot be blank")
            return

        deck = Deck(self.var_name_entry.get(), [])
        self.deckService.add_deck(deck)
        CreateCard(deck, master=self.app)
        # self.load_back_view()

    def load_back_view(self):
        CreatorView(self.app)

    def clear(self):
        for widget in self.app.winfo_children():
            widget.pack_forget()
Example #5
0
class DeleteCard(tkinter.Frame):
    def __init__(self, deck, master=None):
        super().__init__(master)
        self.app = master
        self.selectedDeck = deck
        self.data = Data()
        self.deckService = DeckService(Data())
        self.clear()

        self.fontTitle = tkFont.Font(family="Lucida Grande", size=20)
        self.title = tkinter.Label(text="AnkiLike - Creator Mode",
                                   font=self.fontTitle)
        self.str_line = "_" * 20
        self.line = tkinter.Label(text=self.str_line, font=self.fontTitle)
        self.frame_menu = tkinter.LabelFrame(self.app, text="Delete card")
        self.form_one = tkinter.Frame(self.frame_menu)
        self.label_choose = tkinter.Label(self.form_one, text="Delete card : ")
        self.tst = ttk.Combobox(self.form_one)
        self.tst['values'] = [c.title for c in self.selectedDeck._get_cards()]
        self.delete_btn = tkinter.Button(self.frame_menu,
                                         text="Delete",
                                         command=self.delete)
        self.back_btn = tkinter.Button(self.frame_menu,
                                       text="Back",
                                       command=self.load_back_view)

        self.create_view()

    def create_view(self):
        self.title.pack()
        self.line.pack()
        self.frame_menu.pack(pady=20)
        self.form_one.pack()
        self.label_choose.pack(side="left", pady=15, padx=30)
        self.tst.pack(pady=15, padx=5)
        self.delete_btn.pack(pady=10)
        self.back_btn.pack(padx=100, pady=25)

    def delete(self):
        card_name = self.tst.get()
        for c in self.selectedDeck._get_cards():
            if c.title == card_name:
                self.deckService.delete_card_in_deck(self.selectedDeck, c)
                self.load_back_view()
        return

    def load_back_view(self):
        from ui.creatorviews.CardManagement import CardManagement
        CardManagement(self.selectedDeck, self.app)

    def clear(self):
        for widget in self.app.winfo_children():
            widget.pack_forget()
Example #6
0
class DeleteDeck(tkinter.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.app = master
        self.data = Data()
        self.deckService = DeckService(Data())
        self.clear()

        self.fontTitle = tkFont.Font(family="Lucida Grande", size=20)
        self.title = tkinter.Label(text="AnkiLike - Creator Mode",
                                   font=self.fontTitle)
        self.str_line = "_" * 20
        self.line = tkinter.Label(text=self.str_line, font=self.fontTitle)
        self.frame_menu = tkinter.LabelFrame(self.app, text="Delete Deck")
        self.form_one = tkinter.Frame(self.frame_menu)
        self.label_choose = tkinter.Label(self.form_one, text="Delete deck : ")
        self.tst = ttk.Combobox(self.form_one)
        self.tst['values'] = [d._get_name() for d in self.data.box.decks]
        self.delete_btn = tkinter.Button(self.frame_menu,
                                         text="Delete",
                                         command=self.delete)
        self.back_btn = tkinter.Button(self.frame_menu,
                                       text="Back",
                                       command=self.load_back_view)

        self.create_view()

    def create_view(self):
        self.title.pack()
        self.line.pack()
        self.frame_menu.pack(pady=20)
        self.form_one.pack()
        self.label_choose.pack(side="left", pady=15, padx=30)
        self.tst.pack(pady=15, padx=5)
        self.delete_btn.pack(pady=10)
        self.back_btn.pack(padx=100, pady=25)

    def delete(self):
        deck = self.deckService.find_deck_by_name(self.tst.get())
        self.deckService.delete_deck(deck)
        self.load_back_view()

    def load_back_view(self):
        CreatorView(self.app)

    def clear(self):
        for widget in self.app.winfo_children():
            widget.pack_forget()
Example #7
0
    def __init__(self, selectedDeck, master=None):
        super().__init__(master)
        self.selectedDeck = selectedDeck
        self.app = master
        self.clear()

        self.deckService = DeckService(Data())

        self.fontTitle = tkFont.Font(family="Lucida Grande", size=20)
        self.title = tkinter.Label(text="AnkiLike - Creator Mode",
                                   font=self.fontTitle)
        self.str_line = "_" * 20
        self.str_deck = tkinter.Label(text="Card management of deck : " +
                                      self.selectedDeck.name)
        self.line = tkinter.Label(text=self.str_line, font=self.fontTitle)
        self.frame_menu = tkinter.LabelFrame(self.app, text="Deck management")
        self.create_card = tkinter.Button(self.frame_menu,
                                          text="Add card",
                                          command=self.load_add_card_view)
        self.update_card = tkinter.Button(self.frame_menu,
                                          text="Update card",
                                          command=self.load_update_card_view)
        self.delete_card = tkinter.Button(self.frame_menu,
                                          text="Delete card",
                                          command=self.load_del_card_view)
        self.back_btn = tkinter.Button(self.frame_menu,
                                       text="Back",
                                       command=self.load_back_view)

        self.create_view()
Example #8
0
    def __init__(self, selectedDeck, master=None):
        super().__init__(master)
        self.selectedDeck = selectedDeck
        self.app = master
        self.clear()

        self.deckService = DeckService(Data())

        self.fontTitle = tkFont.Font(family="Lucida Grande", size=20)
        self.title = tkinter.Label(text="AnkiLike - Creator Mode",
                                   font=self.fontTitle)
        self.str_line = "_" * 20
        self.str_deck = tkinter.Label(text="Add card to deck : " +
                                      self.selectedDeck.name)
        self.line = tkinter.Label(text=self.str_line, font=self.fontTitle)
        self.frame_menu = tkinter.LabelFrame(self.app, text="Create card")
        self.form_one = tkinter.Frame(self.frame_menu)
        self.form_two = tkinter.Frame(self.frame_menu)
        self.form_three = tkinter.Frame(self.frame_menu)

        self.label_title = tkinter.Label(self.form_one, text="Title : ")
        self.var_title_entry = tkinter.StringVar()
        self.title_entry = tkinter.Entry(self.form_one,
                                         textvariable=self.var_title_entry)

        self.label_quest = tkinter.Label(self.form_two, text="Question : ")
        self.var_quest_entry = tkinter.StringVar()
        self.quest_entry = tkinter.Entry(self.form_two,
                                         textvariable=self.var_quest_entry)

        self.label_answer = tkinter.Label(self.form_three, text="Answer : ")
        self.var_answer_entry = tkinter.StringVar()
        self.answer_entry = tkinter.Entry(self.form_three,
                                          textvariable=self.var_answer_entry)

        self.save_btn = tkinter.Button(self.frame_menu,
                                       text="Save",
                                       command=self.save_card)
        self.back_btn = tkinter.Button(self.frame_menu,
                                       text="Back",
                                       command=self.load_back_view)
        self.error_text = tkinter.StringVar()
        self.error_label = tkinter.Label(self.app,
                                         textvariable=self.error_text)

        self.create_view()
Example #9
0
    def __init__(self, master=None):
        super().__init__(master)
        self.app = master
        self.clear()
        self.data = Data()
        self.deckService = DeckService(Data())

        # Nominal view
        self.fontTitle = tkFont.Font(family="Lucida Grande", size=20)
        self.title = tkinter.Label(text="AnkiLike - Creator Mode",
                                   font=self.fontTitle)
        self.str_line = "_" * 20
        self.frame_menu = tkinter.LabelFrame(self.app, text="Deck Management")
        self.line = tkinter.Label(text=self.str_line, font=self.fontTitle)
        self.form_one = tkinter.Frame(self.frame_menu)
        self.label_choose = tkinter.Label(self.form_one,
                                          text="Choose your deck : ")
        self.tst = ttk.Combobox(self.form_one)
        self.tst['values'] = [d._get_name() for d in self.data.box.decks]
        self.save_btn = tkinter.Button(self.frame_menu,
                                       text="Manage cards",
                                       command=self.manage)
        self.rename_btn = tkinter.Button(self.frame_menu,
                                         text="Rename",
                                         command=self.rename_view)
        self.back_btn = tkinter.Button(self.frame_menu,
                                       text="Back",
                                       command=self.load_back_view)

        # Rename view
        self.clear()
        self.rename_label = tkinter.Label(self.form_one, text="Name : ")
        self.var_name_entry = tkinter.StringVar()
        self.input_rename = tkinter.Entry(self.form_one,
                                          textvariable=self.var_name_entry)

        self.create_view_nominal()
Example #10
0
class DeckServiceTest(unittest.TestCase):
    def setUp(self) -> None:
        self.card = Card("card title", "question", "answer", 1)
        self.deck = Deck("deck name", [self.card])
        self.data = Data()
        self.data.box = Box("box name", [self.deck])

        self.deck_service = DeckService(self.data)

    def test_get_deck_should_return_deck_present_in_data_box(self):
        current_decks = self.data.box.decks
        current_decks.append(Deck("2nd deck", [self.card]))
        self.data.box.decks = current_decks

        self.assertIsInstance(self.deck_service.find_deck_by_index(0), Deck,
                              "incorrect deck instance")
        self.assertEqual(self.deck_service.find_deck_by_index(0), self.deck,
                         "incorrect deck value")
        self.assertEqual(
            self.deck_service.find_deck_by_index(1).name, "2nd deck",
            "incorrect deck value")

    def test_get_decks_should_not_raise_exception_when_index_out_bound_number_decks(
            self):
        number_deck = len(self.data.box.decks)
        try:
            self.deck_service.find_deck_by_index(number_deck)
        except IndexError:
            self.fail(
                "deck_service.get_deck({0}) raised IndexError unexpectedly!".
                format(number_deck))

    def test_get_decks_should_return_None_when_index_out_bound_number_decks(
            self):
        number_deck = len(self.data.box.decks)
        self.assertIsNone(self.deck_service.find_deck_by_index(number_deck),
                          "deck value is not None")
Example #11
0
class CreateCard(tkinter.Frame):
    def __init__(self, selectedDeck, master=None):
        super().__init__(master)
        self.selectedDeck = selectedDeck
        self.app = master
        self.clear()

        self.deckService = DeckService(Data())

        self.fontTitle = tkFont.Font(family="Lucida Grande", size=20)
        self.title = tkinter.Label(text="AnkiLike - Creator Mode",
                                   font=self.fontTitle)
        self.str_line = "_" * 20
        self.str_deck = tkinter.Label(text="Add card to deck : " +
                                      self.selectedDeck.name)
        self.line = tkinter.Label(text=self.str_line, font=self.fontTitle)
        self.frame_menu = tkinter.LabelFrame(self.app, text="Create card")
        self.form_one = tkinter.Frame(self.frame_menu)
        self.form_two = tkinter.Frame(self.frame_menu)
        self.form_three = tkinter.Frame(self.frame_menu)

        self.label_title = tkinter.Label(self.form_one, text="Title : ")
        self.var_title_entry = tkinter.StringVar()
        self.title_entry = tkinter.Entry(self.form_one,
                                         textvariable=self.var_title_entry)

        self.label_quest = tkinter.Label(self.form_two, text="Question : ")
        self.var_quest_entry = tkinter.StringVar()
        self.quest_entry = tkinter.Entry(self.form_two,
                                         textvariable=self.var_quest_entry)

        self.label_answer = tkinter.Label(self.form_three, text="Answer : ")
        self.var_answer_entry = tkinter.StringVar()
        self.answer_entry = tkinter.Entry(self.form_three,
                                          textvariable=self.var_answer_entry)

        self.save_btn = tkinter.Button(self.frame_menu,
                                       text="Save",
                                       command=self.save_card)
        self.back_btn = tkinter.Button(self.frame_menu,
                                       text="Back",
                                       command=self.load_back_view)
        self.error_text = tkinter.StringVar()
        self.error_label = tkinter.Label(self.app,
                                         textvariable=self.error_text)

        self.create_view()

    def create_view(self):
        self.title.pack()
        self.line.pack()
        self.str_deck.pack()
        self.frame_menu.pack(pady=20)
        self.form_one.pack()
        self.form_two.pack()
        self.form_three.pack()
        self.label_title.pack(side="left")
        self.title_entry.pack(pady=10)
        self.label_quest.pack(side="left")
        self.quest_entry.pack(pady=10)
        self.label_answer.pack(side="left")
        self.answer_entry.pack(pady=10)
        self.save_btn.pack(pady=10)
        self.back_btn.pack(padx=100, pady=25)
        self.error_label.pack(pady=40)

    def save_card(self):
        if not self.var_title_entry.get() or not self.var_quest_entry.get(
        ) or not self.var_answer_entry.get():
            self.error_text.set("Error : you need to complete every field")
            return

        card = Card(self.var_title_entry.get(), self.var_quest_entry.get(),
                    self.var_answer_entry.get())
        self.deckService.add_card_to_deck(self.selectedDeck, card)
        self.load_back_view()

    def load_back_view(self):
        from ui.creatorviews.CardManagement import CardManagement
        CardManagement(self.selectedDeck, master=self.app)

    def clear(self):
        for widget in self.app.winfo_children():
            widget.pack_forget()
Example #12
0
class ManageDeck(tkinter.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.app = master
        self.clear()
        self.data = Data()
        self.deckService = DeckService(Data())

        # Nominal view
        self.fontTitle = tkFont.Font(family="Lucida Grande", size=20)
        self.title = tkinter.Label(text="AnkiLike - Creator Mode",
                                   font=self.fontTitle)
        self.str_line = "_" * 20
        self.frame_menu = tkinter.LabelFrame(self.app, text="Deck Management")
        self.line = tkinter.Label(text=self.str_line, font=self.fontTitle)
        self.form_one = tkinter.Frame(self.frame_menu)
        self.label_choose = tkinter.Label(self.form_one,
                                          text="Choose your deck : ")
        self.tst = ttk.Combobox(self.form_one)
        self.tst['values'] = [d._get_name() for d in self.data.box.decks]
        self.save_btn = tkinter.Button(self.frame_menu,
                                       text="Manage cards",
                                       command=self.manage)
        self.rename_btn = tkinter.Button(self.frame_menu,
                                         text="Rename",
                                         command=self.rename_view)
        self.back_btn = tkinter.Button(self.frame_menu,
                                       text="Back",
                                       command=self.load_back_view)

        # Rename view
        self.clear()
        self.rename_label = tkinter.Label(self.form_one, text="Name : ")
        self.var_name_entry = tkinter.StringVar()
        self.input_rename = tkinter.Entry(self.form_one,
                                          textvariable=self.var_name_entry)

        self.create_view_nominal()

    def create_view_nominal(self):
        self.title.pack()
        self.line.pack()
        self.frame_menu.pack(pady=20)
        self.form_one.pack()
        self.label_choose.pack(side="left", pady=15, padx=30)
        self.tst.pack(pady=15, padx=5)
        self.save_btn.pack(pady=10)
        self.rename_btn.pack(pady=10)
        self.back_btn.pack(padx=100, pady=25)

    def rename_view(self):
        deck = self.deckService.find_deck_by_name(self.tst.get())
        if deck:
            RenameDeck(deck, self.app)

    def manage(self):
        deck = self.deckService.find_deck_by_name(self.tst.get())
        if deck:
            CardManagement(deck, master=self.app)

    def load_back_view(self):
        CreatorView(self.app)

    def clear(self):
        for widget in self.app.winfo_children():
            widget.pack_forget()