refine news ticker
This commit is contained in:
parent
de33e99703
commit
a2897194d7
@ -72,6 +72,26 @@ themes = [
|
||||
hud_color=rio.Color.from_hex("2c89ff"),
|
||||
text_color=rio.Color.from_hex("FFFFFF"),
|
||||
light=False,
|
||||
),
|
||||
# Turquoise - Dark
|
||||
rio.Theme.from_colors(
|
||||
primary_color=rio.Color.from_hex("03dac5"),
|
||||
secondary_color=rio.Color.from_hex("018786"),
|
||||
neutral_color=rio.Color.from_hex("1e1e1e"),
|
||||
background_color=rio.Color.from_hex("121212"),
|
||||
hud_color=rio.Color.from_hex("03dac5"),
|
||||
text_color=rio.Color.from_hex("FFFFFF"),
|
||||
light=False,
|
||||
),
|
||||
# Turquoise - Light
|
||||
rio.Theme.from_colors(
|
||||
primary_color=rio.Color.from_hex("03dac5"),
|
||||
secondary_color=rio.Color.from_hex("018786"),
|
||||
neutral_color=rio.Color.from_hex("FFFFFF"),
|
||||
background_color=rio.Color.from_hex("FFFFFF"),
|
||||
hud_color=rio.Color.from_hex("03dac5"),
|
||||
text_color=rio.Color.from_hex("000000"),
|
||||
light=True,
|
||||
)
|
||||
]
|
||||
|
||||
@ -89,7 +109,7 @@ app = rio.App(
|
||||
build=pages.Home,
|
||||
),
|
||||
],
|
||||
theme=themes[2],
|
||||
theme=themes[6],
|
||||
assets_dir=Path(__file__).parent / "assets",
|
||||
on_session_start=on_session_start
|
||||
)
|
||||
|
||||
@ -15,14 +15,15 @@ class Header(rio.Component):
|
||||
rio.Image(from_root("ezgg_website/assets/placeholder_logo_grey.png"), align_x=0, width=8),
|
||||
"/"
|
||||
),
|
||||
rio.Text("News Ticker:", justify="left", width="grow", margin_left=0.8),
|
||||
Ticker(
|
||||
texts=[
|
||||
"Can this Tick?",
|
||||
"Yes it can!",
|
||||
"Rio is awesome",
|
||||
"Look at them suckers still using JS"
|
||||
"Ganz im Geiste der EZ GG wurde der Verein in einer schlecht beleuchteten Kellerbar gegründet",
|
||||
"Aktuelle hat der EZ GG e.V. sieben Mitglieder",
|
||||
"Bist du auch ein Genießer? Dann tritt uns doch bei!",
|
||||
"Auch Wasser wird zum edlen Tropfen, mischt man es mit Malz und Hopfen."
|
||||
],
|
||||
refresh_interval=5,
|
||||
refresh_interval=30,
|
||||
tick_in_order=True,
|
||||
style=TextStyle(italic=True),
|
||||
width="grow",
|
||||
|
||||
@ -19,16 +19,16 @@ class Ticker(Component):
|
||||
self.style = style
|
||||
self._tick_in_order = tick_in_order
|
||||
self._last_text = -1
|
||||
self.task = asyncio.get_event_loop().create_task(self._set_next_text())
|
||||
self._task = asyncio.get_event_loop().create_task(self._set_next_text())
|
||||
|
||||
def stop_ticking(self) -> None:
|
||||
self.task.cancel()
|
||||
self._task.cancel()
|
||||
|
||||
def start_ticking(self) -> None:
|
||||
if not self.task.cancelled():
|
||||
self.task.cancel()
|
||||
if not self._task.cancelled():
|
||||
self._task.cancel()
|
||||
|
||||
self.task = asyncio.get_event_loop().create_task(self._set_next_text())
|
||||
self._task = asyncio.get_event_loop().create_task(self._set_next_text())
|
||||
|
||||
def set_new_texts(self, new_texts: list[str]) -> None:
|
||||
self.stop_ticking()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user