forked from tslocum/cview
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
845 B
40 lines
845 B
// Demo code for the TabbedPanels primitive. |
|
package main |
|
|
|
import ( |
|
"fmt" |
|
|
|
"code.rocketnine.space/tslocum/cview" |
|
) |
|
|
|
const panelCount = 5 |
|
|
|
func main() { |
|
app := cview.NewApplication() |
|
app.EnableMouse(true) |
|
|
|
panels := cview.NewTabbedPanels() |
|
for panel := 0; panel < panelCount; panel++ { |
|
func(panel int) { |
|
form := cview.NewForm() |
|
form.SetBorder(true) |
|
form.SetTitle(fmt.Sprintf("This is tab %d. Choose another tab.", panel+1)) |
|
form.AddButton("Next", func() { |
|
panels.SetCurrentTab(fmt.Sprintf("panel-%d", (panel+1)%panelCount)) |
|
}) |
|
form.AddButton("Quit", func() { |
|
app.Stop() |
|
}) |
|
form.SetCancelFunc(func() { |
|
app.Stop() |
|
}) |
|
|
|
panels.AddTab(fmt.Sprintf("panel-%d", panel), fmt.Sprintf("Panel #%d", panel), form) |
|
}(panel) |
|
} |
|
|
|
app.SetRoot(panels, true) |
|
if err := app.Run(); err != nil { |
|
panic(err) |
|
} |
|
}
|
|
|