Uwe Grauer wrote: > Paul McNett wrote: >> Uwe Grauer wrote: >>> Things like this should make it into the FAQ or a Howto. >>> >>> Something like: >>> - What is the difference between a property and a dynamic property? >> I agree. Can you take that on? >> >> Paul >> > > Yes. > > Uwe
I beg your pardon, but this wiki is a holy crap. Why does the preview look different than the original?
Before i mess up this whole thing, i stop editing it.
Here is the entry:
- <a href="#DifferencePropertyAndDynamicProperty">What is the difference between a property and a dynamic property?</a>
----
<a name="DifferencePropertyAndDynamicProperty">What is the difference between a property and a dynamic property?</a>
A plain property takes a value. checkbox.Enabled = False will disable the checkbox. A dynamic property takes a function. This function will be evaluated at the proper time by Dabo to dynamically determine the value of the property.
def dynEnabled(): import datetime return datetime.datetime.now().minute > 30
checkbox.DynamicEnabled = dynEnabled
Now, the checkbox will be enabled only in the last half of each hour.
A dynamic property can be used at different places:
1) in the constructor:
cb = dabo.ui.dCheckBox(frm, DynamicEnabled=dynEnabled)
2) in the class definition:
class MyCheckBox(dabo.ui.dCheckBox): def initProperties(self): self.DynamicEnabled = dynEnabled
3) after the instanciating:
cb = dabo.ui.dCheckBox(frm) cb.DynamicEnabled = dynEnabled
----
©2008 Uwe Grauer |