Hello Michael and everyone,

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.
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to