I'm having a problem getting the OnLoad event called from an IronPython script that uses WinForms, I've reduced the problem to the smallest possible reproduction case:
from clr import AddReference, accepts, returns, Self
AddReference("System.Windows.Forms")
AddReference("System.Drawing")
import System
from System.Windows.Forms import *
from System.ComponentModel import *
from System.Drawing import *
class DCCForms: # namespace
class Form1(System.Windows.Forms.Form):
def __init__(self):
self.InitializeComponent()
@returns(None)
def InitializeComponent(self):
self.Name = 'Form1'
self.Text = 'DCC'
self.Load += self._Form1_Load
self.ResumeLayout(False)
self.PerformLayout()
@accepts(Self(), System.Object, System.EventArgs)
@returns(None)
def _Form1_Load(self, sender, e):
pass
class WindowsApplication10: # namespace
@staticmethod
def RealEntryPoint():
Application.EnableVisualStyles()
Application.Run(DCCForms.Form1())
WindowsApplication10.RealEntryPoint();
When run, I get the error 'TypeError: Object is not callable.' for the line self.Load += self._Form1_Load. I've also gotten the same error when trying to set a textboxchanged, however adding an OnClick handler to a button works. The code written above was modified from an IronPython 1.1.2 script generated from the IronPython studio sample from the Visual Studio 2008 SDK. However, I'm running it on Iron Python 2.6.1 from inside a PyDev instance.
If I remove the Load statement, the form is generated and responds to OnClick events if specified.