comparison src/cagou/core/cagou_main.py @ 49:fd9cbf6ae663

core: postInit() is now called, allowing automatic profile connection
author Goffi <goffi@goffi.org>
date Sat, 10 Sep 2016 16:01:33 +0200
parents 028a98983e46
children 3f8599d9a766
comparison
equal deleted inserted replaced
48:028a98983e46 49:fd9cbf6ae663
181 181
182 class CagouApp(App): 182 class CagouApp(App):
183 """Kivy App for Cagou""" 183 """Kivy App for Cagou"""
184 184
185 def build(self): 185 def build(self):
186 return CagouRootWidget(ProfileManager()) 186 self._profile_manager = ProfileManager()
187 return CagouRootWidget(self._profile_manager)
187 188
188 def expand(self, path, *args, **kwargs): 189 def expand(self, path, *args, **kwargs):
189 """expand path and replace known values 190 """expand path and replace known values
190 191
191 useful in kv. Values which can be used: 192 useful in kv. Values which can be used:
216 for w_list in self._visible_widgets.itervalues(): 217 for w_list in self._visible_widgets.itervalues():
217 for w in w_list: 218 for w in w_list:
218 yield w 219 yield w
219 220
220 def run(self): 221 def run(self):
222 Clock.schedule_once(self.postInit)
221 self.app.run() 223 self.app.run()
224
225 def postInit(self, dummy):
226 profile_manager = self.app._profile_manager
227 del self.app._profile_manager
228 super(Cagou, self).postInit(profile_manager)
222 229
223 def _defaultFactory(self, plugin_info, target, profiles): 230 def _defaultFactory(self, plugin_info, target, profiles):
224 """factory used to create widget instance when PLUGIN_INFO["factory"] is not set""" 231 """factory used to create widget instance when PLUGIN_INFO["factory"] is not set"""
225 main_cls = plugin_info['main'] 232 main_cls = plugin_info['main']
226 return self.widgets.getOrCreateWidget(main_cls, target, on_new_widget=None, profiles=iter(self.profiles)) 233 return self.widgets.getOrCreateWidget(main_cls, target, on_new_widget=None, profiles=iter(self.profiles))