Go Walk ListBox使用
2021/12/2 6:06:22
本文主要是介绍Go Walk ListBox使用,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
原始代码太长,不利于理解,精简一下
// Copyright 2012 The Walk Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "log" "github.com/lxn/walk" . "github.com/lxn/walk/declarative" ) func main() { mw := &MyMainWindow{model: NewEnvModel()} if _, err := (MainWindow{ AssignTo: &mw.MainWindow, Title: "Walk ListBox Example", MinSize: Size{240, 320}, Size: Size{300, 400}, Layout: VBox{MarginsZero: true}, Children: []Widget{ ListBox{ AssignTo: &mw.lb, Model: mw.model, }, }, }.Run()); err != nil { log.Fatal(err) } } type MyMainWindow struct { *walk.MainWindow model *EnvModel lb *walk.ListBox } type EnvItem struct { name string value string } type EnvModel struct { walk.ListModelBase items []EnvItem } func NewEnvModel() *EnvModel { m := &EnvModel{items: make([]EnvItem, 3)} m.items[0] = EnvItem{"name", "value"} m.items[1] = EnvItem{"name", "value"} m.items[2] = EnvItem{"name", "value"} return m } func (m *EnvModel) ItemCount() int { return len(m.items) } func (m *EnvModel) Value(index int) interface{} { return m.items[index].name }
EnvMode定义
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> <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> <asmv3:application> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true</dpiAware> </asmv3:windowsSettings> </asmv3:application> </assembly>
rsrc -manifest test.manifest -o rsrc.syso
go mod init test
go mod tidy
go build
运行
这篇关于Go Walk ListBox使用的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-24MongoDB资料:新手入门完全指南
- 2024-12-20go-zero 框架的 RPC 服务 启动start和停止 底层是怎么实现的?-icode9专业技术文章分享
- 2024-12-19Go-Zero 框架的 RPC 服务启动和停止的基本机制和过程是怎么实现的?-icode9专业技术文章分享
- 2024-12-18怎么在golang中使用gRPC测试mock数据?-icode9专业技术文章分享
- 2024-12-15掌握PageRank算法核心!你离Google优化高手只差一步!
- 2024-12-15GORM 中的标签 gorm:"index"是什么?-icode9专业技术文章分享
- 2024-12-11怎么在 Go 语言中获取 Open vSwitch (OVS) 的桥接信息(Bridge)?-icode9专业技术文章分享
- 2024-12-11怎么用Go 语言的库来与 Open vSwitch 进行交互?-icode9专业技术文章分享
- 2024-12-11怎么在 go-zero 项目中发送阿里云短信?-icode9专业技术文章分享
- 2024-12-11怎么使用阿里云 Go SDK (alibaba-cloud-sdk-go) 发送短信?-icode9专业技术文章分享