main.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. package main
  2. import (
  3. "github.com/epiclabs-io/winman"
  4. "github.com/rivo/tview"
  5. )
  6. func main() {
  7. app := tview.NewApplication()
  8. wm := winman.NewWindowManager()
  9. content := tview.NewTextView().
  10. SetText("Привет, мир!"). // set content of the text view
  11. SetTextAlign(tview.AlignCenter) // align text to the center of the text view
  12. window := wm.NewWindow(). // create new window and add it to the window manager
  13. Show(). // make window visible
  14. SetRoot(content). // have the text view above be the content of the window
  15. SetDraggable(true). // make window draggable around the screen
  16. SetResizable(true). // make the window resizable
  17. SetTitle("[ WarTank ]"). // set the window title
  18. AddButton(&winman.Button{ // create a button with an X to close the application
  19. Symbol: 'X',
  20. OnClick: func() { app.Stop() }, // close the application
  21. })
  22. window.SetRect(5, 5, 30, 10) // place the window
  23. // now, execute the application:
  24. if err := app.SetRoot(wm, true).EnableMouse(true).Run(); err != nil {
  25. panic(err)
  26. }
  27. }