This chapter covers

Building a web-based document editor So far we've been focusing on using IronPython with Windows Forms to construct rich desktop applications, but the .NET platform also provides a high-level framework for building web applications ASP.NET. ASP.NET includes lots of goodies for web development. It provides a powerful page model where server-to-client round-tripping of data is handled automatically, removing the need for a lot of the boilerplate code in a web application. The .NET class library...

Silverlight controls

Silverlight ships with a set of standard controls based on WPF and contained in the System.Windows.Controls namespace. Figure 13.3 shows examples of the standard controls. Figure 13.3 Some of the standard Silverlight controls Figure 13.3 Some of the standard Silverlight controls As you might expect from their WPF inheritance, the Silverlight controls are attractive and easy to use. Figure 13.4 shows a TextBox with a Button and a TextBlock. Using and configuring llie controls from code is...

System administration with Python

Every computer user does some system administration, even if it's only maintaining a stable and working system. System administration encompasses everything from keeping a computer operating to maintaining large networks with many computers and servers. Although these are radically different situations, they share some needs and techniques in common. We start our look at administration with an example of simple scripting. For simple tasks, one of Python's great advantages is that it doesn't...

Dynamic attribute access

Python attribute access uses straightforward syntax, shared with other imperative languages like Java and C . Through properties, you can control what happens when individual attributes are fetched or set but, with Python, you can provide access to arbitrary attributes through the_getattr_method. 8 This page in the Python documentation lists among other things the protocol methods for rich comparison 9 See the following article on rich comparison in CPython and IronPython, which also shows a...

Remove pages OK and Cancel dialog box

When the user asks to perform an irreversible action, such as removing a tab page, it's normal to ask for confirmation of the action. You're undoubtedly familiar with the standard Windows OK Cancel dialog box, which gives the user the choice of whether to continue with the action or to abort. This is actually our old friend the system message box. In case you've forgotten, the most useful overload of Show is as follows The two strings are the text and caption body and title of the message box....

XPS documents and flow content

Ironpython Wpf

XML Paper Specification XPS is a combination of a document markup language, which is a subset of XAML, and code support for viewing and printing documents. Although you won't read this in the Microsoft documentation, many see XPS as Microsoft's answer to Adobe's Portable Document Format PDF for creating print-ready documents. Fortunately, that debate is irrelevant to us because the classes that provide XPS support are a fantastic way of incorporating documents within WPF applications. One use...

WPF in action

Wxpython Combobox Grid

Although WPF doesn't have as many controls as Windows Forms, it includes standard controls such as check boxes, drop-down lists, and radio buttons. It also includes a range of new controls, both for advanced layout and entirely new user interface components. WPF also covers a wide range of areas beyond traditional user interfaces, including document support and 3D drawing. Even though it doesn't have all the controls that Windows Forms does, it still does an awful lot. It's extremely useful for...

Iron Python and the CLR

So far, we've focused on navigating the .NET framework and the Python language, emphasizing the skills you need to make effective use of IronPython. But not all .NET concepts map easily to Python concepts certain corners of .NET can't be brought directly into Python. This section looks at some of these dusty corners and how they work in IronPython. Most of the things we explore are simple but, even if they're easy, you need to know the trick in order to use them. The first line of IronPython...

The NET Xml Writer

The .NET XML support is enshrined in the System.Xml assembly. The System.Xml namespace has classes for reading and writing XML. There are further namespaces for working with XML schema, XSLT transformations, and XPath queries. Table 5.2 shows the major XML namespaces in .NET 2.0. Provides support for standards-based XML support. Includes the XmlReader and XmlWriter classes. Support for XML Schemas in the form of schema definition language XSD schemas. Classes to serialize objects in XML form....

Working with Visual Studio or Mono Develop

Net Opensource

Visual Studio Express is free to download and use, but you have to choose which language you'll be developing with. There are separate versions for C , C , VB.NET, and web development, but you can have several different versions of Visual Studio Express installed on the same machine. If you have Visual Studio Professional, then you don't have to make a choice, as it supports all of the standard .NET languages. Figure 14.1 shows a new class library being created with the VB.NET version of Visual...

Visual Studio Express and ironPython

Microsoft Visual Express Interface

For this example, we use the free version of Visual Studio, Visual Studio Express. Visual Studio Express doesn't have IronPython integration, so we have to find another way to work with it to create our dialog. Depending on which version you download,9 it can generate Visual Basic, C , C , or Visual J . Because they all compile to .NET assemblies and we won't be directly writing code in this example, it doesn't really matter which one you choose. Having generated code in another language can be...

Trying it out using PostgreSQL

To begin exploring the Data Provider layer, we need a database to work with and a corresponding data provider to connect to it from IronPython. In these examples we're going to use PostgreSQL, a high-quality open source DBMS. You can download the Figure 12.2 The structure of a DataSet Figure 12.2 The structure of a DataSet database engine from www.postgresql.org, and the ADO.NET data provider for PostgreSQL is Npgsql, which is available at npgsql.org. You can administer Postgres databases...

WMI and the System Management assembly

Powershell Ntlogevent

One of the primary Windows interfaces for system management is Management Instrumentation, known affectionately by the acronym WMI. WMI is a management infrastructure, through which system components provide information about their state and notification of events. You can use WMI to change configuration, interrogate the local system or remote computers, and respond to events. Practical uses for WMI include tasks like inventorying all installed software, uninstalling programs, creating...

Using a simple web service

When an article is published on a weblog, the blogging system will update its Atom or RSS feed so that news readers can alert users to the new article. We can download the feed using the WebClient class, which provides a high-level interface for talking to websites. gt gt gt from System.Net import WebClient gt gt gt url gt gt gt content WebClient .DownloadString url Now content is a string containing XML in the Atom format. An Atom document looks something like what you see in listing 12.14.