Home >Backend Development >Golang >Detailed explanation of how goLang develops windows window interface

Detailed explanation of how goLang develops windows window interface

藏色散人
藏色散人forward
2021-07-26 15:17:067638browse

I looked for it today. Found something on a walk. Needless to say, get this pack before downloading it

go get github.com/lxn/walk

After getting it, I visited the github page and looked at the author's instructions

Walk is a project written for GolangThe Window Application Library Suite, which is mainly used for desktop GUI development, but there is also much more.

There is another example.

package main

import (
	"strings"

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

func main() {
	var inTE, outTE *walk.TextEdit

	MainWindow{
		Title:   "xiaochuan测试",
		MinSize: Size{600, 400},
		Layout:  VBox{},
		Children: []Widget{
			HSplitter{
				Children: []Widget{
					TextEdit{AssignTo: &inTE, MaxLength: 10},
					TextEdit{AssignTo: &outTE, ReadOnly: true},
				},
			},
			PushButton{
				Text: "SCREAM",
				OnClicked: func() {
					outTE.SetText(strings.ToUpper(inTE.Text()))
				},
			},
		},
	}.Run()
}

You must try this for yourself. After writing the code, buIid

go build -ldflags="-H windowsgui"

generated a test.exe file. Opened it. There was no reaction at all. Looked carefully again. It turns out that I overlooked one thing

I also need a pack of rsrc

go get github.com/akavel/rsrc

After getting it, I visited the github page and looked at the author's instructions

for use in the program Tools for embedding binary resources in

How to use this. Run go install and then the rsrc command. hard to use. It is estimated that there is no such rsrc.exe under go bin. There is no way to manually build copy. In the past,

cd %GOPATH%/src/github.com/akavel/rsrc
go build


, you can see that an rsrc.exe is generated under the rsrc directory. It must be this ghost. Copy it to GOROOT/bin. . Run

ok install is complete. How to play next. Continue to see what the author writes

He needs to create a test.manifest file and write

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
        <assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="SomeFunkyNameHere" type="win32"/>
        <dependency>
            <dependentAssembly>
                <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
            </dependentAssembly>
        </dependency>
    </assembly>

and then run

rsrc -manifest test.manifest -o rsrc.syso

Then run the one just now

go build -ldflags="-H windowsgui"

Double-click test.exe. ok ran successfully

For more golang related technical articles, please visit the golang tutorial column!

The above is the detailed content of Detailed explanation of how goLang develops windows window interface. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete