Hello NG,
this may seem a stupid (or even impossible) question, but my knowlegde
of Python is quite limited. I have basically a simple graphical user
interface that contains a Panel, another panel (child of the main panel) and
a custom widget (child of the main panel). Basically is something like (only
some small code, is in wxPython but the question is more Python-related):
class MainClass(wx.Pa nel):
def __init__(self, *args, **kwds):
wx.Panel.__init __(self, *args, **kwds)
self.childpanel = wx.Panel(self, -1)
self.customwidg et = Custom(self, -1)
layoutsizer = wx.BoxSizer(wx. VERTICAL)
layoutsizer.Add (self.childpane l, 1)
layoutsizer.Add (self.customwid get)
layoutsizer.Lay out()
The class "Custom" has a lot of methods (functions), but the user won't call
directly this class, he/she will call the MainClass class to construct the
GUI app. However, all the methods that the user can call refer to the
"Custom" class, not the MainClass class. That is, the methods that the user
call should propagate to the "Custom" class. However, I know I can do:
# Inside MainClass
def SomeMethod(self , param):
self.customwidg et.SomeMethod(p aram)
But the "Custom" class has *a lot* of methods, so I will end up in rewriting
all the "SomeMethod s" in the MainClass just to pass the parameters/settings
to self.customwidg et. Moreover, I know I can do (in the __init__ method of
MainClass):
def __init__(self, *args, **kwds):
wx.Panel.__init __(self, *args, **kwds)
Custom.__init__ (self, parent, -1)
In order to make MainClass knowing about the Custom methods. But the I will
not be able (I suppose) to add self.customwidg et to a layoutsizer. How can I
write:
layoutsizer = wx.BoxSizer(wx. VERTICAL)
layoutsizer.Add (self.childpane l, 1)
layoutsizer.Add (self) # <=== That's impossible
layoutsizer.Lay out()
?
So (and I am very sorry for the long and maybe complex to understand post,
english is not my mother tongue and I am still trying to figure out how to
solve this problem), how can I let MainClass knowing about the Custom
methods without rewriting all the Custom functions inside MainClass and then
pass the parameters to Custom? Is there a way to "propagate" the methods to
the child class (Custom)?
Thanks for every suggestion, and sorry for the long post.
Andrea.
--
"Imaginatio n Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77