Archive for the 'Python' category

 | May 12, 2009 1:52 pm

In comparison to Windows and Mac OS X, installing PyQt on Linux is trivially easily.  It is likely that all of the software necessary for Python development is likely available in your favorite distribution repository.  If you are using the most recent version of Ubuntu 9.04 (and who isn’t), then, all you need to do is open up your terminal and type:

sudo apt-get install python-qt4 qt4-dev-tools python-qt4-dev build-essential pyqt4-dev-tools

The package manager (apt-get) will take care of downloading and installing any dependencies.  Once the installation routine finishes, you will have a fully working installation of Qt 4.5 and PyQt 4.5 without any compilation, configuration, or other miscellaneous headaches.  The qt4-dev-tools, pyqt4-dev-tools and python-qt4-dev packages install important tools used for creating user-interfaces.  The build-essential package installs the GNU compilers and autoconf tool chain.  If you will only be running PyQt programs, these additional packages are unnecessary.

 | February 9, 2009 4:46 pm

IronPython in ActionThere is an old adage, often used and much abused, “Give a man a fish and he will eat for a day.  Teach a man to fish and he will never want for food.”  And while this old saying is extremely tired and very much cliché, it is a surprisingly apt way for me to begin a review of “IronPython in Action,” a programming book by Michael J. Foord and Christian Muirhead.

“IronPython in Action” delves into the use of scripting (or dynamic) languages and how they merge with Microsoft’s enormous .Net platform.  For readers of this site, it shouldn’t be any secret that I have been working hard to teach myself Python.  And while that particular adventure is better documented elsewhere, “IronPython in Action” has been central to it.  Indeed, it has been my primary reference manual and guide.

It’s been nearly six months and it’s far past time to write a review of the guide.  But this review is going to be a little bit different than others that you might read.  If you are looking for a more traditional summary, you might be better served by Craig Murphy’s exhaustive breakdown.  Rather than detail the contents and render an opinion, I would like to first tell a story and then focus on a much narrower question: Is IronPython valuable for people who are new to Python or .Net programming?  More to the point, can it be used to teach a novice “how to fish?”

Show me more… »

 | January 6, 2009 1:12 am
Figure 1. The main Podcast list for Podcatcher. This is an example of WPF data binding where a data template and data trigger have been applied. The selected item shows the feed description in addition to the feed name, link and image.

One of the most important and fundamental purposes of computers is to manipulate information. This can range anywhere from simple storage and retrieval to complex applications, like automated detection of diseased heart tissue. However, automated manipulation of data is only of limited interest. At some point, data must interact with human beings in order to be interesting. Luckily, Windows Presentation Foundation (WPF) has an extremely powerful feature meant to facilitate man’s interaction with his data. This feature is called data binding. As described by Microsoft:

“Data binding is the process that establishes a connection between an application and the underlying logic. If the binding has the correct settings, when the data changes its value, the elements that are bound to the data reflect changes automatically.”

Data binding has appeared in many incarnations among the various Microsoft technologies. A version of it can be found in Windows Forms as well among the various voodoo cults of web programming. Since data binding has been around for a while, the version included in WPF is a very mature technology. Tens of thousands of developers have helped Microsoft work out the rough edges and it is possible to do some rather sophisticated things.

While data binding is capable of doing sophisticated things to complex sets of information, you won’t find much of that here. Rather, this article and the others in this series will focus on a very simple application: manipulating and displaying information from RSS feeds. After all, I am hardly an expert in either IronPython or WPF. Rather, I plan to stick to comfortable ground and I will be returning to my Podcast aggregator. Previously, I created a download manager to handle the work of retrieving files; now it’s time to start tackling another major module: the Library. In doing so, I will compose variations on a theme. I will show how WPF displays data and facilitates user interaction with that data. This article will introduce the features of the project and provide some background on data-binding. Later articles will look at code and how to add in bells and whistles.

Show me more… »

 | December 16, 2008 6:49 pm

As described in part 1 of this article, vector graphics offer a tremendous number of advantages over their raster counterparts. These benefits include the ability to enlarge the image to any size without a loss of detail or quality and better reproduction in both print and online form. Combined with the existence of many high quality icon libraries, vector graphics represent a valuable source of art for desktop applications.

In part 2 of this article, we looked at a way to convert vector graphics using Adobe Illustrator. While useful, the XAML export plug-in has a number of limitations and is not always able to faithfully convert the image to XAML. Thus, while Adobe Illustrator is a good conversion method when working directly with artists and graphic designers who are able to provide art files in Adobe Illustrator (AI) format, it is not so well suited to existing OpenSource libraries which tend to be distributed in the SVG format.

Due to their use of alpha transparency, Adobe Illustrator is always able to read the images from other editors, though it contains basic SVG support. This is unfortunate as these icon libraries, such as the Oxygen Icon Set, are freely available under permissive licenses. Fortunately, there is a way to overcome some of these limitations. In this article, I will look at how to convert SVG icons to XAML using the stand-alone utility XamlTune. We will also be using the OpenSource SVG editor, Inkscape.

Show me more… »

 | December 14, 2008 1:34 am

In part 1 of this article, I introduced some of the difficulties in converting SVG graphics to WPF XAML. These included inconsistent implementations across SVG editors and the lack of a high quality XAML export. I also introduced two methods for the conversion of vector graphics to XAML. The first uses Adobe Illustrator and the second makes use of free standalone program called XamlTune. In this article will take a detailed look at the first of these methods. In part 3, we will look at the second method.

Show me more… »

 | December 13, 2008 7:35 pm

In a perfect world, most would be judged on the quality of their ideas and depth of character. However, more often they are judged by looks and dress.  What is true in the world of people is also true in the world of software. More than one website, computer program, or presentation has suffered because it is unattractive. In the inevitable fight between style and substance, substance often exerts more than its fair share of influence.

Given the importance of stylistic presentation, it is somewhat ironic that one of the most neglected components of many software projects it that of the artwork. While the code may be carefully vetted and analyzed, often icons and other artwork are chosen at the last stage of the design. While this might be unfortunate, it is due to an important reality: high quality artwork can be very, very expensive.

Fortunately, there are a number of beautiful graphics libraries that are either cheap or free of charge. Most are available under permissive or OpenSource licenses and can even be used in commercial products. There is just one problem; nearly all of these libraries are available in formats which don’t play nicely with WPF and XAML. With a little bit of planning and strategy, however, it isn’t too difficult to use these resources in your own applications.

Show me more… »

 | December 11, 2008 3:38 pm

After finishing the download manager of my podcast aggregator (PodCatcher), I took a few days off to work on other things. After a brief break, though, I am back at the grindstone and I can happily say that it is starting to come together.

The next major component of the aggregator that I will work on is the library module. This will include the functions necessary to view, add, remove and manage the different Podcast feeds and the individual podcast episodes. Due to my initial architecture, I have hit a patch of luck.

Since the aggregator sits on top of the Windows RSS Platform, much of the “library” functionality is already handed to me. Further, because Internet Explorer uses the RSS platform and the Common Feeds List, there will be a nice integration with other programs. The ability to subscribe to new podcasts from the browser always made more sense to me than the model of other aggregators, where management occurs exclusively in the Podcast Manager.

Since much of the backend is already written, I have been thrown into a realm of programming where I have done very little work: the user interface. While I touched on the user interface a little in the Learning IronPython series, I have now gotten serious about it. The screenshot shows the subsequent result. I have a prototype user interface for PodCatcher!

While putting the UI together, however, I discovered a bit of a surprise.  According to the Oracle of Google, there isn’t a lot of material on WPF and dynamic languages. What is worse, getting the UI to load and function isn’t as simple as applying stock C# principles. To answer my (many) questions I have spent quite a bit of time hunting down tutorials and looking at everything I can find about IronPython and WPF. After trundling through Google, the IronPython users archive, MSDN, and the major IronPython blogs, I have a pretty good list and I thought it might be of interest to others trying to learn IronPython.

Show me more… »

 | December 8, 2008 3:21 pm

Now that I have finished a major component of my PodCast client, I feel as though I have reached a transition point. I have managed to create a useful (albeit small) program and I have become much more productive when I use WPF, Python and the .Net frameworks. So I thought it prudent to take a moment and reflect on some of the lessons which I have learned over the course of the last few weeks. After all, learning doesn’t necessarily happen in the struggle and frustration of the moment, but in the quiet reflection which comes after.

While there were many specific things I wish I had known (for example, that the Win32 API is complicated), there were a few general items that I thought particularly helpful. As a result, this post is going to be painted in the broad swash of generalities. A few specific things I would like to touch on are: setting goals and measuring progress, following schedules while maintaining flexibility, working on a real (practical) project, trying new things out, limiting the number of dependencies, and seeking high quality examples and references.

Show me more… »

 | December 7, 2008 6:54 pm

In the last article of this series, my download manager based on the Background Intelligent Transfer Service (BITS) in Microsoft Windows had reached a functional (though far from aesthetically pleasing) state. Making use of a multithreaded model and interfacing with BITS through a C# wrapper, the download manager has been designed to integrate into my IronPython “learning project,” a PodCast plug-in for Windows Media Player.

Figure 1 – Right. User interface of the fully functional IronPython Download Manager. Major features include the ability to run downloads in the background without affecting foreground application performance and the ability to pause and resume downloads.

With all the major pieces in place, this article will focus on some of the smaller details which transform a rudimentary download manager into a functional one. The files for this article can be found here.

Show me more… »

 | December 1, 2008 10:42 pm

Now that the background and semi-theoretical parts about BITS, multithreading, and downloads have been dealt with; it’s time to start wrapping up ends and build a useable program. In this post, I will be looking at how to connect my multithreaded BackgroundWorker Object and SharpBITS to a functioning user interface that notifies the user of the download’s progress. For those wishing to follow along, the source files and assemblies for this article can be found here.

Show me more… »