Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
3e7b2479
Commit
3e7b2479
authored
Jan 06, 2016
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move markup method outside class
parent
3513603a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
19 deletions
+24
-19
topydo/ui/TodoWidget.py
topydo/ui/TodoWidget.py
+24
-19
No files found.
topydo/ui/TodoWidget.py
View file @
3e7b2479
...
...
@@ -20,6 +20,28 @@ from topydo.ui.Colors import color_map256
import
urwid
def
_markup
(
p_todo
,
p_focus
):
"""
Returns an attribute spec for the colors that correspond to the given todo
item.
"""
priority_colors
=
config
().
priority_colors
()
color_map
=
color_map256
()
try
:
# retrieve the assigned value in the config file
fg_color
=
priority_colors
[
p_todo
.
priority
()]
# convert to a color that urwid understands
fg_color
=
color_map
[
fg_color
]
except
KeyError
:
fg_color
=
'black'
if
p_focus
else
'default'
bg_color
=
'light gray'
if
p_focus
else
'default'
return
urwid
.
AttrSpec
(
fg_color
,
bg_color
,
256
)
class
TodoWidget
(
urwid
.
WidgetWrap
):
def
__init__
(
self
,
p_todo
,
p_number
):
# pass a None todo list, since we won't use %i or %I here
...
...
@@ -44,29 +66,12 @@ class TodoWidget(urwid.WidgetWrap):
self
.
widget
=
urwid
.
AttrMap
(
self
.
columns
,
self
.
_markup
(
p_todo
,
False
),
# no focus
self
.
_markup
(
p_todo
,
True
)
# focus
_markup
(
p_todo
,
False
),
# no focus
_markup
(
p_todo
,
True
)
# focus
)
super
().
__init__
(
self
.
widget
)
def
_markup
(
self
,
p_todo
,
p_focus
):
priority_colors
=
config
().
priority_colors
()
color_map
=
color_map256
()
try
:
# retrieve the assigned value in the config file
fg_color
=
priority_colors
[
p_todo
.
priority
()]
# convert to a color that urwid understands
fg_color
=
color_map
[
fg_color
]
except
KeyError
:
fg_color
=
'black'
if
p_focus
else
'default'
bg_color
=
'light gray'
if
p_focus
else
'default'
return
urwid
.
AttrSpec
(
fg_color
,
bg_color
,
256
)
def
keypress
(
self
,
p_size
,
p_key
):
"""
Override keypress to prevent the wrapped Columns widget to
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment