gcla / gowid

Compositional widgets for terminal user interfaces, written in Go, inspired by urwid.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple examples

diamondburned opened this issue · comments

Hey. As a new TUI user hopping from tview, the lack of simple examples disturb me. Take a look at this:

https://github.com/gcla/gowid/blob/master/examples/gowid-menu/menu.go

A new person wouldn't for the life of them comprehend this. Comparing this 171 LOC example with tview's example:

package main

import "github.com/rivo/tview"

func main() {
	app := tview.NewApplication()
	dropdown := tview.NewDropDown().
		SetLabel("Select an option (hit Enter): ").
		SetOptions([]string{"First", "Second", "Third", "Fourth", "Fifth"}, nil)
	if err := app.SetRoot(dropdown, true).SetFocus(dropdown).Run(); err != nil {
		panic(err)
	}
}

You could see the obvious differences.

My recommendation: move the current examples to advanced/ and make a bare minimum simple/ example folder like Gtk.

Thanks for the feedback. Point taken about the menu example, and the lack of comments doesn't help...

One relatively simple example is probably the "hello world" one - https://github.com/gcla/gowid/blob/master/examples/gowid-helloworld/helloworld.go. Of course it doesn't do much. The others that follow the Tutorial document - gowid-tutorial* - are quite straightforward too.

That said, I understand your recommendation to make the starting-out points more prominent, I'll try to do that.

I would also like to add that I really like how tview has simple examples for each of its widgets.

I am also trying to learn gowid and am having trouble with the examples and documentation. It seems good at a more advanced level, but for a beginner it is really dense

Something I have noticed with the examples is that they either show you the bare minimum of constructing specific widgets or they go all out and implement an entire application. For instance with examples/gowid-widgets4 it shows how to construct lists (it also was very helpful for me to understand text and styling), but nothing about how to add functionality that might be useful in an application. Off the top of my head some things that might be good as expansions to examples around lists:

  • showing how to style unfocused list items that are selected (like termshark does)
  • implementing a tab box using a list as the controller
  • a column type tree (like finder)

Another thing that comes to mind is that it is unclear how focus works. What does focus mean for a widget (I did see this covered in the tutorial, but it could use its own section)? Is there a way to assign a widget focus programmatically? Does this apply to every widget or just some? What effect does focus have on selectable items? An example that could be helpful for this would be some editable boxes that you can tab between with styles applied to the one with focus

You have a clearly powerful library so the examples probably can't be that short. Still, it seems like there is a chance to make it easy to learn for new users that are willing to put in the time