[IronPython] Overloading OnPaint etc.

Kirk Olynyk kirko at microsoft.com
Mon Apr 25 20:53:48 CEST 2005


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

sys.LoadAssemblyByName("System")

sys.LoadAssemblyByName("System.Drawing")

sys.LoadAssemblyByName("System.Windows.Forms")

 

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)

 

Application.Run(HelloWorld())

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20050425/1a371edb/attachment.html>


More information about the Ironpython-users mailing list