duanputian5341
duanputian5341
2016-02-19 13:45

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?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dtkwt62022 dtkwt62022 5年前

    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.

    点赞 评论 复制链接分享

为你推荐