[IronPython] Overloading OnPaint etc.

Jim Hugunin jimhug at exchange.microsoft.com
Tue Apr 26 22:37:46 CEST 2005

This is broken.  Unfortunately, you should assume that in IronPython 0.7.3 you can't override any methods from a CLS super type so that it will be seen from the CLS side.

FYI - It is possible in IronPython 0.7.3 to override a very small set of methods from a CLS super type in such a way that other CLS languages will see and be affected by those overrides.  Looking over the code, the set of methods that work for this are exactly those needed to run the parrotbench benchmark - no more and no less.

Now that you've reminded us of this issue, fixing the bug is high on our priority list and I'd expect this to be fixed in the next 1-2 weeks for 0.7.4.  The basic design is in place to make this work for int.__cmp__ and a few other key methods so the work is just to extend that design to cover the general case.

Thanks - Jim

From: users-ironpython.com-bounces at lists.ironpython.com [mailto:users-ironpython.com-bounces at lists.ironpython.com] On Behalf Of Kirk Olynyk
Sent: Monday, April 25, 2005 11:54 AM
To: users-ironpython.com at lists.ironpython.com
Subject: [IronPython] Overloading OnPaint etc.

Under C#, you can overload OnPaint on a class derived from Form and then it will automatically be called upon the paint event. I find that under IronPython that I am forced to explicitly add the OnPaint method to the paint message handler list. Is this by design?
import sys
from System import *
from System.Windows.Forms import *
from System.Drawing import *
class HelloWorld(Form):
    def __init__ (self):
        print "HelloWorld.__init__"
        self.Text = "Hello World"
        self.BackColor = Color.White
        self.Paint += HelloWorld.OnPaint        # not necessary in Csharp
    def OnPaint (self, pea):
        print "HelloWorld.OnPaint"
        grfx = pea.Graphics
        grfx.DrawString("Hell, Windows Forms!", self.Font, Brushes.Black, 0, 0)

More information about the Ironpython-users mailing list