【毕设日记】(3)go语言基于gopacket+fyne简单抓包工具实现之GUI

PkgList.go 渲染包的简要信息的list和对应的说明信息

package ui

import (
	"fmt"
	fyne2 "fyne.io/fyne/v2"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/data/binding"
	"fyne.io/fyne/v2/widget"
	//"time"
)
func loadPkgList(w fyne2.Window) (*fyne2.Container,binding.StringList) {
	pkgText:=[]string{
		"No.     ","Time                          ","Source              ","Dst                      ",
		"Protocol   ","Length     ","Info                                 ",
	}
	pkgTextContainer:=container.NewHBox()
	for _,v:=range pkgText{
		pkgTextContainer.Add(widget.NewButton(v, func() {

		}))
	}
	PkgStringList:=binding.NewStringList()

	PkgList:=widget.NewListWithData(PkgStringList,
		func() fyne2.CanvasObject {
			return widget.NewLabel("")
		},
		func(item binding.DataItem, object fyne2.CanvasObject) {
			i:=item.(binding.String)
			l:=object.(*widget.Label)
			s,_:=i.Get()
			l.SetText(s)
		})
	PkgList.OnSelected= func(id widget.ListItemID) {
		fmt.Println(id)

	}
	s:=widget.NewSeparator()
	PkgInfoContainer:=container.NewBorder(pkgTextContainer,nil,nil,s,PkgList)
	PkgInfoContainer.Resize(fyne2.NewSize(1600,280))
	return PkgInfoContainer,PkgStringList

}

效果:【毕设日记】(3)go语言基于gopacket+fyne简单抓包工具实现之GUI

上一篇:org.apache.ibatis.binding.BindingException


下一篇:WPF 基础 - Binding 的源与路径