toga icon indicating copy to clipboard operation
toga copied to clipboard

`_background_supports_alpha` should be added to WinForm ProgressBar

Open ikus060 opened this issue 2 years ago • 3 comments

Describe the bug

As title explain, ProgressBar widget on Windows doesn't support alpha color and raise an exception when set to transparent. To avoid this, the widget class should declare _background_supports_alpha = False

Steps to reproduce

Simply create a Progress bar with TRANSPARENT background.

Expected behavior

Should not raise an exception.

Screenshots

No response

Environment

  • Operating System: Windows
  • Python version: 3.10
  • Software versions:
    • Briefcase: NA
    • Toga: 0.4.2
    • ...

Logs

    self._applicator.set_background_color(value)
  File "c:\Users\vmtest\Documents\minarca-agent\.venv\lib\site-packages\toga\style\applicator.py", line 51, in set_background_color
    self.widget._impl.set_background_color(color)
  File "c:\Users\vmtest\Documents\minarca-agent\.venv\lib\site-packages\toga_winforms\widgets\base.py", line 132, in set_background_color
    self.native.BackColor = win_color
System.ArgumentException: Control does not support transparent background colors.
   at System.Windows.Forms.Control.set_BackColor(Color value)

Additional context

No response

ikus060 avatar Feb 26 '24 21:02 ikus060

Thanks for the report. Your analysis seems entirely correct; a patch would be welcome.

It looks like this wasn't picked up because the testbed test_progressbar doesn't import any of the color tests (cf the testbed tests for test_textinput. Adding the extra imports will exercise the color APIs; there may be some changes needed on the various platform probes to make the tests pass.

It also makes me wonder how many other widgets aren't exercising these tests...

freakboy3742 avatar Feb 27 '24 00:02 freakboy3742

@freakboy3742 Thanks for the confirmation. I might try to make a PR for this little change. Question for you. How can I run the testbed ? I don't see any documentation about how to run the test.

ikus060 avatar Feb 27 '24 12:02 ikus060

@ikus060 There's a section on running the testbed in the contribution guide.

freakboy3742 avatar Feb 27 '24 21:02 freakboy3742