lxn / walk

A Windows GUI toolkit for the Go Programming Language
Other
6.84k stars 884 forks source link

Extra white space in the toolbar and client area #633

Open tomatome opened 4 years ago

tomatome commented 4 years ago

After startup: image

Click Maximize and then Restore to the original window. The blank disappears: image

package main

import (
    "fmt"
    "os"

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

type MyMainWindow struct {
    main *walk.MainWindow
    sbi  *walk.StatusBarItem
}

var mw *MyMainWindow

func main() {
    mw = new(MyMainWindow)
    MW := MainWindow{
        AssignTo: &mw.main,
        Title:    "客户端",
        Icon:     "../goFtp/images/client.ico",
        MinSize:  Size{900, 600},
        MenuItems: []MenuItem{
            Menu{Text: "文件"},
            Menu{Text: "设置"},
        },
        ToolBar: ToolBar{
            ButtonStyle: ToolBarButtonImageBeforeText,
            Items: []MenuItem{
                Action{
                    Text:  "管理",
                    Image: "../goFtp/images/list.ico",
                },
                Action{
                    Text:  "上传",
                    Image: "../goFtp/images/upload.ico",
                },
                Action{
                    Text:  "下载",
                    Image: "../goFtp/images/down.ico",
                },
            },
        },
        Layout: VBox{SpacingZero: true},
        Children: []Widget{
            Composite{
                Layout: VBox{MarginsZero: true, SpacingZero: true},
                Children: []Widget{
                    TextEdit{},
                },
            },
        },
    }

    if _, err := MW.Run(); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}
lxn commented 4 years ago

There currently are some problems with ToolBar. Until they are fixed you can add your ToolBar to the list of Children of the MainWindow. Just be sure to wrap it on it's own in a Composite, or it will misbehave again.