wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
http://wxpython.org/
2.33k stars 515 forks source link

SButton SetButtonColour does nothing #1716

Open carandraug opened 4 years ago

carandraug commented 4 years ago

Operating system: Linux wxPython version & source: 4.1.0 gtk3 (phoenix) wxWidgets 3.1.4 from PyPI Python version & source: Python 3.7 from Debian repos

The SButton class has GetButtonColour and SetButtonColour methods which internally set the _buttoncolour attribute. However, this is not used anywhere which means that calling SetButtonColour does nothing. This affects all the SButton subclasses.

Metallicow commented 4 years ago

Not sure atm... but Andrea might have planned to have an option to change the color via dc drawing code, so you might start looking there... But since the circle/oval button produced by the code has a bit of gradienting, then you might have to do a bit of work to figure out what color helper func to use to get a nice smooth color transition.

carandraug commented 4 years ago

What I have done to workaround this was:

        correction = [c/255.0 for c in colour]
        self._mainbuttondown = self._mainbuttondown.AdjustChannels(*correction)

which applies the colour straight into the image keeping the gradient of the button. This works because the base gradient is greyscale. I can prepare a PR if you want. It would also be nice if it was possible to have separate colours for button down and up.