comparison src/cagou.py @ 11:49d30fc15884

core: added switchWidget method, to change a CagouWidget for an other one
author Goffi <goffi@goffi.org>
date Fri, 08 Jul 2016 20:17:52 +0200
parents 7b0a53d2afd3
children 30f6586f904b
comparison
equal deleted inserted replaced
10:8b2836b5b6c7 11:49d30fc15884
33 from kivy.app import App 33 from kivy.app import App
34 import xmlui 34 import xmlui
35 from profile_manager import ProfileManager 35 from profile_manager import ProfileManager
36 from contact_list import ContactList 36 from contact_list import ContactList
37 from kivy.uix.boxlayout import BoxLayout 37 from kivy.uix.boxlayout import BoxLayout
38 from cagou_widget import CagouWidget
38 import os.path 39 import os.path
39 40
40 41
41 class CagouRootWidget(BoxLayout): 42 class CagouRootWidget(BoxLayout):
42 43
76 self.app.root.change_widgets([contact_list]) 77 self.app.root.change_widgets([contact_list])
77 78
78 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): 79 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE):
79 log.info(u"Profile presence status set to {show}/{status}".format(show=show, status=status)) 80 log.info(u"Profile presence status set to {show}/{status}".format(show=show, status=status))
80 81
82 def switchWidget(self, old, new):
83 """Replace old widget by new one
84
85 old(CagouWidget): CagouWidget instance or a child
86 new(CagouWidget): new widget instance
87 """
88 for w in old.walk_reverse():
89 if isinstance(w, CagouWidget):
90 parent = w.parent
91 idx = parent.children.index(w)
92 parent.remove_widget(w)
93 parent.add_widget(new, index=idx)
94 break
95
81 96
82 if __name__ == '__main__': 97 if __name__ == '__main__':
83 Cagou().run() 98 Cagou().run()