[IronPython] overriding methods from C# classes

Marcin Krol mrkafk at gmail.com
Fri Jul 9 19:43:42 CEST 2010


Dino Viehland wrote:
>> Is there some way of simply overriding methods in Python so that they do
>> get called by form events?
> 
> In both of these cases there are no methods to be overridden.  You're just 
> defining methods which you want to use for the event handlers.  You need
> to connect those methods to the event handlers somewhere.  

OK hang on a second - WHICH methods do you mean precisely - In the base 
class or the overriden class?

Bc when I changed declaration of the method to "protected virtual" in 
the Form1.cs, the inherited class calls my Ipython method all right - 
that looks like overriding to me, at least when looking at it from the 
outside and not looking "under covers" what's happening.

> Your C# code is
> working probably because the connection of the event handlers is in the 
> generated code in InitializeComponent().

It is there all right:

public void InitializeComponent()
{
..
     this.comboBox1.SelectedIndexChanged += new 
System.EventHandler(this.comboBox1_SelectedIndexChanged);
}



> This is one of the reasons why I suggest WPF over WinForms.  In WPF you can
> declare the event handlers in the XAML and we can wire them up to you.  In
> our IronPython 2.7 source code I recently added a clr.LoadComponent method which
> does this.  

Well that certainly makes WPF worth considering. Questions:

1. when IPY 2.7 is to be released?

2. Documentation. This sort of worries me: where do I get the detailed 
info how to use this stuff? So far I have developed only in CPython/Linux...



Regards,
mk

--
Premature optimization is the root of all fun.



More information about the Ironpython-users mailing list