Mercurial > libervia-desktop-kivy
diff src/cagou/core/widgets_handler.py @ 16:ba14b596b90e
host can now be get as a global value:
instead of always copying host from class to class, it can now be gotten from a global class with:
from cagou import G
then G.host will give host.
This will probably be used on the long term on all SàT (backend + frontends).
As host is currently needed in several places (most importantly in QuickFrontend), the argument is still present, and must be there even is unused on class inheriting from QuickSomething.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 09 Jul 2016 18:41:52 +0200 |
parents | 56838ad5c84b |
children | 02acbb297a61 |
line wrap: on
line diff
--- a/src/cagou/core/widgets_handler.py Sat Jul 09 17:24:01 2016 +0200 +++ b/src/cagou/core/widgets_handler.py Sat Jul 09 18:41:52 2016 +0200 @@ -23,6 +23,7 @@ from kivy.uix.boxlayout import BoxLayout from kivy.uix.button import Button from kivy import properties +from cagou import G NEW_WIDGET_DIST = 10 @@ -67,8 +68,7 @@ class WidgetsHandler(BoxLayout): - def __init__(self, host, wid=None, **kw): - self.host = host + def __init__(self, wid=None, **kw): if wid is None: wid=self.default_widget self.vert_wid = self.hor_wid = None @@ -83,7 +83,7 @@ @property def default_widget(self): - return self.host.default_wid['factory'](self.host, self.host.default_wid, None, None) + return G.host.default_wid['factory'](G.host.default_wid, None, None) def removeWidget(self, vertical): if vertical and self.vert_wid is not None: @@ -96,11 +96,11 @@ def setWidgetSize(self, vertical, size): if vertical: if self.vert_wid is None: - self.vert_wid = WidgetsHandler(self.host, self.default_widget, size_hint=(1, None)) + self.vert_wid = WidgetsHandler(self.default_widget, size_hint=(1, None)) self.add_widget(self.vert_wid, len(self.children)) self.vert_wid.height=size else: if self.hor_wid is None: - self.hor_wid = WidgetsHandler(self.host, self.default_widget, size_hint=(None, 1)) + self.hor_wid = WidgetsHandler(self.default_widget, size_hint=(None, 1)) self.blh.add_widget(self.hor_wid, len(self.blh.children)) self.hor_wid.width=size