refine news ticker
This commit is contained in:
parent
de33e99703
commit
a2897194d7
@ -72,6 +72,26 @@ themes = [
|
|||||||
hud_color=rio.Color.from_hex("2c89ff"),
|
hud_color=rio.Color.from_hex("2c89ff"),
|
||||||
text_color=rio.Color.from_hex("FFFFFF"),
|
text_color=rio.Color.from_hex("FFFFFF"),
|
||||||
light=False,
|
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,
|
build=pages.Home,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
theme=themes[2],
|
theme=themes[6],
|
||||||
assets_dir=Path(__file__).parent / "assets",
|
assets_dir=Path(__file__).parent / "assets",
|
||||||
on_session_start=on_session_start
|
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.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(
|
Ticker(
|
||||||
texts=[
|
texts=[
|
||||||
"Can this Tick?",
|
"Ganz im Geiste der EZ GG wurde der Verein in einer schlecht beleuchteten Kellerbar gegründet",
|
||||||
"Yes it can!",
|
"Aktuelle hat der EZ GG e.V. sieben Mitglieder",
|
||||||
"Rio is awesome",
|
"Bist du auch ein Genießer? Dann tritt uns doch bei!",
|
||||||
"Look at them suckers still using JS"
|
"Auch Wasser wird zum edlen Tropfen, mischt man es mit Malz und Hopfen."
|
||||||
],
|
],
|
||||||
refresh_interval=5,
|
refresh_interval=30,
|
||||||
tick_in_order=True,
|
tick_in_order=True,
|
||||||
style=TextStyle(italic=True),
|
style=TextStyle(italic=True),
|
||||||
width="grow",
|
width="grow",
|
||||||
|
|||||||
@ -19,16 +19,16 @@ class Ticker(Component):
|
|||||||
self.style = style
|
self.style = style
|
||||||
self._tick_in_order = tick_in_order
|
self._tick_in_order = tick_in_order
|
||||||
self._last_text = -1
|
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:
|
def stop_ticking(self) -> None:
|
||||||
self.task.cancel()
|
self._task.cancel()
|
||||||
|
|
||||||
def start_ticking(self) -> None:
|
def start_ticking(self) -> None:
|
||||||
if not self.task.cancelled():
|
if not self._task.cancelled():
|
||||||
self.task.cancel()
|
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:
|
def set_new_texts(self, new_texts: list[str]) -> None:
|
||||||
self.stop_ticking()
|
self.stop_ticking()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user