On Apr 2, 2007, at 10:27 AM, Larry Bradley wrote:
> membertableBizobj = MembertableBizobj(self.Connection)
>
> just set a LOCAL variable membertableBizobj, not a property of the
> form whereas
>
> self.membertableBizobj = MembertableBizobj(self.Connection)
>
> sets a form property which I can use later.
Let me clear up some terminology differences between VFP and Python.
In VFP, objects have properties and methods. In Python, objects have
attributes and method. 'Property' is a special construct; about the
closest thing in VFP is a VFP prop with access and assign methods.
VFP requires that all properties and methods be declared in the class
definition, or explicitly added with ADDPROPERTY(). Python is more
dynamic; you can simply say 'myInstance.foo = 3", and that object
instance has a new attribute named 'foo'.
In Dabo we've adopted a convention of having all attributes and
methods begin with a lower-case letter, and all properties beginning
with upper case.
> I was "assuming" that the addBizobj() method would assign a form
> property
> as it does in VFP.
'addObject()', which adds a child control to a container, does
indeed create a container-level attribute (well, it fakes it pretty
well). But you have to be careful: the 'Name' of an object is not
related to a local variable or anything else you assign it to.
Example (assuming form-level code):
# This creates a textbox as a child of the form
foo = self.addObject(dabo.ui.dTextBox)
# Since we didn't assign a name explicitly, the text box got the
# default name of 'dTextBox1' (or 2, or 3...).
... then later on in some other form method:
print self.foo.Value
# Throws an error, since there is no 'self.foo'
print self.dTextBox1.Value
# This works, since automatic references depend on the Name property.
> I presume that the code should really read:
> self.membertableBizobj = MembertableBizobj(self.Connection)
> self.addBizobj(self.membertableBizobj)
>
> (adding the self. in front of the membertable).
>
> I tried the latter method you mentioned with getBizobj and I now
> have a
> combo box.
Cool; glad you got it working.
Object referencing in Python is close enough to VFP to lull you into
making some bad assumptions in cases where they aren't the same.
That's just something that you figure out with time.
-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]