Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

color of button #7

Open
plotti opened this issue Jan 26, 2021 · 1 comment
Open

color of button #7

plotti opened this issue Jan 26, 2021 · 1 comment

Comments

@plotti
Copy link

plotti commented Jan 26, 2021

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?

@MyreMylar
Copy link
Owner

MyreMylar commented Jan 26, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants