Skip to content

Commit

Permalink
Fix color handling
Browse files Browse the repository at this point in the history
  • Loading branch information
chintal committed Mar 30, 2024
1 parent 6f82be4 commit 8b82ce8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions kivy_garden/ebs/marquee/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@
from kivy.core.window import Window
from kivy.animation import Animation
from kivy.properties import NumericProperty
from kivy.properties import ListProperty

from kivy_garden.ebs.core.colors import ColorBoxLayout


class MarqueeLabel(ScrollView):
spacer_width = NumericProperty(None)
bgcolor = ListProperty([1, 1, 1, 1])
color = ListProperty([1, 1, 1, 1])

def __init__(self, **kwargs):
bgcolor = kwargs.pop('bgcolor')
self.bgcolor = kwargs.pop('bgcolor')
self.color = kwargs.pop('color')
ScrollView.__init__(self, bar_width=0)

self._layout = ColorBoxLayout(size_hint_x=None,
bgcolor=bgcolor,
bgcolor=self.bgcolor,
orientation='horizontal')
self._mainlabels = []
self._lspacer = Widget(size_hint_x=None, width=Window.width)
Expand All @@ -33,6 +37,14 @@ def __init__(self, **kwargs):
self._callback = None
self._loop = None

def on_bgcolor(self, _, value):
if self._layout:
self._layout.bgcolor = value

def on_color(self, _, value):
for x in self._mainlabels:
x.color = value

def update_widths(self):
width = self._lspacer.width + \
self._rspacer.width + \
Expand Down Expand Up @@ -67,7 +79,7 @@ def text(self, value):

self._mainlabels = []
for t in texts:
l = Label(text=t, size_hint_x=None,
l = Label(text=t, size_hint_x=None, color=self.color,
text_size=(None, None), **self._label_params)
self._layout.add_widget(l)
l.bind(texture_size=self._set_mainlabel_width)
Expand Down

0 comments on commit 8b82ce8

Please sign in to comment.