Detailed explanation of how goLang develops windows window interface

藏色散人
Release: 2021-07-26 15:17:51
forward
7590 people have browsed it

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
Copy after login

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()
}
Copy after login

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

go build -ldflags="-H windowsgui"
Copy after login

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
Copy after login

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
Copy after login


, 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>
Copy after login

and then run

rsrc -manifest test.manifest -o rsrc.syso

Then run the one just now

go build -ldflags="-H windowsgui"
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template