will

It's All Geek to Me

Posts about technology, with a focus on web development with Python.

I am the author of Beginning Games Development with Python and PyGame.

This is something I have been hacking together for a while now; FS is a file-system abstraction for Python. It has reached a stable state and is worthy of an official (0.1.0) release. continue reading…

To compensate for the previous post, here is a picture of something pretty. Work on my pretty-charts (working title) web application is progressing slowly but steadily. :-)

A well-designed website will tend to have a consistent colour scheme where the various design elements sit harmoniously together, yet contrast well enough  that the user can separate them visually. Selecting these colors is a mixture of an art and a science. Its an art because only a human being can know if the colors project the image required by the site (business-like, mellow, funny etc), but it's also a science because complimentary and contrasting colors can be produced from a source colour using only math. As an engineer the math part appeals to me, but the art part "confuses and enrages me" (guess the quote). continue reading…

Python programmers love a challenge, so I thought I would throw this one to the lazyweb.

I have an app that generates a large sequence of files, the nature of which is unimportant. What is important is generating a location to store them. To keep the directory structure manageable there should be no more than 100 files plus sub-directories in any given directory. For instance if there are 99 files in a directory, then there is only room for one more file or a directory -- bringing the total to 100. There is an additional requirement that the directory structures should be as flat as possible, i.e. foo/bar for the nth item is preferable over foo/bar/baz. To summarize the requirements: continue reading…

I spent another afternoon working on my pie chart project. I'm using PyCairo to render labels over the chart render. The tricky part was finding the position at the center of each pie segment to render the label over. There's no way of retrieving that information from Povray, so I had to do the math myself and calculate the coordinates manually. Fortunately I had a 3D math module that I was intimately familiar with, having written it just last year (its always gratifying to re-use code for a new purpose)!

When writing the image wrapping script, I came across a difference between Firefox and Opera. Basically, when there are small floated divs in a vertical stack, the text to the right will be aligned to the topmost div in Firefox, even if the divs underneath extend farther than the topmost div. Opera handles this situation better and places the text after the maximum extents of the floated divs. Take the following HTML:

<div style="float:left;clear:left;width:100;height:8px;background-color:#55f;" ></div>

<div style="float:left;clear:left;width:120;height:8px;background-color:#66f;" ></div>

<div style="float:left;clear:left;width:140;height:8px;background-color:#77f;" ></div>

<div style="float:left;clear:left;width:160;height:8px;background-color:#88f;" ></div> continue reading…

After posting my latest pie chart image, it occurred to me that it would be pretty cool if the text flowed around the edge of the pie chart image rather than around a rectangle. This is not something that can be done simply with HTML / CSS, but it can be done by breaking the images up in to horizontal slices so that they extend only to the edge of the image, rather than to the absolute border.

If I googled for it, I suspect I could find tools to do this for me -- but where is the fun in that? Instead, I wrote a Python script that uses the Python Image Library to scan an image and output HTML that will allow text to wrap smoothing around the image. No additional images are produced, because the 'slicing' is done with CSS to select the part of the original image that is seen. continue reading…

I've been doing a little more work on my 3D pie-chart renderer. I've added beveling and tweaked colors to a point where I can render charts that -- in my opinion -- are a better quality than those produced from Apple's Numbers. Next step is to add labels over the main image. Povray does support rendering of True Type Fonts, but it is a 2D overlay that I'm looking for (not 3D text), so I plan to use PyCairo to render the labels. Once I've perfected the chart renderer I can build a polished web interface, and a web service for the render queue. All in Python, of course!

Since I've moved to Linux as my primary desktop (I know, about time), I've been motivated in porting some of my old software. This shouldn't be too difficult, since I try to work in as platform agnostic manner as possible, and when I do use a platform specific API I keep it nice and modular. Food File is probably the most popular app I ever created, although only since I made it free. As a commercial app, it didn't do to well, probably because it didn't get noticed amongst all the diet / food applications for Windows out there, or possibly because I am lousy at marketing. continue reading…

One of the things that used to annoy me about working with CSS, is that I had a mental block about margin and padding. I could never recall which was which, because the two terms mean pretty much the same thing; an arbitrary space around text. Frankly I think the creators of CSS should have used have called them inner-margin and outer-margin, or inner-padding and outer-padding. I'm sure there is a good reason for using the terms margin and padding (I'm guessing its from typesetting nomenclature), but to me they feel arbitrary and may have well have been called bob and jane.