Mercurial > getan > getan
annotate getan/nodes.py @ 242:81f05202f1b4
Improve debug output when selecting a node
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Tue, 09 Apr 2013 20:43:44 +0200 |
parents | 8e9e894552e8 |
children | bcc5951edaad |
rev | line source |
---|---|
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
2 # |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
3 # (c) 2013 by Björn Ricks <bjoern.ricks@intevation.de> |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
4 # |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
5 # This is Free Software licensed under the terms of GPLv3 or later. |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
6 # For details see LICENSE coming with the source of 'getan'. |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
7 # |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
8 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
9 import logging |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
10 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
11 import urwid |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
12 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
13 from getan.utils import short_time, format_datetime, human_time |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
14 from getan.resources import gettext as _ |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
15 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
16 logger = logging.getLogger(__name__) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
17 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
18 class Node(urwid.WidgetWrap): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
19 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
20 def __init__(self, item): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
21 self.selected = False |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
22 self.focus = False |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
23 self.item = item |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
24 w = urwid.AttrMap(self.get_widget(), None) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
25 self.__super.__init__(w) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
26 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
27 def get_widget(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
28 return urwid.Text(' %s ' % (self.get_item_text()), wrap='clip') |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
29 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
30 def get_item_text(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
31 return str(self.item) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
32 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
33 def update_w(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
34 if self.focus: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
35 if self.selected: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
36 self._w.set_focus_map({None: 'selected focus entry'}) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
37 self._w.set_attr_map({None: 'selected focus entry'}) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
38 else: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
39 self._w.set_focus_map({None: 'focus entry'}) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
40 self._w.set_attr_map({None: 'focus entry'}) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
41 else: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
42 if self.selected: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
43 self._w.set_focus_map({None: 'selected entry'}) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
44 self._w.set_attr_map({None: 'selected entry'}) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
45 else: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
46 self._w.set_focus_map({None: 'entry body'}) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
47 self._w.set_attr_map({None: 'entry body'}) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
48 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
49 def select(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
50 self.selected = not self.selected |
242
81f05202f1b4
Improve debug output when selecting a node
Björn Ricks <bjoern.ricks@intevation.de>
parents:
230
diff
changeset
|
51 logger.debug("Node: update selection of item '%s' selected %s" |
81f05202f1b4
Improve debug output when selecting a node
Björn Ricks <bjoern.ricks@intevation.de>
parents:
230
diff
changeset
|
52 % (self.item, self.selected)) |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
53 self._invalidate() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
54 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
55 def get_item(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
56 return self.item |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
57 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
58 def selectable(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
59 return True |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
60 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
61 def keypress(self, size, key): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
62 if "enter" in key: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
63 self.select() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
64 return None |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
65 return key |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
66 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
67 def render(self, size, focus=False): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
68 self.focus = focus |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
69 self.update_w() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
70 return self._w.render(size, focus) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
71 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
72 def update(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
73 self._w = self.get_widget() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
74 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
75 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
76 class ProjectNode(Node): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
77 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
78 MODES = [ |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
79 (0, _('Total')), |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
80 (1, _('Year')), |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
81 (2, _('Month')), |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
82 (3, _('Week')), |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
83 (4, _('Day')) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
84 ] |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
85 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
86 def __init__(self, proj, mode=3, indent=0): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
87 self.indent = indent |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
88 self.mode = self.MODES[mode] |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
89 super(ProjectNode, self).__init__(proj) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
90 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
91 def get_widget(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
92 time_str = self._get_formatted_time() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
93 proj_desc = self.item.desc |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
94 if proj_desc is None: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
95 proj_desc = "" |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
96 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
97 description = urwid.Text([' ' * self.indent, |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
98 ('project_key', self.item.key), (' '), (proj_desc)], wrap="clip") |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
99 if self._get_time(): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
100 time = urwid.Text('%s (%s)' % (self.mode[1], time_str)) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
101 else: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
102 time = urwid.Text('') |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
103 return urwid.AttrMap(urwid.Columns([description, time]), None) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
104 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
105 def _get_formatted_time(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
106 return human_time(self._get_time()) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
107 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
108 def _get_time(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
109 if self.mode == self.MODES[0]: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
110 return self.item.total |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
111 if self.mode == self.MODES[1]: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
112 return self.item.year() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
113 if self.mode == self.MODES[2]: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
114 return self.item.month() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
115 if self.mode == self.MODES[3]: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
116 return self.item.week() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
117 if self.mode == self.MODES[4]: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
118 return self.item.day() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
119 return self.item.week() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
120 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
121 def switch_time_mode(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
122 tmp = self.mode[0] + 1 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
123 if tmp > 4: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
124 self.mode = self.MODES[0] |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
125 else: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
126 self.mode = self.MODES[tmp] |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
127 self._w = self.get_widget() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
128 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
129 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
130 class EntryNode(Node): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
131 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
132 def __init__(self, entry): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
133 super(EntryNode, self).__init__(entry) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
134 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
135 def get_widget(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
136 logger.debug("EntryNode: update entry '%s'." % self.item.desc) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
137 row = urwid.Text(' %s [%s] %s' \ |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
138 % (format_datetime(self.item.start), |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
139 short_time(self.item.duration().seconds), |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
140 self.item.desc), wrap='clip') |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
141 return urwid.AttrMap(row, None) |