umfangreicheres Beispiel
This commit is contained in:
@@ -8,24 +8,47 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
type PWSetup struct {
|
||||
samplerate string
|
||||
buffersize string
|
||||
}
|
||||
|
||||
var pwsetup PWSetup
|
||||
|
||||
func main() {
|
||||
app := tview.NewApplication()
|
||||
|
||||
pages := tview.NewPages()
|
||||
|
||||
text := tview.NewTextView().
|
||||
SetTextColor(tcell.ColorGreen).
|
||||
SetText("Samplerate: " + pwsetup.samplerate)
|
||||
|
||||
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) {
|
||||
pwsetup.samplerate = option
|
||||
}).
|
||||
AddDropDown("Buffer : ", []string{"64", "128", "256", "512", "1024", "2048"}, 0, func(option string, index int) {
|
||||
pwsetup.buffersize = option
|
||||
}).
|
||||
AddDropDown("Buffer : ", []string{"64", "128", "256", "512", "1024", "2048"}, 0, nil).
|
||||
AddTextView("Notes", "Set sample rate and buffersize for Pipewire", 40, 2, true, false).
|
||||
AddButton("Set", nil).
|
||||
AddButton("Set", func() {
|
||||
text.SetText("SampleRate: " + pwsetup.samplerate)
|
||||
pages.SwitchToPage("result")
|
||||
}).
|
||||
AddButton("Quit", func() {
|
||||
app.Stop()
|
||||
})
|
||||
|
||||
form.SetBorder(true).SetTitle(" Pipewire setup ").SetTitleAlign(tview.AlignLeft)
|
||||
if err := app.SetRoot(form, true).EnableMouse(true).EnablePaste(true).Run(); err != nil {
|
||||
|
||||
pages.AddPage("pwsetup", form, true, true)
|
||||
pages.AddPage("result", text, true, false)
|
||||
|
||||
if err := app.SetRoot(pages, true).EnableMouse(true).EnablePaste(true).Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user