gizak / termui

Golang terminal dashboard
MIT License
13.14k stars 787 forks source link

Problem with animating the grid #105

Closed ghost closed 7 years ago

ghost commented 7 years ago

So... I've been trying to re-render the gird and I must admit the documentation isn't to clear about how one is supposed to do this (or even if he is supposed to do this at all).

Basically what I have is a simple grid created using:

ui.Body.AddRows(
    ui.NewRow(
        ui.NewCol(6, 0, ls0),
        ui.NewCol(6, 0, ls1),
    ),
)

(Where ls0 and ls1 are pointer to ui lists) And I'm trying to re-render it inside a handler

ui.Handle("/sys/kbd/e", func(ui.Event) {
     ///WHAT HERE ?

        ui.Body.Align()
    ui.Render(ui.Body)
  }

The previous answer here just flat out doesn't work for me, rudely informing me termui.Body is not a type: https://github.com/gizak/termui/issues/91

Is the body made to be re-rendered ? Would there be any chance of including some more concise examples of how ones is supposed to do this for the more dumb headed like myself.

I've tried various things, like making ui.Body point to a NewGrid (strange error that bugged out the terminal and turned the process zombie).

I've tried changing the widgets themselves (ls0 and ls1)

....Obviously I'm missing something here. Could any of you kind folks help me out ?

ghost commented 7 years ago

Ok, so what I ended up doing is accessing the slice of Rows contained within the Body manually as ui.Body.Rows and changing the Rows manually to "reinitialize them" as:

ui.Body.Rows[x] = ui.NewRow(....)

not sure if its the correct way to do it but it seems to work just fine. So I guess this can be closed. Still,I'd be nice if some more examples were added to the docs would be added for dummies like myself :/