mirror of https://github.com/mum4k/termdash.git
Updated Dynamic layout (markdown)
parent
e42e8e9ae0
commit
7230a596d3
|
@ -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
|
Loading…
Reference in New Issue