Golang GUI Basics 1--JSON formatting widgets

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

What's wasting today is tomorrow to those who died yesterday; What's the future of hate now?

What you are wasting today is the tomorrow that the man who died yesterday expects, and what you dislike is now the future you will never go back to.

I started Golang GUI, just want to do some small tools for daily use, because the love of Golang has reached the point of intoxicated.

Start today's Lxn/walk exercise:

package mainimport ("encoding/json""github.com/lxn/walk". "github.com/lxn/walk/declarative")func main() {var inTE, outTE *walk.TextEditMainWindow{Title:   "格式化工具",MinSize: Size{600, 400},Layout:  VBox{},Children: []Widget{HSplitter{Children: []Widget{TextEdit{AssignTo: &inTE},TextEdit{AssignTo: &outTE, ReadOnly: true},},},PushButton{Text: "格式化",MinSize:Size{150, 36},OnClicked: func() {var jsonStr interface{}err := json.Unmarshal([]byte(inTE.Text()), &jsonStr)jsonStr, _ = json.MarshalIndent(jsonStr, "\r\n", "\t")if err != nil {                        // 暂时未找到设置颜色值//outTE.SetTextColor(walk.Color(32))outTE.SetText("数据格式不正确")} else {outTE.SetText(string(jsonStr.([]uint8)))}},},},}.Run()}

This case is tested on Windows 10.

Run first use the RSRC tool to compile the load manifest file, then build the executable file

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.