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 definedThis 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)
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
精彩评论