GO GUI帮助(步行包)

GO GUI帮助(步行包)

问题描述:

I am making a GUI for my app, using package lxn/walk. I'm trying to figure out how to place elements by pixels. My code is like this:

package main

import (
    "github.com/lxn/walk"
    . "github.com/lxn/walk/declarative"
)

var edit *walk.Label

func main() {

    MainWindow{
        Title:   "FetchTest",
        MinSize: Size{600, 400},
        Layout:  VBox{},

        Children: []Widget{

            Label{
                AssignTo: &edit,
                Text:     "Hello",
            },

            PushButton{
                Text: "GET DATA",
                OnClicked: func() {

                },
            },
        },
    }.Run()

    edit.SetBounds(walk.Rectangle{10, 5, 50, 50})

}

But this doesn't work since the code that sets the position of label is not executing. Where to use edit.SetBounds(walk.Rectangle{10, 5, 50, 50} so the element is shown at the given coordinates?

I'm not familiar with walk, but maybe MainWindow.Run() only returns when the window is closed? You could try the approach used in the walk "filebrowser" example: call Create to set up the window, do any additional initialization, and then call Run.