# HG changeset patch # User Goffi # Date 1468001872 -7200 # Node ID 49d30fc158843da5325349f5ba09caff83208cc9 # Parent 8b2836b5b6c761f0969b4ab0b261e44f04c0f5ce core: added switchWidget method, to change a CagouWidget for an other one diff -r 8b2836b5b6c7 -r 49d30fc15884 src/cagou.py --- a/src/cagou.py Fri Jul 08 20:17:09 2016 +0200 +++ b/src/cagou.py Fri Jul 08 20:17:52 2016 +0200 @@ -35,6 +35,7 @@ from profile_manager import ProfileManager from contact_list import ContactList from kivy.uix.boxlayout import BoxLayout +from cagou_widget import CagouWidget import os.path @@ -78,6 +79,20 @@ def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): log.info(u"Profile presence status set to {show}/{status}".format(show=show, status=status)) + def switchWidget(self, old, new): + """Replace old widget by new one + + old(CagouWidget): CagouWidget instance or a child + new(CagouWidget): new widget instance + """ + for w in old.walk_reverse(): + if isinstance(w, CagouWidget): + parent = w.parent + idx = parent.children.index(w) + parent.remove_widget(w) + parent.add_widget(new, index=idx) + break + if __name__ == '__main__': Cagou().run()