comparison 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
comparison
equal deleted inserted replaced
163:ef09dce878c7 164:60b2b2bad747
27 from kivy import properties 27 from kivy import properties
28 from cagou import G 28 from cagou import G
29 29
30 30
31 class HeaderWidgetChoice(ButtonBehavior, BoxLayout): 31 class HeaderWidgetChoice(ButtonBehavior, BoxLayout):
32
32 def __init__(self, cagou_widget, plugin_info): 33 def __init__(self, cagou_widget, plugin_info):
33 self.plugin_info = plugin_info 34 self.plugin_info = plugin_info
34 super(HeaderWidgetChoice, self).__init__() 35 super(HeaderWidgetChoice, self).__init__()
35 self.bind(on_release=lambda btn: cagou_widget.switchWidget(plugin_info)) 36 self.bind(on_release=lambda btn: cagou_widget.switchWidget(plugin_info))
36 37
44 def __init__(self, cagou_widget): 45 def __init__(self, cagou_widget):
45 super(HeaderWidgetSelector, self).__init__() 46 super(HeaderWidgetSelector, self).__init__()
46 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__):
47 choice = HeaderWidgetChoice(cagou_widget, plugin_info) 48 choice = HeaderWidgetChoice(cagou_widget, plugin_info)
48 self.add_widget(choice) 49 self.add_widget(choice)
50
51 def add_widget(self, *args):
52 widget = args[0]
53 widget.bind(minimum_width=self.set_width)
54 return super(HeaderWidgetSelector, self).add_widget(*args)
55
56 def set_width(self, choice, minimum_width):
57 self.width = max([c.minimum_width for c in self.container.children])
49 58
50 59
51 class CagouWidget(BoxLayout): 60 class CagouWidget(BoxLayout):
52 header_input = properties.ObjectProperty(None) 61 header_input = properties.ObjectProperty(None)
53 header_box = properties.ObjectProperty(None) 62 header_box = properties.ObjectProperty(None)