From 8aeef0a9b54991268b60d24f229266c47a716d1b Mon Sep 17 00:00:00 2001 From: death916 Date: Wed, 7 Jan 2026 05:07:01 -0800 Subject: [PATCH] adding play buttons --- utils/radio.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/utils/radio.py b/utils/radio.py index 201dd0d..8874f89 100644 --- a/utils/radio.py +++ b/utils/radio.py @@ -12,6 +12,7 @@ HARDWARE = True class Radio_UI: def __init__(self): + self.station = CURRENT_STATION if DEBUG: self.device = None else: @@ -20,6 +21,51 @@ class Radio_UI: def open_radio_button(self): return rx.button("Radio", on_click=self.open_radio_button) + def play_button(self): + if DEBUG: + return rx.button("Play") + else: + return rx.button("Play", on_click=self.device.play_radio) + + def stop_button(self): + if DEBUG: + return rx.button("Stop") + else: + return rx.button("Stop", on_click=self.device.stop_radio) + + def volume_slider(self): + if DEBUG: + return rx.slider( + min_=0, + max_=10, + step=1, + ) + else: + return rx.slider( + min_=0, + max_=10, + step=1, + value=self.device.volume, + on_change=self.device.set_volume, + ) + + def set_station(self, station): + self.station = station + + def station_input(self): + if DEBUG: + return rx.input( + placeholder="Enter station", + # set current station to input value + value=self.station, + on_change=self.set_station, + ) + else: + return rx.input( + placeholder="Enter station", + on_change=self.device.set_station, + ) + def radio_card(self): """ Radio Card @@ -32,11 +78,11 @@ class Radio_UI: rx.vstack( rx.heading("Current Station"), rx.text(CURRENT_STATION), - # rx.text("Volume"), - # rx.button("Play", on_click=self.device.play_radio), + rx.hstack( + self.play_button(), self.stop_button(), self.station_input() + ), + self.volume_slider(), ), - # rx.button("Pause"), - # rx.button("Stop"), ), )