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

HOWTO? grid layout with different size columns #737

Closed
rfay opened this issue Mar 10, 2020 · 18 comments
Closed

HOWTO? grid layout with different size columns #737

rfay opened this issue Mar 10, 2020 · 18 comments

Comments

@rfay
Copy link

rfay commented Mar 10, 2020

Describe the bug:

I've been trying to make a simple grid of labels that has appropriately sized columns based on the text in the label widgets in the columns, and I just fail to do it. It seems that all the columns are always set to the same size. I've tried a GridLayoutWithRows of a GridLayoutWithColumns and several other things. Even though the MinSize() of the column is correctly calculated, when you push it into

To Reproduce:

Here's a snippet of one of many approaches I've tried. With every single approach I end up with identical column widths: https://gist.github.com/rfay/85aeb42ba7175f331639a259885a6e4d

Screenshots:

DDEV-Local

Example code:

Snippet: https://gist.github.com/rfay/85aeb42ba7175f331639a259885a6e4d

Device (please complete the following information):

  • OS: macOS
  • Version: Catalina
  • Go version: 1.14
  • Fyne version: 1.2.3
@andydotxyz
Copy link
Member

Yes, that is correct, our grid layout is a uniform grid. I guess you are looking for a table widget, which we have not yet created. The plan is that it would be built on top of the data binding API we are adding in release 1.3. There are some workarounds posted where people have used combined layouts to create the effect. Like #157?

@rfay
Copy link
Author

rfay commented Mar 10, 2020

Wow, talk about responsiveness. Thanks!

@rfay
Copy link
Author

rfay commented Mar 10, 2020

I note that #157 doesn't help at all though, columns are still the max of any cell:

Hello_and_rfay_t3v9composer-web___etc_cron_d

@andydotxyz
Copy link
Member

andydotxyz commented Mar 10, 2020

Goodness you are quite right - I never ran the code that was contributed ;)
I updated it by removing the grid layout and get the following result:
Screenshot from 2020-03-10 21-11-28

(Full code attached to #157)

@andydotxyz
Copy link
Member

It should be noted that this only work as long as all of your cells have the same height, otherwise alignment goes off

@rfay
Copy link
Author

rfay commented Mar 10, 2020

Would you mind gist-ing your solution? return widget.NewVBox(objects...) definitely doesn't get the result you show here.

Also, to use that code I had to download and manually install v3.2/glfw in vendor per icexin/gocraft#8 (comment)

@andydotxyz
Copy link
Member

andydotxyz commented Mar 10, 2020

Did you copy and paste my updated code? There is no instance of “NewVBox(objects...)” in what I pasted (it’s HBox).

@andydotxyz
Copy link
Member

If you are performing your own vendoring then yes that is an issue - we have introduced a new “fyne vendor” command that solves this for you - I haven’t mentioned it on the website yet but you could try it out if you have the latest version of the ‘fyne’ command.

@rfay
Copy link
Author

rfay commented Mar 10, 2020

You didn't mention that you had updated #157 (comment) :) so no, I didn't... (and thanks!)

Requiring fyne vendor sure sounds like a suspicious hack, sad to say. But I'll sure try it.

@andydotxyz
Copy link
Member

Apologies, I was working on 3 issues concurrently ;).

Fyne vendor may feel like a hack but unfortunately it’s due to the design of go vendor, as the missing directory contains no go code... if you have a better solution we would be glad :)

@rfay
Copy link
Author

rfay commented Mar 10, 2020

I note that installing "fyne" requires go get fyne.io/fyne/cmd/fyne, which I also don't think is mentioned anywhere.

@rfay
Copy link
Author

rfay commented Mar 10, 2020

And unfortunately...

 ~/go/bin/fyne vendor
Unsupported command vendor

Thanks so much for your amazing and prompt help.

@andydotxyz
Copy link
Member

It’s not mentioned everywhere but I think the first place mentioning the command should cover it https://tour.fyne.io/introduction/packaging.html.
Or there is a more complete developer page https://fyne.io/develop/distribution.html

@andydotxyz
Copy link
Member

Apologies, the vendor subcommand is currently in testing so you’d need to build it from the develop branch. (Now that I think about it that’s probably why it’s not documented anywhere yet ;) ).

@rfay
Copy link
Author

rfay commented Mar 10, 2020

git clone github.com/fyne-io/fyne
cd fyne
git checkout origin/develop
go install ./cmd/fyne
cd <myproject>
~/go/bin/fyne vendor

@rfay
Copy link
Author

rfay commented Mar 10, 2020

And I confirm that #157 (comment) does what I'm after... Now to adapt! Thanks!

@andydotxyz
Copy link
Member

Great, thanks for letting us know. Can we close this as a duplicate of that ticket do you think?

@rfay
Copy link
Author

rfay commented Mar 10, 2020

Well, people will stumble on the vendor problem, but yes. Closing as duplicate of #157 now that #157 (comment) does what's needed. I'll move discussion of fyne vendor over there.

@rfay rfay closed this as completed Mar 10, 2020
@rfay rfay mentioned this issue Mar 11, 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