Hi Hansong, 

I noticed that you (@hhspiny) released your WPF adventures with pythonnet on github, but without a license: 

https://github.com/hhspiny/WPFPy

Can you please indicate the license?

Hi Tony,

Please let me know how this subclassing (.NET -> Python -> Python) would work?

Thanks,
Denis

On Mon, Apr 11, 2016 at 2:04 AM, Tony Roberts <tony@pyxll.com> wrote:
Hi,

yes, deriving from a python class in Python that itself is derived from a .net class doesn't work. Apologies, if I'd known that was what you were doing I could have saved you some time by telling you that earlier.

AFAIK this hasn't been created as an issue in github, so please if you could do that that would be helpful. It's probably not that hard to make work, but it's not something I've got time to look at myself right now I'm afraid. If anyone else wants to have a go and needs pointing in the right direction let me know.

Tony
On Mon, Apr 11, 2016 at 3:41 AM Hansong Huang <hhspiny@live.com> wrote:
Hello,

This is related to previous investigation of inheriting from .NET interface class to create WPF MVVM structure.  As now I believe it has nothing to do with interface class, but instead caused by inheriting from .Net class overall. 

please see the following code

import clr, System
class baseNA(System.Random):
    __namespace__ = "BaseNA"
    def __init__(self):
        super(baseNA,self).__init__()
#    @clr.clrmethod(System.String,[])
    def ToString(self):
        return "string"

class baseNB(baseNA):
    __namespace__ = "BaseNB"
    def __init__(self):
        super(baseNB,self).__init__()
bna = baseNA()
print bna.ToString()
print bna._Random__ToString()
bnb = baseNB()
print bnb.ToString()
print bnb._baseNA__ToString()
print bnb._Random__ToString()


This produces the following output
string
BaseNA.baseNA
BaseNB.baseNB
BaseNB.baseNB
BaseNB.baseNB

as you see, while baseNA -- the first level inherited class works fine. ToString() overrides System.Random.ToString()

But baseNB inherited from baseNA did not inherit ToString() method from baseNA, but rather inherited from System.Random.  

Not sure if it is a bug in python.net or was intended. 

regards,

Hansong




_________________________________________________
Python.NET mailing list - PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet

_________________________________________________
Python.NET mailing list - PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet