Chapter 3. .NET objects and IronPython


This chapter covers

  • Reading the MSDN documentation
  • .NET types: Classes, structures, enumerations, and collections
  • Delegates and event handlers in IronPython
  • Subclassing .NET classes

.NET is a large platform and has a great deal to offer programmers. The framework is extremely broad; the classes it provides cover almost every aspect of programming that you can imagine. The IronPython .NET integration makes it easy to use these classes directly from IronPython code; you’ll rarely do type conversion between Python types and .NET ones. Not only are the .NET objects straightforward to use and configure from within IronPython, but they’re also integrated into the Python infrastructure so that you can use Python idioms to work with them.

To understand how to use the .NET types available in the framework, you’ll need to be able to read the .NET documentation. In this chapter, you’ll create some basic applications using Windows Forms and translate the Microsoft documentation into IronPython along the way. Windows Forms is a mature library for building user interfaces for desktop applications. We could have picked almost any of the different libraries provided by .NET, but Windows Forms is a great library to work with, and it also makes for some very visual examples!

3.1. Introducing .NET

3.2. Structures, enumerations, and collections: .NET types

3.3. Handling events

3.4. Subclassing .NET types

3.5. Summary