-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gallery.go
38 lines (34 loc) · 887 Bytes
/
Gallery.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"io/ioutil"
"log"
"strings"
)
func showGallery(w fyne.Window) {
root_src := "/mnt/data/Wallpapers"
files, err := ioutil.ReadDir(root_src)
if err != nil {
log.Fatal(err)
}
tabs := container.NewAppTabs()
for _, file := range files {
if file.IsDir() == false {
extension := strings.Split(file.Name(), ".")[1]
if extension == "png" || extension == "jpeg" || extension == "jpg" {
image := canvas.NewImageFromFile(root_src + "/" + file.Name())
image.FillMode = canvas.ImageFillContain
tabs.Append(container.NewTabItem(file.Name(), image))
}
}
}
tabs.SetTabLocation(container.TabLocationLeading)
GalleryContainer := tabs
w.SetContent(
container.NewBorder(PanelContent, nil, nil, nil, GalleryContainer),
)
w.Resize(fyne.NewSize(600, 600))
w.Show()
}