[EMAIL PROTECTED] wrote:
> How do we make an AfterInit method “see” a parameter? For example, we want
> to use and existing class for a lookup and we have a value that we want to
> start with, how do we pass a parameter the class without messing with the
One of the primary Dabo idioms for this is to make a property in the
class that represents the parameter, and then pass the property value to
the class's constructor when instantiating it. Example:
#-- begin test code (copy/paste to a .py file and run it)
import dabo
dabo.ui.loadUI("wx")
class MyTextBox(dabo.ui.dTextBox):
def _getMyProp(self):
return getattr(self, "_myProp", None)
def _setMyProp(self, val):
self._myProp = val
MyProp = property(_getMyProp, _setMyProp)
if __name__ == "__main__":
app = dabo.dApp()
app.setup()
tb = MyTextBox(app.MainForm, MyProp="Test value")
print tb.MyProp
app.start()
#-- end test code
Other than that, you aren't going to get afterInit() to see an argument
passed to __init__(), but you could code your class like:
class MyTextBox(zdabo.ui.dTextBox):
def __init__(self, myArg=None, *args, **kwargs):
self.super()
self.myArg = myArg
and now you can reference the myArg attribute from whereever you like.
--
pkm ~ http://paulmcnett.com
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users