tvxwidgets/README.md

64 lines
1.5 KiB
Markdown
Raw Normal View History

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
[![PkgGoDev](https://pkg.go.dev/badge/github.com/navidys/tvxwidgets)](https://pkg.go.dev/github.com/navidys/tvxwidgets)
![Go](https://github.com/navidys/tvxwidgets/workflows/Go/badge.svg)
[![codecov](https://codecov.io/gh/navidys/tvxwidgets/branch/main/graph/badge.svg)](https://codecov.io/gh/navidys/tvxwidgets)
2021-12-22 14:45:50 +11:00
[![Go Report](https://img.shields.io/badge/go%20report-A%2B-brightgreen.svg)](https://goreportcard.com/report/github.com/navidys/tvxwidgets)
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
![Screenshot](demo.gif)
2021-12-21 22:20:34 +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/)
* [sparkline](./demos/sparkline/)
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
```