tags:

views:

25

answers:

1

Hello,

I am working through IronPython in Action.

The following code fails at the line that reads label=Label()
The error returned is NameError: name 'Label' is not defined

This is exactly as in the book. And I don't know why it can't resolve the Label class...especially since it resolves the Form class with no problems. Any ideas?

Seth

import clr
clr.AddReference('System.Windows.Forms')


from System.Windows.Forms import Application,Form
form=Form()
form.Text='Hello World'
label=Label()
label.Text='Wassup'
form.Controls.Add(label)

Application.Run(form)
+3  A: 

Change:

from System.Windows.Forms import Application,Form

To:

from System.Windows.Forms import Application,Form,Label

Right now, the runtime doesn't know that "Label" is System.Windows.Forms.Label

Reed Copsey
Of course! Thanks.Seth
Seth Spearman