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

How to create widget in expanded form? #479

Closed
Kvaz1r opened this issue Oct 8, 2019 · 3 comments
Closed

How to create widget in expanded form? #479

Kvaz1r opened this issue Oct 8, 2019 · 3 comments

Comments

@Kvaz1r
Copy link
Contributor

Kvaz1r commented Oct 8, 2019

MCVE:

package main

import (
	"log"

	"fyne.io/fyne"
	"fyne.io/fyne/app"
	"fyne.io/fyne/widget"
)

func main() {

	app := app.New()
	w := app.NewWindow("MCVE")
	w.Resize(fyne.Size{800, 600})

	out := widget.NewEntry()
	out.SetText("Sample")

	BStart := widget.NewButton("Button", func() {
		log.Println("Clicked")
	})
	w.SetContent(widget.NewHBox(
		widget.NewVBox(
			widget.NewEntry(),
			BStart,
		),
		widget.NewScrollContainer(widget.NewVBox(
			out,
		))))
	w.ShowAndRun()
}

I want that out widget fill all available horizontal space. It's not clear for me how to do it from documentation or samples.

@andydotxyz
Copy link
Member

The VBox and HBox widgets are shrinking their contents - their layout stretches in one dimension (width for VBox and height for HBox) and shrinks to min on the other - this is how their contents are packed.
Remove the VBox from around "out" and it should work as expected

@Kvaz1r
Copy link
Contributor Author

Kvaz1r commented Oct 8, 2019

good to know, thanks. But which container should be used if need packed several widgets?

@andydotxyz
Copy link
Member

That depends on how you wish them to be laid out... Vbox and HBox are just helpers around fyne.NewContainerWithLayout - and so fyne.Container is the correct container, but you can apply various layouts (from the layout package).

MicahParks added a commit to MicahParks/xbright that referenced this issue Dec 1, 2020
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