Icons & Images
Provides methods for convenient icons and image handling
Icon management
- xlgui.icons.MANAGER
Singleton instance of the
IconManager
- class xlgui.icons.IconManager[source]
Provides convenience functions for managing icons and images in general
- add_icon_name_from_directory(icon_name: str, directory: str) str | None[source]
Registers an icon name from files found in a directory
- Parameters:
icon_name – the name for the icon
directory – the location to search for icons
- Returns:
filesystem location of the highest-quality icon of this name, or None if not found
- add_icon_name_from_file(icon_name: str, filename: str, size: int | None = None) None[source]
Registers an icon name from a filename
- Parameters:
icon_name (string) – the name for the icon
filename (string) – the filename of an image
size (int) – the size the icon shall be registered for
- add_icon_name_from_pixbuf(icon_name: str, pixbuf: <mocks.Mock object at 0x7f720b1a8850>, size: int | None = None) None[source]
Registers an icon name from a pixbuf
- Parameters:
icon_name – the name for the icon
pixbuf – the pixbuf of an image
size – the size the icon shall be registered for
- pixbuf_from_icon_name(icon_name: str, size: int | <mocks.MockGiModule object at 0x7f720b166a90> = <mocks.MockGiModule object>) <mocks.Mock object at 0x7f720b6fd790> | None[source]
Generates a pixbuf from an icon name
- Parameters:
icon_name – an icon name
size – the size of the icon, will be tried to converted to a GTK icon size
- Returns:
the generated pixbuf
Utilities
- class xlgui.icons.ExtendedPixbuf(pixbuf)[source]
A
GdkPixbuf.Pixbufwrapper class allowing for interaction using standard operatorsThus you can do the following:
pixbuf1 + pixbuf2(horizontally appendspixbuf2topixbuf1)pixbuf * 5(multiplies the content ofpixbuf)pixbuf1 & pixbuf2(simple composition ofpixbuf2onpixbuf1, the desired alpha value has to be included in the pixbufs themselves)pixbuf1 < pixbuf2,pixbuf1 > pixbuf2(compares the pixbuf dimensions)pixbuf1 == pixbuf2(compares the pixel data, use the is operator to check for identity)
Even more is possible with the provided verbose methods
- add_horizontal(other, spacing=0)[source]
Horizontally appends a pixbuf to the current
- Parameters:
other (
GdkPixbuf.Pixbuf) – the pixbuf to appendspacing (int) – amount of pixels between the pixbufs
- Returns:
a new pixbuf
- Return type:
- add_vertical(other, spacing=0)[source]
Vertically appends a pixbuf to the current
- Parameters:
other (
GdkPixbuf.Pixbuf) – the pixbuf to appendspacing (int) – amount of pixels between the pixbufs
- Returns:
a new pixbuf
- Return type:
- composite_simple(other)[source]
Composites a pixbuf on the current pixbuf at the location (0, 0)
- Parameters:
other (
GdkPixbuf.Pixbuf) – the pixbuf to composite- Returns:
a new pixbuf
- Return type:
- move(offset_x, offset_y, resize=False)[source]
Moves the content of the current pixbuf within its boundaries (clips overlapping data) and optionally resizes the pixbuf to contain the movement
- Parameters:
- Returns:
a new pixbuf
- Return type:
- multiply_horizontal(multiplier, spacing=0)[source]
Horizontally multiplies the current pixbuf content
- Parameters:
- Returns:
a new pixbuf
- Return type:
- xlgui.icons.extended_pixbuf_new_from_file(filename)[source]
Returns a new
ExtendedPixbufcontaining an image loaded from the specified file- Parameters:
filename (string) – the name of the file containing the image to load
- Returns:
a new pixbuf
- Return type: