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 运筹学排序问题中的在线排序
  • ¥15 关于#flink#的问题:关于docker部署flink集成hadoop的yarn,请教个问题flink启动yarn-session.sh连不上hadoop
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题