How to implement an override method in IronPython
- by Adal
I'm trying to implement a WPF control in IronPython and I'm having trouble implemented the override methods. The code below fails with this error: TypeError: expected int, got instancemethod.
If I rename the VisualChildrenCount method, the exception is not raised anymore, but the control doesn't work.
So how do I tell IronPython that the method is an override?
class PaintCanvas(FrameworkElement):
def __init__(self):
self.__children = VisualCollection(self)
dv = DrawingVisual()
self.__children.Add(dv)
# In C# this should be: protected override int VisualChildrenCount
def VisualChildrenCount(self):
return self.__children.Count
# In C# this should be: protected override Visual GetVisualChild(int index)
def GetVisualChild(self, index):
return self.__children[index]