Mercurial > getan > getan
annotate getan/nodes.py @ 453:ceb5909b106e
Backed out changeset ab3c63877862
Because Magnus accidently committed some experimental code pieces.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Fri, 26 Jan 2018 17:23:01 +0100 |
parents | ab3c63877862 |
children | 050ffdec60d9 |
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 |
304
c7f9997a5492
Fix codingstyle for pep8
Björn Ricks <bjoern.ricks@intevation.de>
parents:
273
diff
changeset
|
18 |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
19 class Node(urwid.WidgetWrap): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
20 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
21 def __init__(self, item): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
22 self.selected = False |
256
bcc5951edaad
Fix compatibility with urwid 1.1
Björn Ricks <bjoern.ricks@intevation.de>
parents:
242
diff
changeset
|
23 self.has_focus = False |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
24 self.item = item |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
25 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
|
26 self.__super.__init__(w) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
27 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
28 def get_widget(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
29 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
|
30 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
31 def get_item_text(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
32 return str(self.item) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
33 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
34 def update_w(self): |
256
bcc5951edaad
Fix compatibility with urwid 1.1
Björn Ricks <bjoern.ricks@intevation.de>
parents:
242
diff
changeset
|
35 if self.has_focus: |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
36 if self.selected: |
321
6e72a6b5e94f
Update mapping for foreground and background color settings of nodes
Björn Ricks <bjoern.ricks@intevation.de>
parents:
304
diff
changeset
|
37 self._w.set_focus_map({None: 'selected_focus_entry'}) |
6e72a6b5e94f
Update mapping for foreground and background color settings of nodes
Björn Ricks <bjoern.ricks@intevation.de>
parents:
304
diff
changeset
|
38 self._w.set_attr_map({None: 'selected_focus_entry'}) |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
39 else: |
321
6e72a6b5e94f
Update mapping for foreground and background color settings of nodes
Björn Ricks <bjoern.ricks@intevation.de>
parents:
304
diff
changeset
|
40 self._w.set_focus_map({None: 'focus_entry'}) |
6e72a6b5e94f
Update mapping for foreground and background color settings of nodes
Björn Ricks <bjoern.ricks@intevation.de>
parents:
304
diff
changeset
|
41 self._w.set_attr_map({None: 'focus_entry'}) |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
42 else: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
43 if self.selected: |
321
6e72a6b5e94f
Update mapping for foreground and background color settings of nodes
Björn Ricks <bjoern.ricks@intevation.de>
parents:
304
diff
changeset
|
44 self._w.set_focus_map({None: 'selected_entry'}) |
6e72a6b5e94f
Update mapping for foreground and background color settings of nodes
Björn Ricks <bjoern.ricks@intevation.de>
parents:
304
diff
changeset
|
45 self._w.set_attr_map({None: 'selected_entry'}) |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
46 else: |
321
6e72a6b5e94f
Update mapping for foreground and background color settings of nodes
Björn Ricks <bjoern.ricks@intevation.de>
parents:
304
diff
changeset
|
47 self._w.set_focus_map({None: 'entry'}) |
6e72a6b5e94f
Update mapping for foreground and background color settings of nodes
Björn Ricks <bjoern.ricks@intevation.de>
parents:
304
diff
changeset
|
48 self._w.set_attr_map({None: 'entry'}) |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
49 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
50 def select(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
51 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
|
52 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
|
53 % (self.item, self.selected)) |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
54 self._invalidate() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
55 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
56 def get_item(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
57 return self.item |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
58 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
59 def selectable(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
60 return True |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
61 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
62 def keypress(self, size, key): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
63 if "enter" in key: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
64 self.select() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
65 return None |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
66 return key |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
67 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
68 def render(self, size, focus=False): |
256
bcc5951edaad
Fix compatibility with urwid 1.1
Björn Ricks <bjoern.ricks@intevation.de>
parents:
242
diff
changeset
|
69 self.has_focus = focus |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
70 self.update_w() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
71 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
|
72 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
73 def update(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
74 self._w = self.get_widget() |
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 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
77 class ProjectNode(Node): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
78 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
79 MODES = [ |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
80 (0, _('Total')), |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
81 (1, _('Year')), |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
82 (2, _('Month')), |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
83 (3, _('Week')), |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
84 (4, _('Day')) |
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 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
87 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
|
88 self.indent = indent |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
89 self.mode = self.MODES[mode] |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
90 super(ProjectNode, self).__init__(proj) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
91 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
92 def get_widget(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
93 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
|
94 proj_desc = self.item.desc |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
95 if proj_desc is None: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
96 proj_desc = "" |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
97 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
98 description = urwid.Text([' ' * self.indent, |
304
c7f9997a5492
Fix codingstyle for pep8
Björn Ricks <bjoern.ricks@intevation.de>
parents:
273
diff
changeset
|
99 ('project_key', self.item.key), |
453
ceb5909b106e
Backed out changeset ab3c63877862
Bernhard Reiter <bernhard@intevation.de>
parents:
452
diff
changeset
|
100 (' '), (proj_desc)], |
304
c7f9997a5492
Fix codingstyle for pep8
Björn Ricks <bjoern.ricks@intevation.de>
parents:
273
diff
changeset
|
101 wrap="clip") |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
102 if self._get_time(): |
272
0190f1c30e3e
Align time column text in Project list to the right
Björn Ricks <bjoern.ricks@intevation.de>
parents:
256
diff
changeset
|
103 time = urwid.Text('%s (%s)' % (self.mode[1], time_str), |
304
c7f9997a5492
Fix codingstyle for pep8
Björn Ricks <bjoern.ricks@intevation.de>
parents:
273
diff
changeset
|
104 align="right") |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
105 else: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
106 time = urwid.Text('') |
273
a5c5675b6fa4
Give more "weight" to the description when displaying the project node entry
Björn Ricks <bjoern.ricks@intevation.de>
parents:
272
diff
changeset
|
107 return urwid.AttrMap(urwid.Columns([("weight", 2, description), time], |
304
c7f9997a5492
Fix codingstyle for pep8
Björn Ricks <bjoern.ricks@intevation.de>
parents:
273
diff
changeset
|
108 dividechars=1), None) |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
109 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
110 def _get_formatted_time(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
111 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
|
112 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
113 def _get_time(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
114 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
|
115 return self.item.total |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
116 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
|
117 return self.item.year() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
118 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
|
119 return self.item.month() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
120 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
|
121 return self.item.week() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
122 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
|
123 return self.item.day() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
124 return self.item.week() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
125 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
126 def switch_time_mode(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
127 tmp = self.mode[0] + 1 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
128 if tmp > 4: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
129 self.mode = self.MODES[0] |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
130 else: |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
131 self.mode = self.MODES[tmp] |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
132 self._w = self.get_widget() |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
133 |
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 class EntryNode(Node): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
136 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
137 def __init__(self, entry): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
138 super(EntryNode, self).__init__(entry) |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
139 |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
140 def get_widget(self): |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
141 logger.debug("EntryNode: update entry '%s'." % self.item.desc) |
304
c7f9997a5492
Fix codingstyle for pep8
Björn Ricks <bjoern.ricks@intevation.de>
parents:
273
diff
changeset
|
142 row = urwid.Text(' %s [%s] %s' |
c7f9997a5492
Fix codingstyle for pep8
Björn Ricks <bjoern.ricks@intevation.de>
parents:
273
diff
changeset
|
143 % (format_datetime(self.item.start), |
363
1be996254ad5
Fix: Entry.duration got renamed to Entry.get_duration
Björn Ricks <bjoern.ricks@intevation.de>
parents:
321
diff
changeset
|
144 short_time(self.item.get_duration().seconds), |
226
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
145 self.item.desc), wrap='clip') |
f8571308abef
Move ProjectNode and EntryNode to its own module
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
146 return urwid.AttrMap(row, None) |