Hi Karnagious,
Thanks for your answer, it was very enlightening. In fact my question was a little more complex (not much) but your answer has been very helpful.
The idea based on your ball's example was a window cascade call (default object c -> calls a -> a calls b:
Code:
class ball(object):
def __init__(self):
self.kick = "a"
class a(object):
def __init__(self, var):
self.var = var
self.b = b(self.var)
class b(object):
def __init__(self,var):
self.var = var
class c(object):
def __init__(self,var):
self.var = var
self.a = a(self.var)
the_ball = ball()
the_c = c(the_ball)
print(the_c.var.kick)
print(the_c.a.var.kick)
print(the_c.a.b.var.kick)
the_c.var.kick = "b"
print(the_c.var.kick)
print(the_c.a.var.kick)
print(the_c.a.b.var.kick)
the_c.a.var.kick = "c"
print(the_c.var.kick)
print(the_c.a.var.kick)
print(the_c.a.b.var.kick)
the_c.a.b.var.kick = "d"
print(the_c.var.kick)
print(the_c.a.var.kick)
print(the_c.a.b.var.kick)
Taking this as a base I modify my addon.
In the default.py of the addon I create the global object (ball)
Code:
SessionDataGlobal = CSession()
I create the first Window and add the param SESSION with the global object
Code:
import resources.lib.Screen1 as Screen
ui = Screen.Screen1 ('Screen1 .xml', AddonPath, 'default', SESSION=SessionDataGlobal)
ui.doModal()
del ui
in the first window I receive the param:
Code:
class Screen1 (xbmcgui.WindowXML):
def __init__(self, *args, **kwargs):
xbmcgui.WindowXML.__init__(self, *args, **kwargs)
self.SessionDataG = kwargs["SESSION"]
I do the same when I call the second screen from the first screen:
Code:
import resources.lib.Screen2 as Screen
ui = Screen.Screen2 ('Screen2.xml', addon.get_path(), 'default', SESSION=self.SessionDataG)
ui.doModal()
del ui
The difference is that the object is local (self.SessionDataG). And finally in the Screen2 I recover the object like Screen1.
I can modify the object at any level because it's passed by reference so when a Screen2 is closed the modified data passes to Screen 1 and so on.
So the option 2 is OK too.
Thanks for your help