Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple examples #7

Open
diamondburned opened this issue May 19, 2019 · 3 comments
Open

Simple examples #7

diamondburned opened this issue May 19, 2019 · 3 comments

Comments

@diamondburned
Copy link

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.

@gcla
Copy link
Owner

gcla commented May 19, 2019

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.

@diamondburned
Copy link
Author

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

@ghost
Copy link

ghost commented Aug 18, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants