Exemplo n.º 1
0
    def populate(self, categories_list):
        self.favorites_tab = FavoriteTab(self.notebook, self,
                                         self.favorites_image)
        self.expired_tab = ExpiredTab(self.notebook, self, self.expired_image,
                                      self.favorites_tab)
        self.favorites_tab.set_expired_tab(self.expired_tab)
        for i in range(len(categories_list)):

            new_tab = Tab(self.notebook, categories_list[i], self,
                          self.favorites_tab, self.expired_tab)
            new_tab.populate_tab()
            self.tabs_list.append(new_tab)
    def clean(self):
        used = False
        for tab in self.application.tabs_list:
            if tab.get_category().get_name() == self.entry.get():
                used = True
        if used:
            window = InvalidInputWindow(self.master, self.application,
                                        "This category already exists.")
        else:

            if self.valid_input_checker(self.entry.get()):
                self.value = self.entry.get()
                DatabaseHandler.create_category_database(self.entry.get())
                new_tab = Tab(self.application.get_notebook(),
                              Category(self.entry.get()), self.application,
                              self.favorites_tab, self.expired_tab)
                new_tab.populate_tab()
                self.application.tabs_list.append(new_tab)
                self.top.destroy()
            else:
                window = InvalidInputWindow(
                    self.master, self.application,
                    "Use only capital and lowercase letters,\nnumbers or apostrophe, please."
                )