Ejemplo n.º 1
0
    def save(self, *args):
        """Save the note."""

        if self.notebody_textinput.text.strip() != '':

            if self.note_name_ti.text != '':

                self._name = self.note_name_ti.text

            if app_variables.active_note is None:  # If we're adding a new note

                # Add note to database
                note_manager.new_obj(self._name,
                                     self.notebody_textinput.text.strip(),
                                     app_variables.active_notebook)

            else:  # If we're editing an existing

                note_manager.update_obj(app_variables.active_note,
                                        name=self._name,
                                        data=self.notebody_textinput.text)

            self.note_name_ti.text = ''
            self.notebody_textinput.text = ''

            # Update note list
            app_variables.notes = note_manager.load()
Ejemplo n.º 2
0
    def save(self, *args):
        """Method to properly save the new notebook."""

        name = self.nb_name.text

        if name:

            self.nb_name.text = ''
            note_manager.new_obj(name, "Notebook", 0)
            app_variables.notes = note_manager.load()
            app_variables.active_notebook = app_variables.notes[-1][0]

            sm.current = 'notebook'
Ejemplo n.º 3
0
    def delete(self, *args):
        """Deletes Note."""

        if app_variables.active_note is not None:  # If this isn't a new note

            note_manager.delete(app_variables.active_note)

            app_variables.notes = note_manager.load()
            app_variables.active_note = None

            # Hacky workaround to deal with save method
            self.notebody_textinput.text = ''

        sm.current = 'notebook'
Ejemplo n.º 4
0
    def delete(self, *args):
        """Method for deleting a notebook"""

        notebook_lbl = self.current_notebook

        if "Delete" not in notebook_lbl.text:

            notebook_lbl.text = "Delete " + app_variables.get_note_obj(
                app_variables.active_notebook)[1] + "?"
            notebook_lbl.color = [1, 0, 0, 1]

        else:

            note_manager.delete(app_variables.active_notebook)
            app_variables.notes = note_manager.load()

            sm.current = 'menu'
Ejemplo n.º 5
0
    def load(self, *args):
        """Loads all notebooks when screen loads."""

        app_variables.notes = note_manager.load()
        print(app_variables.notes)

        app_variables.active_notebook = None
        app_variables.active_note = None
        self.notebooks.clear_widgets()

        child_note_objs = note_manager.get_children(0)

        if len(child_note_objs) > 0:

            for note_obj in child_note_objs:

                bg_color = app_settings.textinput_color

                notebook_btn = Button(text=note_obj[1],
                                      size_hint=(1, None),
                                      background_normal='',
                                      background_color=bg_color,
                                      color=app_settings.text_color,
                                      id=str(note_obj[0]))

                self.notebooks.add_widget(notebook_btn)

                notebook_btn.bind(on_press=lambda button:
                                  self.switch_screen(button))

            #       Buffer
            self.notebooks.add_widget(Label(text="",
                                            size_hint=(0, 1-(len(
                                                child_note_objs)*.1))))

        else:

            self.notebooks.add_widget(Label(text="No Notebooks to display :("))