Mercurial > libervia-desktop-kivy
comparison src/cagou/core/cagou_widget.py @ 25:d09bd16dbbe2
code (cagou widget), selector: icons handling + use of new muchoslava icon set
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 10 Aug 2016 01:24:37 +0200 |
parents | 29b507826eed |
children | 8b5827c43155 |
comparison
equal
deleted
inserted
replaced
24:bc15b55a4114 | 25:d09bd16dbbe2 |
---|---|
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 | 20 |
21 from sat.core import log as logging | 21 from sat.core import log as logging |
22 log = logging.getLogger(__name__) | 22 log = logging.getLogger(__name__) |
23 from kivy.uix.button import Button | 23 from kivy.uix.image import Image |
24 from kivy.uix.behaviors import ButtonBehavior | |
24 from kivy.uix.boxlayout import BoxLayout | 25 from kivy.uix.boxlayout import BoxLayout |
25 from kivy.uix.dropdown import DropDown | 26 from kivy.uix.dropdown import DropDown |
26 from kivy import properties | 27 from kivy import properties |
27 from cagou import G | 28 from cagou import G |
28 | 29 |
29 | 30 |
30 class HeaderWidgetButton(Button): | 31 class HeaderWidgetChoice(ButtonBehavior, BoxLayout): |
32 def __init__(self, cagou_widget, plugin_info): | |
33 self.plugin_info = plugin_info | |
34 super(HeaderWidgetChoice, self).__init__() | |
35 self.bind(on_release=lambda btn, plugin_info=plugin_info: cagou_widget.switchWidget(plugin_info)) | |
36 | |
37 | |
38 | |
39 class HeaderWidgetCurrent(ButtonBehavior, Image): | |
31 pass | 40 pass |
32 | 41 |
33 | 42 |
34 class HeaderWidgetSelector(DropDown): | 43 class HeaderWidgetSelector(DropDown): |
35 | 44 |
36 def __init__(self, cagou_widget): | 45 def __init__(self, cagou_widget): |
37 super(HeaderWidgetSelector, self).__init__() | 46 super(HeaderWidgetSelector, self).__init__() |
38 for plugin_info in G.host.getPluggedWidgets(except_cls=cagou_widget.__class__): | 47 for plugin_info in G.host.getPluggedWidgets(except_cls=cagou_widget.__class__): |
39 btn = HeaderWidgetButton(text=plugin_info["name"]) | 48 choice = HeaderWidgetChoice(cagou_widget, plugin_info) |
40 btn.bind(on_release=lambda btn, plugin_info=plugin_info: cagou_widget.switchWidget(plugin_info)) | 49 self.add_widget(choice) |
41 self.add_widget(btn) | |
42 | 50 |
43 | 51 |
44 class CagouWidget(BoxLayout): | 52 class CagouWidget(BoxLayout): |
45 header_input = properties.ObjectProperty(None) | 53 header_input = properties.ObjectProperty(None) |
46 | 54 |
47 def __init__(self): | 55 def __init__(self): |
56 for p in G.host.getPluggedWidgets(): | |
57 if p['main'] == self.__class__: | |
58 self.plugin_info = p | |
59 break | |
48 BoxLayout.__init__(self, orientation="vertical") | 60 BoxLayout.__init__(self, orientation="vertical") |
49 self.selector = HeaderWidgetSelector(self) | 61 self.selector = HeaderWidgetSelector(self) |
50 | 62 |
51 def switchWidget(self, plugin_info): | 63 def switchWidget(self, plugin_info): |
52 self.selector.dismiss() | 64 self.selector.dismiss() |