...

Source file src/github.com/rivo/tview/demos/form/main.go

Documentation: github.com/rivo/tview/demos/form

     1  // Demo code for the Form primitive.
     2  package main
     3  
     4  import (
     5  	"github.com/rivo/tview"
     6  )
     7  
     8  func main() {
     9  	app := tview.NewApplication()
    10  	form := tview.NewForm().
    11  		AddDropDown("Title", []string{"Mr.", "Ms.", "Mrs.", "Dr.", "Prof."}, 0, nil).
    12  		AddInputField("First name", "", 20, nil, nil).
    13  		AddInputField("Last name", "", 20, nil, nil).
    14  		AddTextArea("Address", "", 40, 0, 0, nil).
    15  		AddTextView("Notes", "This is just a demo.\nYou can enter whatever you wish.", 40, 2, true, false).
    16  		AddCheckbox("Age 18+", false, nil).
    17  		AddPasswordField("Password", "", 10, '*', nil).
    18  		AddButton("Save", nil).
    19  		AddButton("Quit", func() {
    20  			app.Stop()
    21  		})
    22  	form.SetBorder(true).SetTitle("Enter some data").SetTitleAlign(tview.AlignLeft)
    23  	if err := app.SetRoot(form, true).EnableMouse(true).Run(); err != nil {
    24  		panic(err)
    25  	}
    26  }
    27  

View as plain text