The graphical interface of Go and gui--go language walk

Source: Internet
Author: User

Go does not have a native interface library, so it cannot be used to write GUI interfaces directly. But recently the internet has sprung up a lot of mature, useful third-party interface library. Using them, you can also write a C #, C + + interface. and more efficient.

About Walk Interface Library (official introduction):

Walk is a Windows Application Library suite for Golang, which is used primarily for desktop GUI development, but there are more things.

Part One : Installing Walk

Before you browse this section, make sure that you have configured the environment where the go language is installed. If not, you can refer to the install Help on the Go website. Also, note: This walk library can only run on Go 1.1.x and above.

To install walk is simple, just run the command:go get github.com/lxn/walk

Wait for the command to complete, this time check gopath src and pkg, whether there is a walk directory in accordance with their own computer environment. (The CPU architecture of my computer is AMD64, a walk folder and a compiled file A are present under%GOPATH%\WINDOWS_AMD64\GITHUB.COM\LXN, in addition to the%gopath%\src\github.com\ LXN will also appear under the Walk source code)

We also need to install a tool rsrc to complete the post-packaging work and execute the command:go get github.com/akavel/rsrc

    等待命令执行完成,然后检查,步骤与上文相仿,不再多说。

Part : Using Walk

Here does not tell the specific coding, open source projects can be understood by themselves, and the official also gave a lot of examples, can let you thoroughly understand the library. This section is mainly about compiling the Walk project.

This library is a bit more unique than the interface libraries in other languages. The EXE file it generates is only dependent on manifest for normal operation (in other GUI programs, this file is mostly used to generate XP styles). But go does not provide all the functions of the resource package (at least not found in my liteide), so to embed manifest EXE file, also need a tool: rsrc.

This tool has been successfully installed in the previous section. The purpose of this tool is to simply package some files in the Syso file, and the go compiler can embed the files in the exe file.

The command to embed manifest is simple:rsrc –manifest %manifestpath% –o % sysopath%

  比如我们要为test.exe打包一个manifest文件,只要这样做:rsrc -manifest test.manifest -o rsrc.syso

    执行完命令后,把rsrc文件移动到src下的项目目录,再执行编译命令。这时候,编译出来的exe就可以独立运行了。当然,如果你不喜欢这种方法,还可以把xxx.manifest文件改名为xxx.exe.manifest,程序同样能执行,但是发布时,必须要带着此文件一起发布。

    这个命令还有很多有趣的功能,如给exe文件加上自己喜欢的图标,命令为:rsrc-manifest Main.manifest–ico icon.ico-o rsrc.syso , followed by the same as in the previous article.

Appendix:

SYSO file on the Internet very little introduction, after my research on the source code and after the formation of PE view. Discover the Syso file is the go official for the "program Object Archive" of a thing, plainly, and win under the resource file similar. The PE viewer also shows that this is a resource file that is stored in the RSRC program segment.

The graphical interface of Go and gui--go language walk

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.