[IronPython] can't override LayoutEngine property

Jonathan Amsterdam jba at ELLINGTON.com
Thu Apr 26 21:22:46 CEST 2007

Thanks for your prompt reply.  Unfortunately, your suggestion doesn't
work either (it gives the same result when invoked from C#).  Moreover,
the first way (name = property(...)) worked fine when I just built my
own C# class with its own virtual property.

Date: Thu, 26 Apr 2007 11:04:08 -0700
From: Dino Viehland <dinov at exchange.microsoft.com>
Subject: Re: [IronPython] can't override LayoutEngine property
To: Discussion of IronPython <users at lists.ironpython.com>
<7AD436E4270DD54A94238001769C22278F5F482E0B at DF-GRTDANE-MSG.exchange.corp
Content-Type: text/plain; charset="us-ascii"

I believe currently you need to do:

                def get_MyLayoutEngine(self): return mle

to get the get_ method to override this.  A couple of people have ran
into this and we don't seem to have a bug on it so I've opened bug #9902
to make this more intuitive.

From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Jonathan
Sent: Thursday, April 26, 2007 8:23 AM
To: users at lists.ironpython.com
Subject: [IronPython] can't override LayoutEngine property

I'm trying to overrride the LayoutEngine property of Control so I can
implement my own layout engine. I find that this doesn't work in IP.
Accessing the LayoutEngine property in IP works fine, but it doesn't
work from C#.

//////////////////// C# code:

   public class MyCSharpClass
        public static LayoutEngine getLayoutEngine(Panel p)
            return p.LayoutEngine;

//////////////////// Python code:

class MyLayoutEngine(LayoutEngine):
    def Layout(self, parent, eventArgs):

mle = MyLayoutEngine()

class MyPanel(Panel):
    LayoutEngine = property(lambda self: mle)

p = MyPanel()
print "from Python:", p.LayoutEngine
print "from C#:", MyCSharpClass.getLayoutEngine(p)

//////////////////// output:
from Python: <MyLayoutEngine object at 0x000000000000002B>
from C#: System.Windows.Forms.Layout.DefaultLayout

Email transmissions can not be guaranteed to be secure or error-free, as information 
could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain 
viruses.  The sender therefore does not accept liability for any errors or omissions in 
the contents of this message which arise as a result of email transmission.  In addition,
the information contained in this email message is intended only for use of the 
individual or entity named above.  If the reader of this message is not the intended
recipient, or the employee or agent responsible to deliver it to the intended recipient,
you are hereby notified that any dissemination, distribution, or copying of this communication,
disclosure of the parties to it, or any action taken or omitted to be taken in reliance on it,
is strictly prohibited, and may be unlawful.  If you are not the intended recipient please
delete this email message. 

More information about the Ironpython-users mailing list