Skip to content
This repository has been archived by the owner on Jan 3, 2018. It is now read-only.

Commit

Permalink
add theming option, close #15
Browse files Browse the repository at this point in the history
set version to v0.7
  • Loading branch information
h4llow3En committed Nov 8, 2015
1 parent 892febe commit cee3a4f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
' ({}.{} detected).'.format(*version))
sys.exit(-1)

VERSION = '0.5.1'
VERSION = '0.7'


def install(mute=True):
Expand Down
5 changes: 5 additions & 0 deletions tdo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ def main(argv=sys.argv):
displayhelp()
elif argv[1] == 'update':
todolist.update()
elif argv[1] == 'themes':
todolist.listthemes()
elif argv[1] == 'settheme':
settings = todolist.settheme(argv, settings)
todolist.savesettings(settings)
else:
# something wrong? Help!
displayhelp()
Expand Down
1 change: 1 addition & 0 deletions tdo/todolist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from .maintenance import *
from .help import *
from .printing import *
from .theme import *
4 changes: 3 additions & 1 deletion tdo/todolist/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
tdo lists List all lists with a statistic of undone/done tasks.
tdo help Display this help.
tdo reset DANGER ZONE. Delete all your todos and todo lists.
tdo update Updates tdo to the latest release.'''
tdo update Updates tdo to the latest release.
tdo themes Shows all available themes.
tdo settheme id Set the theme to <id>'''
8 changes: 5 additions & 3 deletions tdo/todolist/printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ def printtask(num_len, task_id, name, table, tick, done=False):
donestr = '[x]' if done else '[ ]'

if table:
print(' {done} |{id} | {task}'.format(done=donestr,
id=printedId,
task=tasklist[0]))
space = (5 - num_len) if spaces == 0 else spaces
print(' {done} |{space}{id} | {task}'.format(done=donestr,
space=' ' * space,
id=printedId,
task=tasklist[0]))
if len(tasklist) > 1:
for element in range(len(tasklist) - 1):
print(' |{idlen}| {task}'.format(idlen=' ' * (maxLen - 6),
Expand Down
44 changes: 44 additions & 0 deletions tdo/todolist/theme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from .listing import listall
import json

num_len = 1
examplelist = {'default': {
'1': ['This is an example', False], '2': ['This one is done', True]}}
tempsettings = {'globalid': 1, 'table': False, 'tick': False}


def listthemes():
print('\033[1m\033[91mTheme 1:\033[0m')
listall(examplelist, num_len, tempsettings)
print('\033[1m\033[91mTheme 2:\033[0m')
tempsettings['tick'] = True
listall(examplelist, num_len, tempsettings)
print('\033[1m\033[91mTheme 3:\033[0m')
tempsettings['tick'] = False
tempsettings['table'] = True
listall(examplelist, num_len, tempsettings)
print('\033[1m\033[91mTheme 4:\033[0m')
tempsettings['tick'] = True
listall(examplelist, num_len, tempsettings)


def settheme(argv, settings):
if len(argv) < 3:
print('You have to select a theme.\nYou can get a list of all themes \
with "themes"')
elif argv[2] == '1':
settings['tick'] = False
settings['table'] = False
elif argv[2] == '2':
settings['tick'] = True
settings['table'] = False
elif argv[2] == '3':
settings['tick'] = False
settings['table'] = True
elif argv[2] == '4':
settings['tick'] = True
settings['table'] = True
else:
print('There is no theme {id}.\nYou can get a list of all themes \
with "themes"'.format(id=argv[2]))
return settings

0 comments on commit cee3a4f

Please sign in to comment.