Go GUI---lxn/walk 自带demo学习---7.文件浏览器

本文档展示了如何使用Walk库在Go语言中创建一个结合TreeView展示目录结构、TableView显示文件信息和WebView预览文件的文件浏览器应用。通过Directory结构体和自定义模型,实现了目录遍历和文件信息展示的动态交互。

如上图,从左到右用来TreeView、TableView、WebView

定义了一个名为Directory的目录结构体,每个目录理论上有一个父节点,有0到n个子节点。

type Directory struct {
	name     string
	parent   *Directory
	children []*Directory
}

 

 

filebrowser.go

// Copyright 2011 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"
	"os"
	"path/filepath"
	"time"
)

import (
	"github.com/lxn/walk"
	. "github.com/lxn/walk/declarative"
)

type Directory struct {
	name     string
	parent   *Directory
	children []*Directory
}

func NewDirectory(name string, parent *Directory) *Directory {
	return &Directory{name: name, parent: parent}
}

var _ walk.TreeItem = new(Directory)

func (d *Direct
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值