diff cagou/core/common.py @ 179:7177fe2d9725

common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
author Goffi <goffi@goffi.org>
date Tue, 01 May 2018 20:48:48 +0200
parents 11ff8cd93659
children 284cb5c467b0
line wrap: on
line diff
--- a/cagou/core/common.py	Tue May 01 18:28:22 2018 +0200
+++ b/cagou/core/common.py	Tue May 01 20:48:48 2018 +0200
@@ -83,3 +83,19 @@
 
 class ActionSymbol(Symbol):
     pass
+
+
+class ActionIcon(BoxLayout):
+    plugin_info = properties.DictProperty()
+
+    def on_plugin_info(self, instance, plugin_info):
+        self.clear_widgets()
+        try:
+            symbol = plugin_info['icon_symbol']
+        except KeyError:
+            icon_src = plugin_info['icon_medium']
+            icon_wid = Image(source=icon_src, allow_stretch=True)
+            self.add_widget(icon_wid)
+        else:
+            icon_wid = ActionSymbol(symbol=symbol)
+            self.add_widget(icon_wid)