Skip to content

Support the use of an image in UIButton from python code without a theme entry #622

Open
@aelydam

Description

@aelydam

Is your feature request related to a problem? Please describe.
No.

Describe the solution you'd like
Let us to make a button to use an image from code instead of setting it up in the theme json.
In the game I'm working, I'm using buttons to create a hotbar where the player can select spells. Each spell has its own icon, and there are some 50+ possible icons.
Setting each possible icon in the theme file and a ObjectID for each spell would be really annoying.
Using code to retrieve each image from the spell database would be much more useful.

Describe alternatives you've considered
As a workaround, I'm setting button.normal_image = my_surface, button.hovered_image = .... and running button.rebuild() and replacing _set_any_images_from_theme in a subclass.
This seems to work, but I'm not sure it would have undesired consequences.

I think implementing this, would open the way for a future implementation of icons for UISelectionList, since behind the scenes each item of a selection list is an UIButton.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions