comparison sat_frontends/primitivus/widget.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 26edcf3a30eb
children 003b8b4b56a7
comparison
equal deleted inserted replaced
2623:49533de4540b 2624:56f94936df1e
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core import log as logging 20 from sat.core import log as logging
21
21 log = logging.getLogger(__name__) 22 log = logging.getLogger(__name__)
22 import urwid 23 import urwid
23 from urwid_satext import sat_widgets 24 from urwid_satext import sat_widgets
24 from sat_frontends.primitivus.keys import action_key_map as a_key 25 from sat_frontends.primitivus.keys import action_key_map as a_key
25 26
26 27
27 class PrimitivusWidget(urwid.WidgetWrap): 28 class PrimitivusWidget(urwid.WidgetWrap):
28 """Base widget for Primitivus""" 29 """Base widget for Primitivus"""
29 30
30 def __init__(self, w, title=''): 31 def __init__(self, w, title=""):
31 self._title = title 32 self._title = title
32 self._title_dynamic = None 33 self._title_dynamic = None
33 self._original_widget = w 34 self._original_widget = w
34 urwid.WidgetWrap.__init__(self, self._getDecoration(w)) 35 urwid.WidgetWrap.__init__(self, self._getDecoration(w))
35 36
55 title_elts = [] 56 title_elts = []
56 if self._title: 57 if self._title:
57 title_elts.append(self._title) 58 title_elts.append(self._title)
58 if self._title_dynamic: 59 if self._title_dynamic:
59 title_elts.append(self._title_dynamic) 60 title_elts.append(self._title_dynamic)
60 if len(all_profiles)>1 and profiles: 61 if len(all_profiles) > 1 and profiles:
61 title_elts.append(u'[{}]'.format(u', '.join(profiles))) 62 title_elts.append(u"[{}]".format(u", ".join(profiles)))
62 return sat_widgets.SurroundedText(u' '.join(title_elts)) 63 return sat_widgets.SurroundedText(u" ".join(title_elts))
63 64
64 @title.setter 65 @title.setter
65 def title(self, value): 66 def title(self, value):
66 self._title = value 67 self._title = value
67 if self.decorationVisible: 68 if self.decorationVisible:
81 @property 82 @property
82 def decorationVisible(self): 83 def decorationVisible(self):
83 """True if the decoration is visible""" 84 """True if the decoration is visible"""
84 return isinstance(self._w, sat_widgets.LabelLine) 85 return isinstance(self._w, sat_widgets.LabelLine)
85 86
86
87 def keypress(self, size, key): 87 def keypress(self, size, key):
88 if key == a_key['DECORATION_HIDE']: #user wants to (un)hide widget decoration 88 if key == a_key["DECORATION_HIDE"]: # user wants to (un)hide widget decoration
89 show = not self.decorationVisible 89 show = not self.decorationVisible
90 self.showDecoration(show) 90 self.showDecoration(show)
91 else: 91 else:
92 return super(PrimitivusWidget, self).keypress(size, key) 92 return super(PrimitivusWidget, self).keypress(size, key)
93 93
94 def _getDecoration(self, widget): 94 def _getDecoration(self, widget):
95 return sat_widgets.LabelLine(widget, self.title) 95 return sat_widgets.LabelLine(widget, self.title)
96 96
97 def showDecoration(self, show=True): 97 def showDecoration(self, show=True):
98 """Show/Hide the decoration around the window""" 98 """Show/Hide the decoration around the window"""
99 self._w = self._getDecoration(self._original_widget) if show else self._original_widget 99 self._w = (
100 self._getDecoration(self._original_widget) if show else self._original_widget
101 )
100 102
101 def getMenu(self): 103 def getMenu(self):
102 raise NotImplementedError 104 raise NotImplementedError