duanputian5341 2016-02-19 13:45
浏览 25
已采纳

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 2016-02-19 13:58
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?