[IronPython] keyword argument in Form or Button constructor

Brian Raynes brian_raynes at dnr.state.ak.us
Mon Nov 21 23:39:05 CET 2005


I was following along in the tutorial (I'm using Iron Python 0.9.5 and 
.NET 2.0 framework that installs from the Visual C# Express Edition).  
The tutorial section that deals with adding a button click event handler 
directs us to create the click handler like this:

def click(f, a):
    l = Label(Text = "Hello")
    l.Location = a.Location
    f.Controls.Add(l)

After registering this handler, I did not see the labels appear on the 
form.  Checking, I was able to confirm that label controls are added, 
but their Text property is an empty string.  If I change the handler 
function like this, without using a keyword argument in the Label 
constructor, it works like expected:

def click(f, a):
    l = Label()
    l.Text = "Hello"
    l.Location = a.Location
    f.Controls.Add(l)

Playing around with keyword arguments in the constructor for Form() 
yielded similar results (empty string for .Text property):

f = Form(Text="Hello")
print f.Text

Are keyword arguments in the constructor supposed to work in these 
cases?  If they do not, it would be a really nice feature.  In either 
case, the tutorial should reflect what does work, or at least what will 
work when 1.0 is released.

Brian Raynes

-- 
***********************************************************************
* Brian Raynes                                                        *
* Land Surveyor I                                                     *
* 907-269-8519 - brian_raynes at dnr.state.ak.us                         *
* Division of Mining, Land & Water                                    *
* Dept. of Natural Resources, State of Alaska                         *
***********************************************************************




More information about the Ironpython-users mailing list