[pygtk] sharing data between windows

René 'Necoro' Neumann lists at necoro.eu
Tue Sep 15 06:32:57 WST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Doug Brewer schrieb:
> The only way I could figure this out was to pass the main window object
> itself to the preferences class, so that the pref class could set properties
> (or access methods) to transfer the data.
> 
> (in preferences class):
> 
> def set_parent(self, object)
>     self.parent = object
> 
> def close_window(self)
>     self.parent.data = self.data
> 
> It works, but I'm wondering if I'm missing something really obvious that
> would make this simpler.
> 
> Doug

I'm currently passing callback functions to the the second window, which
get called when needed (to preserve the illusion of correct
OO-encapsulation) -- but this is also nasty, as I have to change the
__init__ method whenever I need an additional callback.

So ... also waiting for better ideas ;)

- - René

P.S: Just thought about it - but could the usage of signals
("data-changed") in the second window, which the first one connects too,
be a possibility? ... (hmm - well - then we need to connect each time,
the second window is created, which is also ugly)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkquxJkACgkQ4UOg/zhYFuCNTwCfYm9ojp9ozw+BoCDCZgL1tDU5
e6kAnRyWxgMicXv+ldttDBFJL4aHEVdb
=RD0H
-----END PGP SIGNATURE-----


More information about the pygtk mailing list