[IronPython] overriding methods defined in C# classes
Simon Dahlbacka
simon.dahlbacka at gmail.com
Fri Jul 9 18:56:27 CEST 2010
Shouldn't your c# methods be protected virtual to be overridable?
On Jul 9, 2010 7:41 PM, "Marcin Krol" <mrkafk at gmail.com> wrote:
Hello Michael and everyone,
(sigh, I sent reply recently while I meant to start a new thread, this is
it)
Michael Foord wrote:
> I recommend using the Visual Studio C# designer and then subclass the
classes it generates from IronPython.
I set out to do just that and stumbled upon a problem:
I generated Windows form in C#, compiled into assembly (ip_cl1), copied to
python project folder:
clr.AddReference('ip_cl1')
..
from ip_cl1 import Form1
class Form1Inh(Form1):
def __init__(self):
Form1.__init__(self)
def comboBox1_SelectedIndexChanged(self, sender, event):
self.BackColor = Color.Azure
This doesn't work, i.e. method comboBox1_SelectedIndexChanged doesn't get
called. I have to expicitly add EventHandler in Python:
class Form1Inh(Form1):
def __init__(self):
Form1.__init__(self)
self.box1.SelectedIndexChanged +=
EventHandler(self.comboBox1_SelectedIndexChanged);
def comboBox1_SelectedIndexChanged(self, sender, event):
self.BackColor = Color.Azure
Is there some way of simply overriding methods in Python so that they do get
called by form events?
In Form1.cs I have:
namespace ip_cl1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected void box1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void comboBox1_SelectedIndexChanged(object sender,
EventArgs e)
{
}
}
}
--
Regards,
mk
--
Premature optimization is the root of all fun.
--
Regards,
mk
--
Premature optimization is the root of all fun.
_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100709/453971ae/attachment.html>
More information about the Ironpython-users
mailing list