walk
walk copied to clipboard
Unable to set MaxSize
I am working on a wallpaper tool. So far it works, but i cant seem to make it NON-RESIZABLE
The MaxSize
does nothing at all
package main
import (
"fmt"
"io/ioutil"
"strings"
"github.com/h2non/filetype"
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
"github.com/reujab/wallpaper"
)
var image string
//Main Process/window
func main() {
fmt.Println("Wallpaper v2.1")
var textEdit *walk.TextEdit
MainWindow{
Title: "Wallpaper Tool",
Size: Size{320, 240},
MinSize: Size{320, 240},
MaxSize: Size{320, 240},
Layout: VBox{},
// Listen for file being drag'n'dropped
OnDropFiles: func(files []string) {
textEdit.SetText(strings.Join(files, "\r\n"))
//set 'wallpaper' to the filepath of said image
image = strings.Join(files, "\r\n")
//check what type of file the provided file is
buf, err := ioutil.ReadFile(image)
if err != nil {
panic(err)
}
// See if file is a image
if filetype.IsImage(buf) {
textEdit.SetText(strings.Join(files, "\r\n"))
wallpaper.SetFromFile(image)
} else {
fmt.Println("The File is not a Image")
textEdit.SetText("The File is not a Image")
}
},
Children: []Widget{
TextEdit{
AssignTo: &textEdit,
ReadOnly: true,
Text: "Drag your desired wallpaper here.",
},
},
}.Run()
}
Sets the window size change event. Just set it to the size of the original window when the window changes. I've asked the author before that the maximize button can't be disabled.
Okay, how do i do that?
package main
import (
"fmt"
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
"github.com/lxn/win"
)
var (
window *walk.MainWindow
width int = 320
height int = 240
x int = 200
y int = 200
)
func main() {
fmt.Println("Wallpaper v2.1")
MainWindow{
Title: "Wallpaper Tool",
AssignTo: &window,
Layout: VBox{},
OnSizeChanged: func() {
window.SetWidth(width)
window.SetHeight(height)
window.SetX((int(win.GetSystemMetrics(0)) - width) / 2)
window.SetY((int(win.GetSystemMetrics(1)) - height) / 2)
},
}.Run()
}
@Merith-TK Can't you?
havent had the time to get to that, sorry, still busy with other things
Just was able to test it, it sorta works, however it still opens at the max size
@Merith-TK You mean even though you set MainWindow.Size it opens at full size ? I don't have that behaviour.
Did you just try copy/pase exactly of @HeyDon-Lee's example ? If so, you're missing the size attribute.