Paul McNett wrote:
Alex Tweedly wrote:
I ran into a problem with things not happening in the order I expected.
In the __init__ method I create a variable (self.done) and then try
to use it in afterInit - but it fails with
AttributeError: DemoForm object has no attribute 'done'
Any clues for me ?
Try not to use __init__ at all. Instead, use beforeInit and afterInit.
Basically, your problem is that it is the superclass's __init__() that
calls afterInit(), so if your __init__ code calls self.super(),
self.afterInit() will be called before returning back to your code.
Thanks - that works nicely.
If you are going to multiple-inherit (and I'd question why you want to
do that), you really should use new-style classes:
class BaseForm(object)
I initially tried it with DemoForm being based on BaseForm, which was in
turn based on dabo.ui.dForm (that's what I really wanted),
import dabo
dabo.ui.loadUI("wx")
class BaseForm(dabo.ui.dForm):
def __init__(self):
self.done = True
class DemoForm(BaseForm):
def afterInit(self):
print self.done
def main():
app = dabo.dApp()
app.MainFormClass = DemoForm
app.start()
if __name__ == '__main__':
main()
but when you do that, with __init__, it all goes sadly wrong (I don't,
to be honest, understand why - but using this form with beforeInit in
place of __init__ works perfectly).
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.8.2/356 - Release Date: 05/06/2006
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users