Item and Size Classes

class gallerynpy.Item(name: str, resource, size: Size, song: str = None, condition: str = None, tooltip: str = None)

Represents a single item in gallerynpy gallery.

Parameters:
  • name – The item name. Must be unique.

  • resource – The resource of the item.

  • size – The size of the item thumbnail.

  • song – A valid filepath for an audio that renpy can load.

  • condition – The condition to unlock the item.

  • tooltip – The tooltip text to display when the item is hovered.

if_condition(to_return)

Gets the given param if this Item meets the condition it has.

See also meets_condition

Parameters:

to_return – The object to return

Returns:

to_return if it meets the condition, None otherwise

property condition: str
Getter:

Gets the item condition.

Setter:

Sets the item condition.

Parameters:

condition – The new condition to unlock the item

property meets_condition
Getter:

Checks if this Item meets the condition it has or does not have it.

property name: str
Getter:

Gets the item name

Setter:

Sets the item name

Parameters:

name – The new item name. Must be unique.

property resource
Getter:

Gets the item resource.

Setter:

Changes the item resource

Parameters:

resource – The new resource of the item.

property song: str
Getter:

Gets the item song.

Setter:

Sets the item song.

Parameters:

song – A valid filepath for an audio that renpy can load

property thumbnail: Thumbnail
Getter:

Gets the thumbnail object of the item. If not meets its condition, returns a thumbnail of the locked resource

property tooltip: str
Getter:

Gets the item tooltip.

Setter:

Sets the item tooltip.

Parameters:

tooltip – The new item tooltip

class gallerynpy.Size(width: int, height: int)

Represents the dimensions (integers) of an image.

Parameters:
  • width – The width dimension.

  • height – The height dimension.

static from_size(size: Size) Size

Creates a new size object from the given size.

Parameters:

size – The size object

Raises:

TypeError – If the given size not is an instance of Size.

Returns:

The new size object.

set(size: Size)

Sets the actual dimensions to those of the given size.

Raises:

TypeError – If the given size not is an instance of Size.

Parameters:

size – The size object with the new dimensions.

property aspect_ratio
Getter:

Gets the aspect ratio of the current dimensions.
Calculated as width / height.

Returns:

The calculated aspect ratio.

property height: int
Getter:

Gets the height of the size.

Setter:

Sets the height of the size.
This value must be a positive integer.

property width
Getter:

Gets the width of the size.

Setter:

Sets the width of the size.
This value must be a positive integer.