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

How to give a Button item a RGBA Color? #752

Open
kami83 opened this issue Jan 8, 2025 · 2 comments
Open

How to give a Button item a RGBA Color? #752

kami83 opened this issue Jan 8, 2025 · 2 comments

Comments

@kami83
Copy link

kami83 commented Jan 8, 2025

Hi,

i would like to change the color from a Button item like this:

v[sender.name].background_color = "RGBA(1.000000,0.400000,0.400000,1.000000)"
But this is not working. The color is always white after this. So how to give a RGBA value?

Thx a lot.

BR kami

@cclauss
Copy link
Contributor

cclauss commented Jan 8, 2025

On the Pythonista console:

>>> from ui import Button
>>> button = Button()
>>> button.background_color
(0.0, 0.0, 0.0, 0.0)
>>> button.background_color = (1.000000, 0.400000, 0.400000, 1.000000)
>>> button.background_color
(1.0, 0.4, 0.4, 1.0)

The ALPHA value might take a bit of getting used to, so play with alpha being 00, 0.5, and 1.0.

Also hex ("#FF0000") and CSS colors... https://omz-software.com/pythonista/docs/ios/scene.html#colors

>>> button.background_color = "magenta"
>>> button.background_color
(1.0, 0.0, 1.0, 1.0)
>>> button.background_color = "midnightblue"
>>> button.background_color
(0.098039, 0.098039, 0439216, 1.0)

@kami83
Copy link
Author

kami83 commented Jan 9, 2025

Thanks a lot. This is working fine.

BR kami

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