bootstack.images.AppIcon#
- class bootstack.images.AppIcon(icon, *, background='primary', foreground='white', radius=0.22, shape='auto')#
Bases:
objectA generated application icon.
Renders a Bootstrap glyph in one of two shapes:
a tile — the glyph in
foregroundon a filled, roundedbackground(the macOS look); orglyph-only — the glyph alone in the
background(brand) color on a transparent field (the typical Windows and Linux look).
By default (
shape='auto') the shape follows the platform and the size: a tile for macOS targets (.icns, or running on macOS); on Windows and Linux, glyph-only at small sizes (a clean mark in a tiny title bar) and a tile at larger sizes (a branded icon in the taskbar and launchers). A multi-size.icotherefore carries both. Setshapeto'tile'or'glyph'to force one shape at every size.Pass an
AppIconas theicon=of anApporWindowto set its taskbar and title-bar icon without supplying an icon file, or callsaveto export a packaging asset (for example, an icon for a PyInstaller build).Colors may be theme color tokens (such as
'primary') or literal hex strings. Tokens are resolved once, when the icon is generated, so the icon does not change as the theme changes; supply a token while an application is active, or use hex values. Generating an icon outside a running application — such as during a build — must use hex values, since no theme is available to resolve a token against.- save(path)#
Write the icon to a file, choosing the format by file extension.
Use this to produce a packaging asset — for example, an icon to point a PyInstaller build at. The format follows the path suffix:
.ico— a multi-resolution Windows icon..icns— a macOS icon..png— a single 256-pixel image.
- Parameters:
path (str | Path) – Destination file path ending in
.ico,.icns, or.png.- Returns:
The path that was written, as a string.
- Raises:
ValueError – If the file extension is not one of the supported types.
- Return type:
- to_image(size=256, *, tiled=None)#
Render the icon to an
Imagehandle for on-screen display.Use this to show the application icon inside the app itself — for example on an about screen or a splash panel.