From cb7b56c83aabc67601fc49759a000b8bb98f302b Mon Sep 17 00:00:00 2001 From: Sebastian Denz Date: Tue, 26 Jan 2021 00:24:23 +0100 Subject: [PATCH] [gui] first steps on playground ;) --- gui/.gitignore | 1 + gui/main.go | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 gui/.gitignore create mode 100644 gui/main.go diff --git a/gui/.gitignore b/gui/.gitignore new file mode 100644 index 0000000..b095bbf --- /dev/null +++ b/gui/.gitignore @@ -0,0 +1 @@ +gui diff --git a/gui/main.go b/gui/main.go new file mode 100644 index 0000000..a915c62 --- /dev/null +++ b/gui/main.go @@ -0,0 +1,71 @@ +package main + +import ( + "fmt" + "fyne.io/fyne/v2/app" + "fyne.io/fyne/v2/container" + "fyne.io/fyne/v2/widget" + "github.com/jnovack/flag" + log "github.com/sirupsen/logrus" + "os" +) + +var password string +var trx int +var trace bool +var uri string +var trxname string +var ant1 string +var ant2 string +var ant3 string + +func usage() { + fmt.Printf("Usage of %s:\n", os.Args[0]) + flag.PrintDefaults() +} + +func init() { + flag.StringVar(&password, "password", "", "your password") + flag.StringVar(&uri, "uri", "http://http-exporter", "uri to your http-exporter") + flag.IntVar(&trx, "trx", -1, "connected trx port on s.a.m.") + flag.BoolVar(&trace, "trace", false, "log almost everything") + flag.Parse() + if password == "" || uri == "" || trx == -1 { + usage() + os.Exit(1) + } + if trace { + log.SetLevel(log.TraceLevel) + log.Info("trace logging enabled") + } else { + log.Info("normal logging enabled") + } + + // FIXME + log.Info("[fake] getting name from s.a.m. server..") + trxname = "KX3" + ant1 = "HF-P1 40m" + ant2 = "GP 20/15/10m" + ant3 = "2m Eggbeater" +} + +func main() { + a := app.New() + w := a.NewWindow("Antenna Switcher") + + hello := widget.NewLabel("just started..") + w.SetContent(container.NewVBox( + hello, + widget.NewButton(ant1, func() { + hello.SetText(fmt.Sprintf("%s : %s", trxname, ant1)) + }), + widget.NewButton(ant2, func() { + hello.SetText(fmt.Sprintf("%s : %s", trxname, ant2)) + }), + widget.NewButton(ant3, func() { + hello.SetText(fmt.Sprintf("%s : %s", trxname, ant3)) + }), + )) + + w.ShowAndRun() +}