Go語言實現的終端儀表板:termui
Go語言實現的終端儀表板。受blessed-contrib啟發,但純Go實現。
跨平臺,易于編譯和完全可定制。
示例:
安裝
go get github.com/gizak/termui
使用
Each component's layout is a bit like HTML block (box model), which has border and padding.
TheBorderproperty can be chosen to hide or display (with its border label), when it comes to display, the label takes 1 padding space (i.e. in css:padding: 1;, innerHeight and innerWidth therefore shrunk by 1).
import ui "github.com/gizak/termui" // <- ui shortcut, optional
func main() {
err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close()
p := ui.NewPar(":PRESS q TO QUIT DEMO")
p.Height = 3
p.Width = 50
p.TextFgColor = ui.ColorWhite
p.Border.Label = "Text Box"
p.Border.FgColor = ui.ColorCyan
g := ui.NewGauge()
g.Percent = 50
g.Width = 50
g.Height = 3
g.Y = 11
g.Border.Label = "Gauge"
g.BarColor = ui.ColorRed
g.Border.FgColor = ui.ColorWhite
g.Border.LabelFgColor = ui.ColorCyan
ui.Render(p, g)
// event handler...
}項目主頁:http://www.baiduhome.net/lib/view/home/1426163588342
本文由用戶 ew45 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!
