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

_background_supports_alpha should be added to WinForm ProgressBar #2430

Open
ikus060 opened this issue Feb 26, 2024 · 3 comments · May be fixed by #2485 or #2484
Open

_background_supports_alpha should be added to WinForm ProgressBar #2430

ikus060 opened this issue Feb 26, 2024 · 3 comments · May be fixed by #2485 or #2484
Labels
bug A crash or error in behavior. good first issue Is this your first time contributing? This could be a good place to start! windows The issue relates to Microsoft Windows support.

Comments

@ikus060
Copy link

ikus060 commented Feb 26, 2024

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 ikus060 added the bug A crash or error in behavior. label Feb 26, 2024
@freakboy3742 freakboy3742 added the windows The issue relates to Microsoft Windows support. label Feb 27, 2024
@freakboy3742
Copy link
Member

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 freakboy3742 added the good first issue Is this your first time contributing? This could be a good place to start! label Feb 27, 2024
@ikus060
Copy link
Author

ikus060 commented Feb 27, 2024

@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.

@freakboy3742
Copy link
Member

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

@SahilNagpure07 SahilNagpure07 linked a pull request Apr 6, 2024 that will close this issue
4 tasks
@proneon267 proneon267 linked a pull request Apr 24, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior. good first issue Is this your first time contributing? This could be a good place to start! windows The issue relates to Microsoft Windows support.
Projects
None yet
2 participants