diff cagou/core/cagou_widget.py @ 164:60b2b2bad747

core (widget selector): adjusted selector size to content, and added some spacing
author Goffi <goffi@goffi.org>
date Sat, 28 Apr 2018 12:31:48 +0200
parents 976f22cb3ecc
children 7177fe2d9725
line wrap: on
line diff
--- a/cagou/core/cagou_widget.py	Sat Apr 28 11:06:48 2018 +0200
+++ b/cagou/core/cagou_widget.py	Sat Apr 28 12:31:48 2018 +0200
@@ -29,6 +29,7 @@
 
 
 class HeaderWidgetChoice(ButtonBehavior, BoxLayout):
+
     def __init__(self, cagou_widget, plugin_info):
         self.plugin_info = plugin_info
         super(HeaderWidgetChoice, self).__init__()
@@ -47,6 +48,14 @@
             choice = HeaderWidgetChoice(cagou_widget, plugin_info)
             self.add_widget(choice)
 
+    def add_widget(self, *args):
+        widget = args[0]
+        widget.bind(minimum_width=self.set_width)
+        return super(HeaderWidgetSelector, self).add_widget(*args)
+
+    def set_width(self, choice, minimum_width):
+        self.width = max([c.minimum_width for c in self.container.children])
+
 
 class CagouWidget(BoxLayout):
     header_input = properties.ObjectProperty(None)