I am trying automatically generate buttons to a menu using PIL in python.
The button should be small rectangular and have a little gradient from one color to another, and a little text in it.
Is PIL the best way to do this, or is Cairo a better alternative? Any suggestion to how I can accomplish this without having a image to start with..?
You can do this entirely with PIL if you start with a single pre-made white-to-black gradient image (that you've made in some other program) and then use the ImageChops module to manipulate this together with your primary image to get what you want.
For example to if you want to fade from red to blue: multiply red by the gradient, flip the gradient and multiply blue by this, and add these together.
If your images vary in size, you can scale the gradient image appropriately in PIL.
Generating a shaded button using PIL