Updated Dynamic layout (markdown)

Jakub Sobon 2019-03-30 02:16:34 -04:00
parent e42e8e9ae0
commit 7230a596d3
1 changed files with 36 additions and 0 deletions

@ -26,4 +26,40 @@ The **Container.Update** method applies the specified options to a container wit
### Replacing widget in a container
The following code places a button widget inside a container and then updates the container by replacing the button with a Text widget:
```go
tb, err := termbox.New()
if err != nil {
panic(err)
}
defer tb.Close()
b, err := button.New("hello world", func() error {
return nil
},
)
if err != nil {
return fmt.Errorf("button.New => %v", err)
}
t, err := text.New()
if err != nil {
return fmt.Errorf("text.New => %v", err)
}
c, err := container.New(
t,
container.PlaceWidget(b),
container.ID("myID"),
)
if err != nil {
return fmt.Errorf("container.New => %v", err)
}
if err := c.Update("myID", container.PlaceWidget(t)); err != nil {
return fmt.Errorf("c.Update => %v", err)
}
```
### Changing the layout by specifying new splits