Skip to content

Commit

Permalink
Correct handling of color for non-button widgets.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Feb 25, 2023
1 parent 163fa97 commit 8c24cbe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions gtk/tests_backend/widgets/button.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from toga.colors import TRANSPARENT
from toga_gtk.libs import Gtk

from .base import SimpleProbe
Expand All @@ -13,8 +14,8 @@ def text(self):
@property
def background_color(self):
color = super().background_color
# Background color of
if color.r == 0 and color.g == 0 and color.b == 0 and color.a == 0.0:
# Background color of TRANSPARENT is treated as a reset.
if color == TRANSPARENT:
return None
return color

Expand Down
10 changes: 8 additions & 2 deletions gtk/tests_backend/widgets/properties.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
from travertino.fonts import Font

from toga.colors import rgba
from toga.colors import TRANSPARENT, rgba
from toga.style.pack import CENTER, JUSTIFY, LEFT, RIGHT
from toga_gtk.libs import Gtk, Pango


def toga_color(color):
if color:
return rgba(
c = rgba(
int(color.red * 255),
int(color.green * 255),
int(color.blue * 255),
color.alpha,
)

# Background color of rgba(0,0,0,0.0) is TRANSPARENT.
if c.r == 0 and c.g == 0 and c.b == 0 and c.a == 0.0:
return TRANSPARENT
else:
return c
else:
return None

Expand Down

0 comments on commit 8c24cbe

Please sign in to comment.