
界面左侧一个ListBox,右侧一个TextEdit。
ListBox展示的是通过os.Environ()获取的系统环境变量,获取的是 key=val的[]string
单击击ListBox的时候在右侧显示val
func (mw *MyMainWindow) lb_CurrentIndexChanged() {
i := mw.lb.CurrentIndex()
item := &mw.model.items[i]
mw.te.SetText(item.value)
fmt.Println("CurrentIndex: ", i)
fmt.Println("CurrentEnvVarName: ", item.name)
}
双击的时候弹出MsgBox
func (mw *MyMainWindow) lb_ItemActivated() {
value := mw.model.items[mw.lb.CurrentIndex()].value
walk.MsgBox(mw, "Value", value, walk.MsgBoxIconInformation)
}
listbox.go
// 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 (
"fmt"
"

这是一个使用Go语言和Walk库构建的GUI应用程序,展示了如何获取并显示系统环境变量。用户可以通过单击ListBox查看环境变量的值,在TextEdit中显示,双击则会弹出一个消息框显示所选环境变量的值。该程序实现了环境变量的列表展示和交互功能。
最低0.47元/天 解锁文章
5016

被折叠的 条评论
为什么被折叠?



