asc ()) # update entries after operations elif choice = 'n' : index = 1 elif choice = 'p' : index -= 1 main_menu = OrderedDict () sub_menu = OrderedDict () if _name_ = '_main_' : initialize () menu_loop () db. _doc_ )) print ( 'q) Quit' ) choice = input ( ' \n Action: ' ) if choice in main_menu : try : main_menu ( index, entries ) except ZeroDivisionError : continue entries = ToDo. strftime ( ' %d /%B/%Y' ) if timestamp != prev_timestamp : # same timestamps get printed only once print ( ' \n ' ) print ( timestamp ) print ( '=' * len ( timestamp )) prev_timestamp = timestamp if ind = index : # placing the selection tick tick = '> ' else : tick = ' ' print ( ''. create_tables (, safe = True ) def view_entries ( index, entries, single_entry ): """"View to-do list""" clear () index = index % len ( entries ) # determines which entry is selected for modification if single_entry : # to see only 1 entry entries = ] index = 0 else : print ( ' \n MY TO-DO LIST' ) print ( '=' * 40 ) prev_timestamp = None for ind, entry in enumerate ( entries ): timestamp = entry. name = 'nt' else 'clear' ) def initialize (): """Connect to database, build tables if they don't exist""" db. Lastly, we query the database and return the query result to the client to make sure the operation is success. After that, we create the todo object and persist it in our database. now ) done = BooleanField ( default = False ) protected = BooleanField ( default = False ) class Meta : database = db def clear (): """Clear the display""" os. On line 16, we obtain the value from the POST operation with r.FormValue('parameter').We use the value as the description to insert into our database. 'done' indicates that it's been completed, 'protected' makes it immune to cleanup""" task = CharField ( max_length = 255 ) timestamp = DateTimeField ( default = datetime. we can also arrange our task on a priority basis by simply drag and drop it. A cleanup feature enables you to delete completed tasks which are more than a week old - unless you have flagged them as 'protected'.""" from collections import OrderedDict import datetime import os from peewee import * db = SqliteDatabase ( 'to_do_list.db' ) class ToDo ( Model ): """Model for creating to-do items. when our task gets completed after then we can remove that task from our list by simply clicking two times on it. """To-do list where you can chronologically add your tasks, modify them and mark if they have been completed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |