Q:

Python/Tkinter: Stretch an image horizontally?

Is it possible to stretch an image horizontally? 
Use case: I have a one pixel wide (60 pixel tall) image that I would like to stretch horizontally to fill its parent container. The purpose of stretching this image is to give the container in question the appearance of a gradient background.
Here's what I tried without success (the gradient image shows up, but just centers itself vs. stretching):
import Tkinter as tkinter
root = tkinter.Tk()

image = tkinter.PhotoImage( file='gradient1.gif' )
imgBackground = tkinter.Label( image=image )
imgBackground.pack( side='top', fill='x', expand=True )

root.mainloop()

A:

No, there is no way to stretch an image to fill the container. However, you can detect when a widget changes size and you can "repaint" the gradient. Use a canvas, and create a binding to <Configure> that draws the gradient. It sounds slow but it's plenty fast enough assuming you don't have hundreds of these.

