adding icons
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 207 KiB |
|
After Width: | Height: | Size: 246 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 9.4 KiB |
|
After Width: | Height: | Size: 9.9 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
@@ -1,54 +1,138 @@
|
||||
import flet as ft
|
||||
import time
|
||||
|
||||
RON = 1
|
||||
RSTARTING = 2
|
||||
ROFF = 3
|
||||
RECEIVER_ON = 1
|
||||
RECEIVER_STARTING = 2
|
||||
RECEIVER_OFF = 3
|
||||
ICONSIZE = 30
|
||||
SOURCE_UNKNOWN = 0
|
||||
SOURCE_RADIO = 1
|
||||
SOURCE_TV = 2
|
||||
SOURCE_SPOTIFY = 3
|
||||
VOLUME_MIN = 0
|
||||
VOLUME_MAX = 60
|
||||
VOLUME_NICE = 30
|
||||
VOLUME_DELTA = 2
|
||||
RADIOS = ["1,NPO Radio 1,nps1.png",
|
||||
"2,NPO Radio 2,nps2.png",
|
||||
"3,NPO 3FM,nps3.png",
|
||||
"4,NPO Radio 4,nps4.png",
|
||||
"5,Sky Radio,sky.png",
|
||||
"6,Radio 538,538.png",
|
||||
"7,Qmusic,qmusic.png",
|
||||
"8,Arrow Classic Rock,arrow.png",
|
||||
"9,Sublime,sublime.png",
|
||||
"10,Classicnl,classicnl.png",
|
||||
"11,VRT Studio Brussel,vrtstudiobrussel.png",
|
||||
"12,VRT Radio 1,vrt1.png",
|
||||
"13,VRT Klara,klara.png",
|
||||
"14,Highway 65 Radio (US),highway65.png",
|
||||
"15,Concertzender (Utrecht),concertzender.png",
|
||||
"16,ANTENNE BAYERN Part Hita,antennebayernpartyhits.png",
|
||||
"17,Prysm Trance,prysm.png",
|
||||
"18,Beach Chill-Out Radio (Canada),beachchillout.png",
|
||||
"19,Frequence3,frequence3.png"]
|
||||
|
||||
|
||||
state_onoff = RECEIVER_OFF
|
||||
state_source = SOURCE_UNKNOWN
|
||||
state_volume = VOLUME_NICE
|
||||
|
||||
def main(page: ft.Page):
|
||||
radio_state = (RON, RSTARTING, ROFF)
|
||||
|
||||
|
||||
def onoff_changed(e):
|
||||
global state_onoff
|
||||
global state_volume
|
||||
global state_source
|
||||
if onoff.value == True:
|
||||
radio_state = RON
|
||||
block_topright.visible = False
|
||||
state_onoff = RECEIVER_ON
|
||||
block_control.visible = True
|
||||
set_volume(VOLUME_NICE)
|
||||
if onoff.value == False:
|
||||
radio_state = ROFF
|
||||
block_topright.visible = True
|
||||
state_onoff = RECEIVER_OFF
|
||||
block_control.visible = False
|
||||
state_source = SOURCE_UNKNOWN
|
||||
page.update()
|
||||
|
||||
def b1_clicked(e):
|
||||
global state_source
|
||||
i1.src = "images/tuner.png"
|
||||
i2.src = "images/spotify_bw.png"
|
||||
i3.src = "images/tv_bw.png"
|
||||
state_source = SOURCE_RADIO
|
||||
page.update()
|
||||
|
||||
def b2_clicked(e):
|
||||
global state_source
|
||||
i1.src = "images/tuner_bw.png"
|
||||
i2.src = "images/spotify.png"
|
||||
i3.src = "images/tv_bw.png"
|
||||
state_source = SOURCE_SPOTIFY
|
||||
page.update()
|
||||
|
||||
def b3_clicked(e):
|
||||
global state_source
|
||||
i1.src = "images/tuner_bw.png"
|
||||
i2.src = "images/spotify_bw.png"
|
||||
i3.src = "images/tv.png"
|
||||
state_source = SOURCE_TV
|
||||
page.update()
|
||||
|
||||
def set_volume(newvol):
|
||||
global state_volume
|
||||
if newvol>=VOLUME_MIN and newvol <= VOLUME_MAX:
|
||||
state_volume = newvol
|
||||
v2.value = newvol
|
||||
if newvol < 35:
|
||||
v2.active_color = ft.colors.GREEN
|
||||
elif newvol < 50:
|
||||
v2.active_color = ft.colors.AMBER
|
||||
else:
|
||||
v2.active_color = ft.colors.RED
|
||||
page.update()
|
||||
|
||||
def volume_changed(e):
|
||||
set_volume(e.control.value)
|
||||
|
||||
def volume_muted(e):
|
||||
set_volume(VOLUME_MIN)
|
||||
|
||||
def volume_upped(e):
|
||||
set_volume(state_volume + VOLUME_DELTA)
|
||||
|
||||
def volume_downed(e):
|
||||
set_volume(state_volume - VOLUME_DELTA)
|
||||
|
||||
page.theme_mode = ft.ThemeMode.DARK
|
||||
onoff = ft.Switch(on_change=onoff_changed)
|
||||
block_topleft = ft.Row([ft.Text("Off", size=30), onoff, ft.Text("On", size=30)])
|
||||
block_topright = ft.Row([ft.ProgressRing()])
|
||||
block_topright = ft.Row([ft.ProgressRing()], visible=False)
|
||||
block_top = ft.Row([block_topleft, block_topright], alignment=ft.MainAxisAlignment.SPACE_BETWEEN)
|
||||
page.add(block_top)
|
||||
|
||||
i1 = ft.Image(src="images/tuner_bw.png", width=100, height=100, fit=ft.ImageFit.CONTAIN)
|
||||
i2 = ft.Image(src="images/spotify_bw.png", width=100, height=100, fit=ft.ImageFit.CONTAIN)
|
||||
i3 = ft.Image(src="images/tv_bw.png", width=100, height=100, fit=ft.ImageFit.CONTAIN)
|
||||
b1 = ft.IconButton(content=i1, on_click=b1_clicked, padding=20)
|
||||
b2 = ft.IconButton(content=i2, on_click=b2_clicked, padding=20)
|
||||
b3 = ft.IconButton(content=i3, on_click=b3_clicked, padding=20)
|
||||
block_middle = ft.Row([b1, b2, b3], alignment=ft.MainAxisAlignment.CENTER, visible=True)
|
||||
|
||||
|
||||
v0 = ft.IconButton(icon=ft.Icons.VOLUME_MUTE, icon_size=ICONSIZE, on_click=volume_muted)
|
||||
v1 = ft.IconButton(icon=ft.Icons.VOLUME_DOWN, icon_size=ICONSIZE, on_click=volume_downed)
|
||||
v2 = ft.Slider(min=0, max=60, width=250, on_change=volume_changed)
|
||||
v3 = ft.IconButton(icon=ft.Icons.VOLUME_UP, icon_size=ICONSIZE, on_click=volume_upped)
|
||||
block_volume = ft.Row([v0, v1,v2,v3], alignment=ft.MainAxisAlignment.CENTER)
|
||||
block_control = ft.Container(content=ft.Column([block_middle, block_volume]))
|
||||
page.add(block_control)
|
||||
|
||||
|
||||
for r in RADIOS:
|
||||
(r_favnr, r_title, r_imagename) = r.split(",")
|
||||
|
||||
|
||||
|
||||
counter = ft.Text("0", size=50, data=0)
|
||||
|
||||
def increment_click(e):
|
||||
counter.data += 1
|
||||
counter.value = str(counter.data)
|
||||
counter.update()
|
||||
|
||||
floating_action_button1 = ft.FloatingActionButton(
|
||||
icon=ft.Icons.ADD, on_click=increment_click
|
||||
)
|
||||
floating_action_button2 = ft.FloatingActionButton(
|
||||
icon=ft.Icons.ADD, on_click=increment_click
|
||||
)
|
||||
page.title = "hello world"
|
||||
page.add(counter)
|
||||
page.add(floating_action_button1)
|
||||
page.add(floating_action_button2)
|
||||
t2 = ft.Text("-", size=40)
|
||||
page.add(t2)
|
||||
for i in range(10):
|
||||
t2.value = f"Step {i}"
|
||||
page.update()
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
ft.app(main)
|
||||
ft.app(main, assets_dir="assets")
|
||||
|
||||