umfangreicheres Beispiel
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os/exec"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
@@ -19,13 +22,21 @@ type PWSetup struct {
|
||||
|
||||
var pwsetup PWSetup
|
||||
|
||||
func pwset() (*string, error) {
|
||||
cmd := exec.Command("ls -l")
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
res := (string(output))
|
||||
return &res, err
|
||||
}
|
||||
|
||||
func main() {
|
||||
app := tview.NewApplication()
|
||||
pages := tview.NewPages()
|
||||
|
||||
text := tview.NewTextView().
|
||||
SetTextColor(tcell.ColorGreen).
|
||||
SetText("Samplerate: " + pwsetup.samplerate)
|
||||
text := tview.NewTextArea()
|
||||
|
||||
form := tview.NewForm().
|
||||
AddDropDown("SampleRate: ", []string{"44100", "48000", "96000"}, 0, func(option string, index int) {
|
||||
@@ -36,7 +47,13 @@ func main() {
|
||||
}).
|
||||
AddTextView("Notes", "Set sample rate and buffersize for Pipewire", 40, 2, true, false).
|
||||
AddButton("Set", func() {
|
||||
text.SetText("SampleRate: " + pwsetup.samplerate)
|
||||
_, err := pwset()
|
||||
if err != nil {
|
||||
text.SetText("ok", true)
|
||||
} else {
|
||||
text.SetText("Fehler", true)
|
||||
}
|
||||
//text.SetText("Hallo Welt", true)
|
||||
pages.SwitchToPage("result")
|
||||
}).
|
||||
AddButton("Quit", func() {
|
||||
@@ -44,7 +61,10 @@ func main() {
|
||||
})
|
||||
|
||||
form.SetBorder(true).SetTitle(" Pipewire setup ").SetTitleAlign(tview.AlignLeft)
|
||||
form.SetFieldBackgroundColor(tcell.ColorDarkBlue)
|
||||
form.SetFieldTextColor(tcell.ColorAntiqueWhite)
|
||||
|
||||
form.SetButtonBackgroundColor(tcell.ColorDarkBlue)
|
||||
pages.AddPage("pwsetup", form, true, true)
|
||||
pages.AddPage("result", text, true, false)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user