2021-12-21 17:13:55 +11:00
|
|
|
# tvxwidgets
|
2021-12-19 18:39:14 +11:00
|
|
|
|
2021-12-22 14:45:50 +11:00
|
|
|
|
|
|
|
[](https://pkg.go.dev/github.com/navidys/tvxwidgets)
|
2023-12-15 19:20:57 +11:00
|
|
|

|
2023-12-17 19:48:19 +11:00
|
|
|
[](https://codecov.io/gh/navidys/tvxwidgets)
|
2021-12-22 14:45:50 +11:00
|
|
|
[](https://goreportcard.com/report/github.com/navidys/tvxwidgets)
|
|
|
|
|
2022-12-17 12:41:00 +11:00
|
|
|
tvxwidgets provides extra widgets for [tview](https://github.com/rivo/tview).
|
2021-12-21 21:52:22 +11:00
|
|
|
|
2021-12-21 22:39:33 +11:00
|
|
|

|
2021-12-21 22:20:34 +11:00
|
|
|
|
2022-12-12 21:36:06 +11:00
|
|
|
## Widgets
|
|
|
|
|
|
|
|
* [bar chart](./demos/barchart/)
|
|
|
|
* [activity mode gauge](./demos/gauge_am/)
|
|
|
|
* [percentage mode gauge](./demos/gauge_pm/)
|
|
|
|
* [utilisation mode gauge](./demos/gauge_um/)
|
|
|
|
* [message dialog (info and error)](./demos/dialog/)
|
|
|
|
* [spinner](./demos/spinner/)
|
|
|
|
* [plot (linechart, scatter)](./demos/plot/)
|
2022-12-16 17:28:20 +11:00
|
|
|
* [sparkline](./demos/sparkline/)
|
2022-12-12 21:36:06 +11:00
|
|
|
|
|
|
|
|
2021-12-21 22:27:17 +11:00
|
|
|
## Example
|
2021-12-21 22:20:34 +11:00
|
|
|
|
2021-12-21 22:27:17 +11:00
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/gdamore/tcell/v2"
|
|
|
|
"github.com/navidys/tvxwidgets"
|
|
|
|
"github.com/rivo/tview"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := tview.NewApplication()
|
|
|
|
gauge := tvxwidgets.NewActivityModeGauge()
|
|
|
|
gauge.SetTitle("activity mode gauge")
|
|
|
|
gauge.SetPgBgColor(tcell.ColorOrange)
|
|
|
|
gauge.SetRect(10, 4, 50, 3)
|
|
|
|
gauge.SetBorder(true)
|
2021-12-22 14:45:50 +11:00
|
|
|
|
|
|
|
update := func() {
|
|
|
|
tick := time.NewTicker(500 * time.Millisecond)
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-tick.C:
|
|
|
|
gauge.Pulse()
|
|
|
|
app.Draw()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
go update()
|
|
|
|
|
2021-12-21 22:27:17 +11:00
|
|
|
if err := app.SetRoot(gauge, false).EnableMouse(true).Run(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
2021-12-22 14:45:50 +11:00
|
|
|
|
2021-12-21 22:27:17 +11:00
|
|
|
```
|