|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
DataBinding and INotifyPropertyChanged in IronPythonHi all,
I was looking for WPF data binding in IronPython and I have found nice Japanese blog about it: http://palepoli.skr.jp/wp/2009/06/28/wpf-listview-databinding-for-ironpython/ It links to http://sdlsdk.codeplex.com/Thread/View.aspx?ThreadId=30322 that should have more information about how to implement INotifyPropertyChanged in IronPython which I am also interested in. Unfortunately this page is no more available. Does the guideline exist somewhere else? Thanks. PS: I know about http://lists.ironpython.com/pipermail/users-ironpython.com/2009-August/010938.html but I don't think using __setattr__ is good approach. Also implementing the PropertyChanged event is different on the blog. -- -- Lukáš _______________________________________________ Users mailing list Users@... http://lists.ironpython.com/listinfo.cgi/users-ironpython.com |
|
|
Re: DataBinding and INotifyPropertyChanged in IronPythonWhy don't you think that __setattr__ is a good approach? The alternative (as shown in the linked Japanese-language blog) is to implement setters for the properties you care about and to manually trigger the event.
2009/11/6 Lukas Cenovsky <cenovsky@...> Hi all, _______________________________________________ Users mailing list Users@... http://lists.ironpython.com/listinfo.cgi/users-ironpython.com |
|
|
Re: DataBinding and INotifyPropertyChanged in IronPython> It links to http://sdlsdk.codeplex.com/Thread/View.aspx?ThreadId=30322
> that should have more information about how to implement > INotifyPropertyChanged in IronPython which I am also interested in. > Unfortunately this page is no more available. Does the guideline exist > somewhere else? Thanks. I've re-enabled the discussions tab on that defunct project, so that link is now active again. _______________________________________________ Users mailing list Users@... http://lists.ironpython.com/listinfo.cgi/users-ironpython.com |
|
|
clr.CompileSubclassTypes restrictions on list of typesHi,
Are there any restrictions placed on the list of types that can be passed to CompileSubclassTypes? We are having issues with a clr.AddReference(DllContainingSubclasses) being very slow, so are trying to split the compiled subclasses across multiple dlls to indicate progress between the loading of these dlls. However, when trying to compile a partial list of types we get the following error: Traceback (most recent call last): File "c:\buildshare\gitrepo\precompile_subclasses.py", line 40, in c:\buildsha re\gitrepo\precompile_subclasses.py TypeError: : can only extend one CLI or builtin type, not both Microsoft.Scripti ng.Runtime.Extensible`1[[System.Double, mscorlib, Version=2.0.0.0, Culture=neutr al, PublicKeyToken=b77a5c561934e089]] (for IronPython.Runtime.Types.PythonType) and IronPython.Runtime.SetCollection (for IronPython.Runtime.Types.PythonType) Any help is much appreciated, Tom _______________________________________________ Users mailing list Users@... http://lists.ironpython.com/listinfo.cgi/users-ironpython.com |
|
|
Re: clr.CompileSubclassTypes restrictions on list of typesThe only restrictions are the normal restrictions that Python has regarding
inheritance. In this case it looks like you're hitting that you cannot inherit from more than one base type w/ a different layout. Basically it looks like you're trying to pre-compile the equivalent of: class c(float, set): pass Which isn't legal in Python so my guess is there is an issue w/ the way you split them up. > -----Original Message----- > From: users-bounces@... [mailto:users- > bounces@...] On Behalf Of Tom Wright > Sent: Tuesday, November 10, 2009 9:39 AM > To: Discussion of IronPython > Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of types > > Hi, > > Are there any restrictions placed on the list of types that can be > passed to CompileSubclassTypes? > > We are having issues with a clr.AddReference(DllContainingSubclasses) > being very slow, so are trying to split the compiled subclasses across > multiple dlls to indicate progress between the loading of these dlls. > > However, when trying to compile a partial list of types we get the > following error: > > Traceback (most recent call last): > File "c:\buildshare\gitrepo\precompile_subclasses.py", line 40, in > c:\buildsha > re\gitrepo\precompile_subclasses.py > TypeError: : can only extend one CLI or builtin type, not both > Microsoft.Scripti > ng.Runtime.Extensible`1[[System.Double, mscorlib, Version=2.0.0.0, > Culture=neutr > al, PublicKeyToken=b77a5c561934e089]] (for > IronPython.Runtime.Types.PythonType) > and IronPython.Runtime.SetCollection (for > IronPython.Runtime.Types.PythonType) > > > Any help is much appreciated, > Tom > _______________________________________________ > Users mailing list > Users@... > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com Users mailing list Users@... http://lists.ironpython.com/listinfo.cgi/users-ironpython.com |
|
|
Re: clr.CompileSubclassTypes restrictions on list of typesThanks the reply,
Could you clarify slightly what you mean by the Python's normal restrictions. I was guessing the restriction might be something like: "When compiling a list of types, if the list contains a class B which inherits from A then A must be contained in the list." The interesting thing here is that the call to CompileSubclassTypes works when we pass it one huge list of types, but not when we call if repeatedly with smaller lists. Thanks Tom Dino Viehland wrote: > The only restrictions are the normal restrictions that Python has regarding > inheritance. In this case it looks like you're hitting that you cannot > inherit from more than one base type w/ a different layout. > > Basically it looks like you're trying to pre-compile the equivalent of: > > class c(float, set): pass > > Which isn't legal in Python so my guess is there is an issue w/ the way you > split them up. > > >> -----Original Message----- >> From: users-bounces@... [mailto:users- >> bounces@...] On Behalf Of Tom Wright >> Sent: Tuesday, November 10, 2009 9:39 AM >> To: Discussion of IronPython >> Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of types >> >> Hi, >> >> Are there any restrictions placed on the list of types that can be >> passed to CompileSubclassTypes? >> >> We are having issues with a clr.AddReference(DllContainingSubclasses) >> being very slow, so are trying to split the compiled subclasses across >> multiple dlls to indicate progress between the loading of these dlls. >> >> However, when trying to compile a partial list of types we get the >> following error: >> >> Traceback (most recent call last): >> File "c:\buildshare\gitrepo\precompile_subclasses.py", line 40, in >> c:\buildsha >> re\gitrepo\precompile_subclasses.py >> TypeError: : can only extend one CLI or builtin type, not both >> Microsoft.Scripti >> ng.Runtime.Extensible`1[[System.Double, mscorlib, Version=2.0.0.0, >> Culture=neutr >> al, PublicKeyToken=b77a5c561934e089]] (for >> IronPython.Runtime.Types.PythonType) >> and IronPython.Runtime.SetCollection (for >> IronPython.Runtime.Types.PythonType) >> >> >> Any help is much appreciated, >> Tom >> _______________________________________________ >> Users mailing list >> Users@... >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > _______________________________________________ > Users mailing list > Users@... > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ Users mailing list Users@... http://lists.ironpython.com/listinfo.cgi/users-ironpython.com |
|
|
Re: clr.CompileSubclassTypes restrictions on list of typesThe restrictions are per-subclass so for example you cannot inherit
from both a list and tuple. The reason here is that list and tuple both have their own independent layout in memory and there's no relationship between them. Or in your case it's set and float. CompileSubclassTypes takes an arbitrary number of parameters and those can be either a type (which gets compiled) or they can be a tuple of types which specify the collection of base types. The latter form is generally useful for including .NET interfaces. So clr.CompileSubclassTypes("foo", (set, float)) will fail as this is specifying that you want 1 class which inherits from both set and float. But you can do clr.CompileSubclassTypes("foo", set, float) and this specifies what you want 2 types, one that inherits from set and float. Or you can do: clr.CompileSubclassTypes("foo", (set, ), (float, )) and again that'll work because it's specifying 2 different base types. > -----Original Message----- > From: users-bounces@... [mailto:users- > bounces@...] On Behalf Of Tom Wright > Sent: Tuesday, November 10, 2009 10:08 AM > To: Discussion of IronPython > Subject: Re: [IronPython] clr.CompileSubclassTypes restrictions on list of > types > > Thanks the reply, > > Could you clarify slightly what you mean by the Python's normal > restrictions. I was guessing the restriction might be something like: > > "When compiling a list of types, if the list contains a class B which > inherits from A then A must be contained in the list." > > The interesting thing here is that the call to CompileSubclassTypes > works when we pass it one huge list of types, but not when we call if > repeatedly with smaller lists. > > Thanks > Tom > > Dino Viehland wrote: > > The only restrictions are the normal restrictions that Python has regarding > > inheritance. In this case it looks like you're hitting that you cannot > > inherit from more than one base type w/ a different layout. > > > > Basically it looks like you're trying to pre-compile the equivalent of: > > > > class c(float, set): pass > > > > Which isn't legal in Python so my guess is there is an issue w/ the way you > > split them up. > > > > > >> -----Original Message----- > >> From: users-bounces@... [mailto:users- > >> bounces@...] On Behalf Of Tom Wright > >> Sent: Tuesday, November 10, 2009 9:39 AM > >> To: Discussion of IronPython > >> Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of > types > >> > >> Hi, > >> > >> Are there any restrictions placed on the list of types that can be > >> passed to CompileSubclassTypes? > >> > >> We are having issues with a clr.AddReference(DllContainingSubclasses) > >> being very slow, so are trying to split the compiled subclasses across > >> multiple dlls to indicate progress between the loading of these dlls. > >> > >> However, when trying to compile a partial list of types we get the > >> following error: > >> > >> Traceback (most recent call last): > >> File "c:\buildshare\gitrepo\precompile_subclasses.py", line 40, in > >> c:\buildsha > >> re\gitrepo\precompile_subclasses.py > >> TypeError: : can only extend one CLI or builtin type, not both > >> Microsoft.Scripti > >> ng.Runtime.Extensible`1[[System.Double, mscorlib, Version=2.0.0.0, > >> Culture=neutr > >> al, PublicKeyToken=b77a5c561934e089]] (for > >> IronPython.Runtime.Types.PythonType) > >> and IronPython.Runtime.SetCollection (for > >> IronPython.Runtime.Types.PythonType) > >> > >> > >> Any help is much appreciated, > >> Tom > >> _______________________________________________ > >> Users mailing list > >> Users@... > >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > >> > > _______________________________________________ > > Users mailing list > > Users@... > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > _______________________________________________ > Users mailing list > Users@... > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com Users mailing list Users@... http://lists.ironpython.com/listinfo.cgi/users-ironpython.com |
|
|
Re: DataBinding and INotifyPropertyChanged in IronPython
__setattr__ is not clean and easy readable piece of code. That's why I
dive into decorators and create a notify_property:
class notify_property(property):
def __init__(self, getter):
def newgetter(slf):
#return None when the property does not exist yet
try:
return getter(slf)
except AttributeError:
return None
super(notify_property, self).__init__(newgetter)
def setter(self, setter):
def newsetter(slf, newvalue):
# do not change value if the new value is the same
# trigger PropertyChanged event when value changes
oldvalue = self.fget(slf)
if oldvalue != newvalue:
setter(slf, newvalue)
slf.OnPropertyChanged(setter.__name__)
return property(
fget=self.fget,
fset=newsetter,
fdel=self.fdel,
doc=self.__doc__)
The usage is the same as for @property - see details on my blog:http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html Unfortunately, this does not work in Silverlight - probably because such properties are not CLR fields. I'd like to find a way to make it work in Silverlight too. -- -- Lukáš Curt Hagenlocher wrote:
_______________________________________________ Users mailing list Users@... http://lists.ironpython.com/listinfo.cgi/users-ironpython.com |
|
|
Re: clr.CompileSubclassTypes restrictions on list of typesThanks for the response. I've discovered the bug: I had
clr.CompileSubclassTypes(name, listOfTypes) instead of clr.CompileSubclassTypes(name, *listOfTypes) Tom Dino Viehland wrote: > The restrictions are per-subclass so for example you cannot inherit > from both a list and tuple. The reason here is that list and tuple both > have their own independent layout in memory and there's no relationship > between them. Or in your case it's set and float. > > CompileSubclassTypes takes an arbitrary number of parameters and those > can be either a type (which gets compiled) or they can be a tuple of types > which specify the collection of base types. The latter form is generally useful > for including .NET interfaces. > > So clr.CompileSubclassTypes("foo", (set, float)) will fail as this is > specifying that you want 1 class which inherits from both set and float. > > But you can do clr.CompileSubclassTypes("foo", set, float) and this specifies > what you want 2 types, one that inherits from set and float. > > Or you can do: > > clr.CompileSubclassTypes("foo", (set, ), (float, )) > > and again that'll work because it's specifying 2 different base types. > > > >> -----Original Message----- >> From: users-bounces@... [mailto:users- >> bounces@...] On Behalf Of Tom Wright >> Sent: Tuesday, November 10, 2009 10:08 AM >> To: Discussion of IronPython >> Subject: Re: [IronPython] clr.CompileSubclassTypes restrictions on list of >> types >> >> Thanks the reply, >> >> Could you clarify slightly what you mean by the Python's normal >> restrictions. I was guessing the restriction might be something like: >> >> "When compiling a list of types, if the list contains a class B which >> inherits from A then A must be contained in the list." >> >> The interesting thing here is that the call to CompileSubclassTypes >> works when we pass it one huge list of types, but not when we call if >> repeatedly with smaller lists. >> >> Thanks >> Tom >> >> Dino Viehland wrote: >> >>> The only restrictions are the normal restrictions that Python has regarding >>> inheritance. In this case it looks like you're hitting that you cannot >>> inherit from more than one base type w/ a different layout. >>> >>> Basically it looks like you're trying to pre-compile the equivalent of: >>> >>> class c(float, set): pass >>> >>> Which isn't legal in Python so my guess is there is an issue w/ the way you >>> split them up. >>> >>> >>> >>>> -----Original Message----- >>>> From: users-bounces@... [mailto:users- >>>> bounces@...] On Behalf Of Tom Wright >>>> Sent: Tuesday, November 10, 2009 9:39 AM >>>> To: Discussion of IronPython >>>> Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of >>>> >> types >> >>>> Hi, >>>> >>>> Are there any restrictions placed on the list of types that can be >>>> passed to CompileSubclassTypes? >>>> >>>> We are having issues with a clr.AddReference(DllContainingSubclasses) >>>> being very slow, so are trying to split the compiled subclasses across >>>> multiple dlls to indicate progress between the loading of these dlls. >>>> >>>> However, when trying to compile a partial list of types we get the >>>> following error: >>>> >>>> Traceback (most recent call last): >>>> File "c:\buildshare\gitrepo\precompile_subclasses.py", line 40, in >>>> c:\buildsha >>>> re\gitrepo\precompile_subclasses.py >>>> TypeError: : can only extend one CLI or builtin type, not both >>>> Microsoft.Scripti >>>> ng.Runtime.Extensible`1[[System.Double, mscorlib, Version=2.0.0.0, >>>> Culture=neutr >>>> al, PublicKeyToken=b77a5c561934e089]] (for >>>> IronPython.Runtime.Types.PythonType) >>>> and IronPython.Runtime.SetCollection (for >>>> IronPython.Runtime.Types.PythonType) >>>> >>>> >>>> Any help is much appreciated, >>>> Tom >>>> _______________________________________________ >>>> Users mailing list >>>> Users@... >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>>> >>> _______________________________________________ >>> Users mailing list >>> Users@... >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >> _______________________________________________ >> Users mailing list >> Users@... >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > _______________________________________________ > Users mailing list > Users@... > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ Users mailing list Users@... http://lists.ironpython.com/listinfo.cgi/users-ironpython.com |
| Free embeddable forum powered by Nabble | Forum Help |