pygame_gui_examples icon indicating copy to clipboard operation
pygame_gui_examples copied to clipboard

color of button

Open plotti opened this issue 4 years ago • 1 comments

i simply want to change the color of some buttons why leaving others the same. i know i can theme all in the json file, but what about individual ones?

plotti avatar Jan 26 '21 09:01 plotti

You can also theme an individual button if you give it a unique object ID, or a class of buttons with a class ID. See the docs here:

https://pygame-gui.readthedocs.io/en/latest/theme_guide.html

And the ObjectID class here:

https://github.com/MyreMylar/pygame_gui/blob/0cbf7056518377b455d51a8d20167f4029756ad9/pygame_gui/core/ui_element.py#L19

Which you can pass into a button something like this:

https://github.com/MyreMylar/pygame_gui/blob/0cbf7056518377b455d51a8d20167f4029756ad9/pygame_gui/elements/ui_drop_down_menu.py#L116-L125

By convention, object ID strings begin with a # and class ID strings begin with a @ symbol.

These class and object IDs can be used in theme file blocks just like the element IDs and the precedence order goes object ID-> class ID-> element ID. So the theming parameters in any object ID block for an element will be used if they exist, if there are none it will look for any class ID parameters, and then for any element ID parameters - before finally using defaults if none of the other classes are found.

MyreMylar avatar Jan 26 '21 10:01 MyreMylar