2 Star 9 Fork 4

daniel2y / fynex

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
file.go 1.49 KB
一键复制 编辑 原始数据 按行查看 历史
daniel2y 提交于 2022-05-15 10:13 . zip and unzip
package component
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/storage"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
// bdFilePath := binding.NewString()
// filters:=[]string{".jpg",".jpeg",".png"}
// filters:=[]string{".zip",".rar",".tar"}
// openFile := NewOpenFile(bdFilePath,filters w)
func NewOpenFile(data binding.String, lbl string, filters []string,
w fyne.Window) *fyne.Container {
return container.NewBorder(nil, nil, widget.NewLabel(lbl),
widget.NewButtonWithIcon("", theme.FileIcon(), func() {
d := dialog.NewFileOpen(func(uc fyne.URIReadCloser, e error) {
if uc == nil {
return
}
data.Set(uc.URI().String()[7:])
}, w)
luri, _ := storage.ListerForURI(storage.NewFileURI("."))
d.SetFilter(storage.NewExtensionFileFilter(filters))
d.SetLocation(luri)
d.Show()
}),
widget.NewEntryWithData(data))
}
// bdFolderPath := binding.NewString()
// openFolder := NewOpenFolder(outData, w)
func NewOpenFolder(data binding.String, lbl string, w fyne.Window) *fyne.Container {
return container.NewBorder(nil, nil, widget.NewLabel(lbl),
widget.NewButtonWithIcon("",
theme.FolderOpenIcon(), func() {
d := dialog.NewFolderOpen(func(lu fyne.ListableURI, e error) {
if lu == nil {
return
}
data.Set(lu.Path())
}, w)
luri, _ := storage.ListerForURI(storage.NewFileURI("."))
d.SetLocation(luri)
d.Show()
}), widget.NewEntryWithData(data))
}
Go
1
https://gitee.com/y2h/fynex.git
git@gitee.com:y2h/fynex.git
y2h
fynex
fynex
bf1bca92af91

搜索帮助

53164aa7 5694891 3bd8fe86 5694891