Graphical representation of an image.

To display a centered GImage of the Stanford tree:

window = GWindow()
tree = GImage("StanfordTree.gif")
x = (window.width - tree.width) / 2
y = (window.height - tree.height) / 2
window.add(tree, x, y)

The above code assumes that you have a file named StanfordTree.gif in the current directory.

The search for matching image files begins in the current directory and, failing that, searches an images/ subdirectory relative to the calling script.



class ImageRow(parent, row, width)[source]

Bases: object

classmethod blank(width, height, background=< object>)[source]

Get the bounding box for this GImage.


Get this GImage’s filename.

classmethod from_data()[source]
classmethod from_file(filename)[source]

Initialize a new image from the given file.

The image file should either exist in the current directory or in a subdirectory named images/.

Parameters:filename – the name of the image file to load.
get_pixel(x, y)[source]

Get the pixel at (x, y).

set_pixel(x, y, pixel)[source]

Set the pixel at (x, y).