question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing the color of button changes the tint of the background image

See original GitHub issue

This is the code for creating the upper right button:

    button = Button(size_hint_y=None, text='Einstellungen')
    # button.color = get_color_from_hex('#e0080d')

and the resulting app: (please ignore the crappy pixel art etc. 😉)

normal working app screenshot

but when I uncomment the line to change the text color of the button, this is what it looks like:

bildschirmfoto vom 2014-07-31 22 55 06

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Dalkercommented, Nov 18, 2016

@inclement Thanks for taking the time to reply.

I now see that it does make sense that the order between the properties can matter in this situation. Well, not “properties” per se, but “canvas instructions”, as you point out, which I guess is the initial source of confusion: when looking at a .kv file for the first time, these really do “look” like if they were “properties” (and that’s why the newcomer can be confused by the “contamination” behaviour).

I’m not sure you’ve understood it fully

I definitely didn’t.

May I suggest adding a little paragraph around the end of the Pong tutorial (as an extra bullet to the Where to go now? section, where suggested extra features are mentioned, inviting the reader to try and modify/improve the game) explicitly mentioning something similar to:

  • Make the ball yellow while keeping everything else white. Warning: anything under canvas: in a .kv file is not a class property, but rather a canvas instruction. This can have effects that seem unexpected to the newcomer. For instance, a Color: canvas instruction changes the color of the “brush” globally, and can thus affect other objects drawn by any subsequent canvas instructions of any object. It is therefore good practice to always specify a Color: explicitly at the beginning of the canvas: section of every class. In this suggested improvement to Pong, this is however not necessary: it is enough to surround the Ellipse: instruction of the ball’s canvas to change the brush to yellow right before drawing it, and then back to the default white right afterwards.

That way, the newcomer would immediately have the opportunity to be confronted to this behaviour and understand what to be aware of.

1reaction
CreamyCookiecommented, Aug 2, 2014

@inclement I can’t reopen this AFAIK.

It did work with your suggestion of using a Color instruction, but it doesn’t make any sense to me, why setting the color of a button changes the default color for other instructions. This certainly is neither user-friendly nor does it follow the Principle of least astonishment. Please expand on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change tint color of UIButton based on background image
here is the extension to set the background color for UIButton according to his sate selected, normal or highlighted
Read more >
How to Change the Background Color of Button in Android ...
Step 1: Create a New Project · Step 2: Working with the activity_main.xml file · Step 3: Add a resource directory named as...
Read more >
How to Change the Background Color of a Button in Android ...
In this video, I show you the recommended way to update the background color of a button in Android Studio. We use a...
Read more >
4 Ways To Change A Background Color In Photoshop
Get My FREE Ebook To Help You Master Photoshop: ...
Read more >
Add or change the background color of cells - Microsoft Support
Select All button. Click Home > the arrow next to Fill Color Button image , or press Alt+H, H. Font group ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found