Mercurial > libervia-backend
comparison sat_frontends/primitivus/widget.py @ 4037:524856bd7b19
massive refactoring to switch from camelCase to snake_case:
historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a
pre-PEP8 code, to use the same coding style as in Twisted.
However, snake_case is more readable and it's better to follow PEP8 best practices, so it
has been decided to move on full snake_case. Because Libervia has a huge codebase, this
ended with a ugly mix of camelCase and snake_case.
To fix that, this patch does a big refactoring by renaming every function and method
(including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case.
This is a massive change, and may result in some bugs.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:54:42 +0200 |
parents | be6d91572633 |
children | 4b842c1fb686 |
comparison
equal
deleted
inserted
replaced
4036:c4464d7ae97b | 4037:524856bd7b19 |
---|---|
30 | 30 |
31 def __init__(self, w, title=""): | 31 def __init__(self, w, title=""): |
32 self._title = title | 32 self._title = title |
33 self._title_dynamic = None | 33 self._title_dynamic = None |
34 self._original_widget = w | 34 self._original_widget = w |
35 urwid.WidgetWrap.__init__(self, self._getDecoration(w)) | 35 urwid.WidgetWrap.__init__(self, self._get_decoration(w)) |
36 | 36 |
37 @property | 37 @property |
38 def title(self): | 38 def title(self): |
39 """Text shown in title bar of the widget""" | 39 """Text shown in title bar of the widget""" |
40 | 40 |
63 return sat_widgets.SurroundedText(" ".join(title_elts)) | 63 return sat_widgets.SurroundedText(" ".join(title_elts)) |
64 | 64 |
65 @title.setter | 65 @title.setter |
66 def title(self, value): | 66 def title(self, value): |
67 self._title = value | 67 self._title = value |
68 if self.decorationVisible: | 68 if self.decoration_visible: |
69 self.showDecoration() | 69 self.show_decoration() |
70 | 70 |
71 @property | 71 @property |
72 def title_dynamic(self): | 72 def title_dynamic(self): |
73 """Dynamic part of title""" | 73 """Dynamic part of title""" |
74 return self._title_dynamic | 74 return self._title_dynamic |
75 | 75 |
76 @title_dynamic.setter | 76 @title_dynamic.setter |
77 def title_dynamic(self, value): | 77 def title_dynamic(self, value): |
78 self._title_dynamic = value | 78 self._title_dynamic = value |
79 if self.decorationVisible: | 79 if self.decoration_visible: |
80 self.showDecoration() | 80 self.show_decoration() |
81 | 81 |
82 @property | 82 @property |
83 def decorationVisible(self): | 83 def decoration_visible(self): |
84 """True if the decoration is visible""" | 84 """True if the decoration is visible""" |
85 return isinstance(self._w, sat_widgets.LabelLine) | 85 return isinstance(self._w, sat_widgets.LabelLine) |
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.decoration_visible |
90 self.showDecoration(show) | 90 self.show_decoration(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 _get_decoration(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 show_decoration(self, show=True): |
98 """Show/Hide the decoration around the window""" | 98 """Show/Hide the decoration around the window""" |
99 self._w = ( | 99 self._w = ( |
100 self._getDecoration(self._original_widget) if show else self._original_widget | 100 self._get_decoration(self._original_widget) if show else self._original_widget |
101 ) | 101 ) |
102 | 102 |
103 def getMenu(self): | 103 def get_menu(self): |
104 raise NotImplementedError | 104 raise NotImplementedError |