icon
pdwidgets.widgets.icon
Icon display widget.
Icon(parent, x=0, y=0, w=None, h=None, align=None, align_to=None, fg=None, bg=None, visible=True, value=None, padding=None, chroma=None)
Bases: Widget
Monochrome or BMP565 icon display.
Initialize an Icon widget to display an icon.
Two asset kinds are supported, both loaded via FrameBuffer.from_file:
- Monochrome
.pbm(1 bit-per-pixel) — recolored to the icon'sfg/bgat draw time via a 2-entry palette (the default). - Color RGB565
.bmp(BMP565) — blitted as-is; passchromato treat one color as transparent. No PNG is used anywhere.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
Widget
|
The parent widget or screen that contains this icon. |
required |
x
|
int
|
The x-coordinate of the icon. |
0
|
y
|
int
|
The y-coordinate of the icon. |
0
|
w
|
int
|
The width of the icon. |
None
|
h
|
int
|
The height of the icon. |
None
|
align
|
int
|
The alignment of the icon. |
None
|
align_to
|
Widget
|
The widget to align to. |
None
|
fg
|
int
|
The color of the icon (monochrome assets only). |
None
|
bg
|
int
|
The background color of the icon. |
None
|
visible
|
bool
|
The visibility of the icon. |
True
|
value
|
str
|
The icon file to display ( |
None
|
padding
|
tuple
|
The padding on each side of the icon. |
None
|
chroma
|
int
|
Transparent color key for color (BMP565) icons. |
None
|
Usage
icon = Icon(screen, value="icon.pbm") status = Icon(bar, value="battery_color_24dp.bmp")
changed()
Update the icon when the value (file) changes.
draw(_=None)
Draw the icon on the screen.
Color (BMP565) icons are blitted directly (with chroma as the
transparent key when set); monochrome icons are recolored to
fg/bg via the shared 2-entry palette buffer.
load_icon(value)
Load icon file, cache it, and record whether it is a color asset.