def action_remove_note(self, event):
        """This method deletes the note;
        activated by click on button Remove('X') of the specific note"""
        if messagebox.askyesno('Delete', 'Are you sure?', default='no'):
            del notes_dict[
                self.
                note_dbid]  # deleting note entry from the notes dictionary
            aux_filter_notes(category_filter_ctrlvar.get(),
                             descr_filter_ctrlvar.get())

            clean_display()  # cleaning the display
            display_notes(
            )  # new display - does not contain frame of the deleted note

            db_delete_note(self.note_dbid)  # deleting note record from the DB
def display_notes(event=None):
    """This function is responsible for displaying the notes"""
    clean_display()
    notes_views_lst.clear()

    # building list of objects of type NoteView (i.e. graphic representation of a note)
    notes_views_lst.extend([
        highlight_match(note_view, descr_filter_ctrlvar.get())
        for note_view in [
            NoteView(frm_root.cnvs_notes_display, note_obj)
            for note_obj in notes_to_display_lst
        ]
    ])

    for seqnum, nv in enumerate(notes_views_lst):
        nv.grid(row=seqnum // frm_root.cnvs_notes_display.gridcols_cnt,
                column=seqnum % frm_root.cnvs_notes_display.gridcols_cnt,
                padx=frm_root.note_padding,
                pady=frm_root.note_padding)
    def action_add_note(self, event):
        """This method registers new note;
        activated by click on button Confirm"""
        # reading note details from UI
        category_str = self.cmbx_category.get().strip()
        descr_str = self.entry_description.get().strip()
        date_str = self.entry_date.get().strip()
        priority_str = self.cmbx_priority.get().strip()

        new_note_obj = NotePureData(
            category_str, descr_str, date_str,
            priority_str)  # object of class NotePureData
        notes_dict[
            new_note_obj.
            id] = new_note_obj  # adding new note object to the notes dictionary
        aux_filter_notes(category_filter_ctrlvar.get(),
                         descr_filter_ctrlvar.get())

        display_notes()
        db_insert_note(new_note_obj)  # adding new note to the database
    def action_update_note(self, event):
        """This method updates the note;
        activated by click on button Confirm Update('V') of the specific note frame"""
        self.action_fix_category()
        self.action_priority2bgcolor()

        # collecting details of the displayed note from the control variables
        n_ctgr = self.ctgr_ctrlvar.get().strip()
        n_descr = self.text_note_descr.get(1.0, '1.end').strip()
        n_date = self.date_ctrlvar.get().strip()
        n_priority = self.prrt_ctrlvar.get().strip()

        # overriding value of the note record wuth updated value (TBD note_dbid - proper getter?)
        updated_note_obj = NotePureData(n_ctgr, n_descr, n_date, n_priority,
                                        self.note_dbid)
        notes_dict[self.note_dbid] = updated_note_obj
        messagebox.showinfo('Update', 'done')

        aux_filter_notes(category_filter_ctrlvar.get(),
                         descr_filter_ctrlvar.get())
        display_notes(
        )  # new display - contains details of the updated note (if still meets filtering criteria)
        db_update_note(updated_note_obj)  # updating note record in the DB
    def action_filter_notes(self, event=None):
        """This method displays notes that meet currentl filtering criteria"""

        aux_filter_notes(category_filter_ctrlvar.get(),
                         descr_filter_ctrlvar.get())
        display_notes(event)