Re: [IronPython] overriding methods defined in C# classes

2010-07-09 Thread Marcin Krol

Simon Dahlbacka wrote:

Shouldn't your c# methods be protected virtual to be overridable?


Yes, that was it. Thanks! I'm a total newbie in C#.


--

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


Re: [IronPython] overriding methods defined in C# classes

2010-07-09 Thread Simon Dahlbacka
Shouldn't your c# methods be protected virtual to be overridable?

On Jul 9, 2010 7:41 PM, "Marcin Krol"  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@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] overriding methods defined in C# classes

2010-07-09 Thread Marcin Krol

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