Mercurial > libervia-desktop-kivy
diff 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 |
line wrap: on
line diff
--- a/src/cagou/core/cagou_widget.py Tue Aug 09 22:06:00 2016 +0200 +++ b/src/cagou/core/cagou_widget.py Wed Aug 10 01:24:37 2016 +0200 @@ -20,14 +20,23 @@ from sat.core import log as logging log = logging.getLogger(__name__) -from kivy.uix.button import Button +from kivy.uix.image import Image +from kivy.uix.behaviors import ButtonBehavior from kivy.uix.boxlayout import BoxLayout from kivy.uix.dropdown import DropDown from kivy import properties from cagou import G -class HeaderWidgetButton(Button): +class HeaderWidgetChoice(ButtonBehavior, BoxLayout): + def __init__(self, cagou_widget, plugin_info): + self.plugin_info = plugin_info + super(HeaderWidgetChoice, self).__init__() + self.bind(on_release=lambda btn, plugin_info=plugin_info: cagou_widget.switchWidget(plugin_info)) + + + +class HeaderWidgetCurrent(ButtonBehavior, Image): pass @@ -36,15 +45,18 @@ def __init__(self, cagou_widget): super(HeaderWidgetSelector, self).__init__() for plugin_info in G.host.getPluggedWidgets(except_cls=cagou_widget.__class__): - btn = HeaderWidgetButton(text=plugin_info["name"]) - btn.bind(on_release=lambda btn, plugin_info=plugin_info: cagou_widget.switchWidget(plugin_info)) - self.add_widget(btn) + choice = HeaderWidgetChoice(cagou_widget, plugin_info) + self.add_widget(choice) class CagouWidget(BoxLayout): header_input = properties.ObjectProperty(None) def __init__(self): + for p in G.host.getPluggedWidgets(): + if p['main'] == self.__class__: + self.plugin_info = p + break BoxLayout.__init__(self, orientation="vertical") self.selector = HeaderWidgetSelector(self)