Archive for March, 2010

Last week, I was trying to find out how to get my photo’s metadata. I had noticed that Windows could display the camera model, creation date and lots of other data on my photos, but I couldn’t remember what that data was called. I finally found what I was looking for. The term is EXIF (Exchangeable Image File Format). For this post, we’ll take a look at the various 3rd party packages that give you access to this information. (more…)

Have you ever wanted to restart your Windows PC with out pressing Start, Shutdown or CTRL+ALT+DEL? What about restarting your annoying co-worker’s PC…the one who just doesn’t know when to shut up? Well, Python has the answer and this blog will tell you how to do it! (more…)

The other day, I was chatting with some wxPython newbies on the wxPython IRC channel and one of them wanted to know how to display images in wx. There are lots of different ways to do this, but I had a pre-made solution that I’d cobbled together a couple of years ago for work. Since this is a fairly popular topic, I thought it would be wise to let you, dear reader, in on the secret. (more…)

Python’s standard library is known for including lots of handy modules and packages that can be used without installing anything else. That’s one of the primary reasons that its standard library is called “batteries included” so often. So it should come as no surprise that Python includes a Windows only module for editing the Windows Registry. This particular module goes by the odd name of _winreg (odd because it starts with an underscore). In this article, we’ll learn the basics of working with the Registry using this “battery”. (more…)

Yesterday, I received a request to create a GUI with Tkinter or wxPython that had an image for the background with buttons on top. After looking at Tkinter, I discovered that it’s PhotoImage widget only supported two formats: gif and pgm (unless I installed the Python Imaging Library). Because of this, I decided to give wxPython a whirl. Here’s what I found out. (more…)

The grid widget in wxPython is one of the most complex GUI elements that you’ll work with in this toolkit. In this article you will learn the basics of grid creation and usage. One of the major uses for a grid is to display tabular data. Another use is to create some kind of spreadsheet. If you need something where you need a lot of cells that can be edited easily, then the grid widget is probably what you want. The ListCtrl in Report Mode is similar in appearance to the grid and can be used as a replacement for the grid depending on your needs. (more…)

The subtitle for this article could easily be “How To Create PDFs with Python”, but WordPress doesn’t support that. Anyway, the premier PDF library in Python is Reportlab. It is not distributed with that standard library, so you’ll need to download it if you want to run the examples in this tutorial. There will also be at least one example of how to put an image into a PDF, which means you’ll also need the Python Imaging Library (PIL). As I understand it, Reportlab is compatible with Python 2.x, IronPython and Jython. They are currently working on a port for Python 3.x (or will be soon). (more…)

Before PyCon, I was approached by a representative from Packt Publishing to review one of their books. They wanted me to read Daniel Arbuckle’s Python Testing: Beginner’s Guide. I’m not really into testing frameworks or test driven development and thought this would be a good excuse to learn the methodology and see if it was something that was actually valuable or just a lot of hype. The book is only 256 pages long, so I told the Packt contact that it would probably take me a week or so to review. After a week, she seemed kind of anxious that I wasn’t done. Thus, this is a partial review. I don’t like being pressured to review something fast. I want my reviews to be thorough and of the best quality I can make them. You will get a thorough review of the chapters that I did manage to finish. If you want a full review, I’m pretty sure someone else on Python Planet said they were doing one. (more…)

This week I was tasked with trying to find a way to find out what the Peak Commit value was on our virtual workstations. The reason being that we are trying to save money and were wondering if we were allocating too much memory or not. We didn’t need the Total Commit Charge or the Limit Commit Charge values, but since I figured out how to get those during my research, I’ll show how to get those as well. (more…)

Have you ever wondered what software was installed on your PC? Most people who use Windows would probably go to Add/Remove Programs to find out this information, but they’re not programmers. No, programmers have to script it because it’s just in our blood to do so. I actually had another reason to do so: my boss wanted me to log what was installed on our user’s PCs so we’d know if our users were installing unauthorized software. Thus, there’s also a practical reason to attempt this. (more…)