umfangreicheres Beispiel
This commit is contained in:
@@ -8,6 +8,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
"os/exec"
|
||||||
|
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
@@ -19,13 +22,21 @@ type PWSetup struct {
|
|||||||
|
|
||||||
var pwsetup PWSetup
|
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() {
|
func main() {
|
||||||
app := tview.NewApplication()
|
app := tview.NewApplication()
|
||||||
pages := tview.NewPages()
|
pages := tview.NewPages()
|
||||||
|
|
||||||
text := tview.NewTextView().
|
text := tview.NewTextArea()
|
||||||
SetTextColor(tcell.ColorGreen).
|
|
||||||
SetText("Samplerate: " + pwsetup.samplerate)
|
|
||||||
|
|
||||||
form := tview.NewForm().
|
form := tview.NewForm().
|
||||||
AddDropDown("SampleRate: ", []string{"44100", "48000", "96000"}, 0, func(option string, index int) {
|
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).
|
AddTextView("Notes", "Set sample rate and buffersize for Pipewire", 40, 2, true, false).
|
||||||
AddButton("Set", func() {
|
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")
|
pages.SwitchToPage("result")
|
||||||
}).
|
}).
|
||||||
AddButton("Quit", func() {
|
AddButton("Quit", func() {
|
||||||
@@ -44,7 +61,10 @@ func main() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
form.SetBorder(true).SetTitle(" Pipewire setup ").SetTitleAlign(tview.AlignLeft)
|
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("pwsetup", form, true, true)
|
||||||
pages.AddPage("result", text, true, false)
|
pages.AddPage("result", text, true, false)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user