Photo

An image you can show in widgets that take an image option (buttons, labels, …). Supports PNG, GIF, and the other formats Tk understands.

Example

const logo = new Photo({ file: 'logo.png' });
app.TLabel({ image: logo }).pack.configure({ padx: 20, pady: 20 });

Load from a packaged app's bundle with a //zipfs: path (see Packaging):

const logo = new Photo({ file: '//zipfs:/app/logo.png' });

Options

Option Type Description
file string Path to an image file (real path or //zipfs: bundle path).
data string / bytes Inline image data (e.g. base64), instead of file.
width / height number Force a size.
format string Override the auto-detected format.

Methods

Method Description
imageWidth() / imageHeight() The image's pixel size.
blank() Clear to fully transparent.

To display it, pass the Photo as a widget's image option.

See also