Skip to content

Commit e400294

Browse files
authored
Cache decoded toga color on gtk (#3117)
Cache decoded color on GTK backend.
1 parent 59d427a commit e400294

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

changes/3117.misc.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
On GTK, native colors representations are now cached.

gtk/src/toga_gtk/colors.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ def native_color(c):
66
color = CACHE[c]
77
except KeyError:
88
color = (c.rgba.r / 255, c.rgba.g / 255, c.rgba.b / 255, c.rgba.a)
9+
CACHE[c] = color
910

1011
return color

gtk/src/toga_gtk/widgets/button.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ def set_enabled(self, value):
3636

3737
def set_background_color(self, color):
3838
# Buttons interpret TRANSPARENT backgrounds as a reset
39-
if color == TRANSPARENT:
40-
color = None
41-
super().set_background_color(color)
39+
super().set_background_color(None if color is TRANSPARENT else color)
4240

4341
def rehint(self):
4442
# print(

0 commit comments

Comments
 (0)