Mercurial > libervia-desktop-kivy
comparison src/cagou/core/widgets_handler.py @ 34:02acbb297a61
handler, widget: deleteWidget is now properly called when a QuickWidget is deleted
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 22 Aug 2016 20:58:12 +0200 |
parents | ba14b596b90e |
children | 9f45098289cc |
comparison
equal
deleted
inserted
replaced
33:c21d1be2e54c | 34:02acbb297a61 |
---|---|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 | 20 |
21 from sat.core import log as logging | 21 from sat.core import log as logging |
22 log = logging.getLogger(__name__) | 22 log = logging.getLogger(__name__) |
23 from sat_frontends.quick_frontend import quick_widgets | |
23 from kivy.uix.boxlayout import BoxLayout | 24 from kivy.uix.boxlayout import BoxLayout |
24 from kivy.uix.button import Button | 25 from kivy.uix.button import Button |
25 from kivy import properties | 26 from kivy import properties |
26 from cagou import G | 27 from cagou import G |
27 | 28 |
86 return G.host.default_wid['factory'](G.host.default_wid, None, None) | 87 return G.host.default_wid['factory'](G.host.default_wid, None, None) |
87 | 88 |
88 def removeWidget(self, vertical): | 89 def removeWidget(self, vertical): |
89 if vertical and self.vert_wid is not None: | 90 if vertical and self.vert_wid is not None: |
90 self.remove_widget(self.vert_wid) | 91 self.remove_widget(self.vert_wid) |
92 self.vert_wid.onDelete() | |
91 self.vert_wid = None | 93 self.vert_wid = None |
92 elif self.hor_wid is not None: | 94 elif self.hor_wid is not None: |
93 self.blh.remove_widget(self.hor_wid) | 95 self.blh.remove_widget(self.hor_wid) |
96 self.hor_wid.onDelete() | |
94 self.hor_wid = None | 97 self.hor_wid = None |
95 | 98 |
96 def setWidgetSize(self, vertical, size): | 99 def setWidgetSize(self, vertical, size): |
97 if vertical: | 100 if vertical: |
98 if self.vert_wid is None: | 101 if self.vert_wid is None: |
102 else: | 105 else: |
103 if self.hor_wid is None: | 106 if self.hor_wid is None: |
104 self.hor_wid = WidgetsHandler(self.default_widget, size_hint=(None, 1)) | 107 self.hor_wid = WidgetsHandler(self.default_widget, size_hint=(None, 1)) |
105 self.blh.add_widget(self.hor_wid, len(self.blh.children)) | 108 self.blh.add_widget(self.hor_wid, len(self.blh.children)) |
106 self.hor_wid.width=size | 109 self.hor_wid.width=size |
110 | |
111 def onDelete(self): | |
112 # when this handler is deleted, we need to delete the holded CagouWidget | |
113 cagou_widget = self.children[0].children[0].children[0] | |
114 if isinstance(cagou_widget, quick_widgets.QuickWidget): | |
115 G.host.widgets.deleteWidget(cagou_widget) |