예제 #1
0
def data_retrieve(touch=None):
    notes.stack.clear_widgets()
    store = DictStore('store13.dat')

    if len(store.keys()) <= 1:
        pass
    else:
        index_stamp = store['index']['num']
        index_stamp.reverse()
        for x in index_stamp:
            timestamp = x
            notetext = store[x]['note']
            notetime = store[x]['notetime']
            notecolor_dt = store[x]['color']

            #Note
            note = Note(notetext[10:], timestamp)

            #NoteButton
            notebutton = note.button
            notebutton.background_color = notecolor_dt

            notebutton.name = timestamp
            if len(notetext) >= 20:
                notebutton.text = notetext[:
                                           20] + '...' + '\n                                               %s' % notetime
            else:
                notebutton.text = notetext + '\n                                                %s' % notetime
            notes.stack.add_widget(notebutton)

            #NoteScreen
            notescreen = note.notescreen
            notescreen.name = timestamp
            notescreen.txt.text = notetext
            notescreen_color = notebutton.background_color
            notescreen_color = list(notescreen_color)
            notescreen.dropdown.main.background_color = notescreen_color
            sm.add_widget(notescreen)

            def delNote(touch):
                #Deleting on Screen
                var = sm.current
                toNotesright(touch)
                #
                #
                #delete notescreen
                for item in sm.children:
                    if item.name == var:
                        sm.remove_widget(item)

                #delete button
                for item in notes.stack.children:
                    if item.name == var:
                        notes.stack.remove_widget(item)

                #Deleting from shelve
                store = DictStore('store13.dat')
                #removing index

                mylist = store['index']['num']
                mylist.remove(var)
                store['index']['num'] = mylist

                #removing df item
                store.delete(var)

            def note_Update(touch):
                curnote = sm.children[0]

                newnotetext = curnote.txt.text

                notecolor_up_dt = curnote.dropdown.main.background_color
                notecolor_up_dt = list(notecolor_up_dt)

                if curnote.txt.text != '':

                    var = sm.current
                    sm.transition = WipeTransition()
                    sm.current = 'notes'

                    store = DictStore('store13.dat')
                    mylist = store['index']['num']
                    mylist.remove(var)
                    store['index']['num'] = mylist

                    #removing df item
                    store.delete(var)
                    #delete notescreen
                    for item in sm.children:
                        if item.name == var:
                            sm.remove_widget(item)

                    #delete button
                    for item in notes.stack.children:
                        if item.name == var:
                            notes.stack.remove_widget(item)

                            #adding new note
                            #working out timestamp
                            timenow = time.asctime(time.localtime(time.time()))
                            timenow = str(timenow)
                            timeraw = timenow[7:19]
                            strip = timeraw.replace(' ', '')
                            timemark = strip.replace(':', '')
                            timestamp = timemark
                            notetime = 'On ' + timenow[:10] + ' at ' + timenow[
                                11:19]

                            #StoreData
                            if 'index' in store.keys():
                                card = store['index']['num']
                                card.append(timestamp)
                                store['index']['num'] = card
                            else:
                                store['index'] = {'num': []}
                                card = store['index']['num']
                                card.append(timestamp)
                                store['index']['num'] = card

                            store[timestamp] = {
                                'note': newnotetext,
                                'notetime': notetime,
                                'color': notecolor_up_dt
                            }

                            #Note
                            note = Note(newnotetext[10:], timestamp)
                            #NoteButton
                            notebutton = note.button
                            notebutton.background_color = notecolor_up_dt
                            notebutton.name = timestamp
                            if len(newnotetext) > 20:
                                notebutton.text = newnotetext[:
                                                              20] + '...' + '\n                                               %s' % notetime
                            else:
                                notebutton.text = newnotetext + '\n                                                ' + notetime
                            notes.stack.add_widget(notebutton,
                                                   len(notes.stack.children))

                            #NoteScreen
                            notescreen = note.notescreen
                            notescreen.name = timestamp
                            notescreen.txt.text = newnotetext
                            notescreen.dropdown.main.background_color = notecolor_up_dt
                            sm.add_widget(notescreen)
                            notescreen.update_button.bind(
                                on_release=note_Update)
                            notescreen.actionprevious.bind(
                                on_release=toNotesright)
                            notescreen.delete_button.bind(on_release=delNote)

            # binding back, delete and update on notescreen
            notescreen.actionprevious.bind(on_release=toNotesright)
            notescreen.delete_button.bind(on_release=delNote)
            notescreen.update_button.bind(on_release=note_Update)
예제 #2
0
        def note_Update(touch):
            curnote = sm.children[0]
            newnotetext = curnote.txt.text
            notecolor_nw_up = curnote.dropdown.main.background_color
            notecolor_nw_up = list(notecolor_nw_up)

            if curnote.txt.text != '':

                var = sm.current
                sm.transition = WipeTransition()
                sm.current = 'notes'

                store = DictStore('store13.dat')
                mylist = store['index']['num']
                mylist.remove(var)
                store['index']['num'] = mylist

                #removing df item
                store.delete(var)
                #delete notescreen
                for item in sm.children:
                    if item.name == var:
                        sm.remove_widget(item)

                #delete button
                for item in notes.stack.children:
                    if item.name == var:
                        notes.stack.remove_widget(item)

                        #adding new note
                        #working out timestamp
                        timenow = time.asctime(time.localtime(time.time()))
                        timenow = str(timenow)
                        timeraw = timenow[7:19]
                        strip = timeraw.replace(' ', '')
                        timemark = strip.replace(':', '')
                        timestamp = timemark
                        notetime = 'On ' + timenow[:10] + ' at ' + timenow[
                            11:19]

                        #StoreData
                        if 'index' in store.keys():
                            card = store['index']['num']
                            card.append(timestamp)
                            store['index']['num'] = card
                        else:
                            store['index'] = {'num': []}
                            card = store['index']['num']
                            card.append(timestamp)
                            store['index']['num'] = card

                        store[timestamp] = {
                            'note': newnotetext,
                            'notetime': notetime,
                            'color': notecolor_nw_up
                        }

                        #Note
                        note = Note(newnotetext[10:], timestamp)
                        #NoteButton
                        notebutton = note.button
                        notebutton.background_color = notecolor_nw_up
                        notebutton.name = timestamp
                        if len(newnotetext) > 20:
                            notebutton.text = newnotetext[:
                                                          20] + '...' + '\n                                               %s' % notetime
                        else:
                            notebutton.text = newnotetext + '\n                                                ' + notetime
                        notes.stack.add_widget(notebutton,
                                               len(notes.stack.children))

                        #NoteScreen
                        notescreen = note.notescreen
                        notescreen.name = timestamp
                        notescreen.txt.text = newnotetext
                        notescreen.dropdown.main.background_color = notecolor_nw_up
                        sm.add_widget(notescreen)
                        notescreen.update_button.bind(on_release=note_Update)
                        notescreen.actionprevious.bind(on_release=toNotesright)
                        notescreen.delete_button.bind(on_release=delNote)