ChrisAn's Blog Please read my disclaimer.

simplegeek

a.k.a. Chris Anderson

Python binding

In a comment Rick says "Hey, you do realize that Python has excellent list/tuple/dictionary objects, right? You shouldn't need to make a special ICustomTypeDescriptor to do what you're doing."

I had to enable GetHashCode and SyncRoot on list to get rid of the call to ToObjectArray(). Once i did that, I could then directly bind to python lists... wahoo!

Next, Touples are already exposed as IEnumerables, so they work naturally as a list... but you can't bind to the members. Without changes to the binding infrastructure I think a list is the best we can get.

Finally, I just added ICD to Dict, which enables binding directly to the named items in a dictionary. This is actually pretty nice, and something we should consider adding to data binding directly. It's very slick to be able to bind using keys to the items in a dictionary...

_list.ItemsSource = [
  {'name':'string', 'value':'cool value'},
  {'name':'button', 'value':Button(Content='cooler value')},
  {'name':'textbox', 'value':TextBox(Text='whatever')},
  {'name':'colors', 'value':ListBox(
     ItemsSource=[color for color in dir(Colors)],
     Height=75,
     Width=150)},
]

Notice that i'm also able to bind to list comprehensions and everything! :)

In another comment Drew asks "Do you know if they support IExpando yet? Support would be pretty easy to add I assume and would have some benefits as I discuss here"

It doesn't appear that IronPython supports IExpando. I don't use unmanaged scripting engines really, so I'm not going to try and add it. Binding into Avalon is my focus right now.

And finally Christian says "Off topic: How do you measure the builds? I see on the AvPad screenshot that this is build "0001". Is this really build 1 of this version? Do you always increment when you rebuild in VS?"

I manually increment the build version when I publish a new release. I've been working on 1.2.0.0001 for a while now. I woulnd't mind using auto-increment, i've just been too lazy to do it.

05/12/2005 6:16 AM | #WinFX #Software

Content © 2003 Chris Anderson | Subscribe to my RSS feed.

Powered by BlogX