Start initial phase

This commit is contained in:
2024-06-03 00:14:40 +02:00
commit 9676daac0a
7 changed files with 838 additions and 0 deletions
+72
View File
@@ -0,0 +1,72 @@
package main
import (
// "image/color"
"time"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
"fmt"
)
const (
refreshInterval = time.Second
windowWidth = 300
windowHeight = 400
)
func updateTime(clock *widget.Label) {
formatted := time.Now().Format("Time: 03:04:05")
clock.SetText(formatted)
}
func main() {
fmt.Println("Starting on GUI")
// Create a GUI app
a := app.New()
w := a.NewWindow("Radio Paradise Playing...")
w.Resize(fyne.NewSize(windowWidth, windowHeight))
// Get data from radioparadise and put in Label
url := "https://api.radioparadise.com/api/now_playing"
data, _ := readAPI(url)
str := printFormattedSong(&data)
rp := widget.NewLabel(str)
// Create clock running as Label
clock := widget.NewLabel("")
updateTime(clock)
go func() {
for range time.Tick(refreshInterval) {
updateTime(clock)
}
}()
// Quit button on container
quit := widget.NewButton("quit", func(){
a.Quit()
})
// Combine all Labels on container
content := container.NewVBox(
rp,
clock,
quit,
)
// Show content on window
w.SetContent(content)
w.Show()
//Run the app
a.Run()
tidyUp()
}
func tidyUp() {
fmt.Println("GUI app exited")
}