-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgallery.go
39 lines (33 loc) · 904 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
39
package main
import (
"fmt"
"io/ioutil"
"log"
"strings"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
)
func showGalleryApp(w fyne.Window) {
root_src := "C:\\Users\\Skillzzzzzy\\Pictures"
files, err := ioutil.ReadDir(root_src)
if err != nil {
log.Fatal(err)
}
tabs := container.NewAppTabs()
for _, file := range files {
fmt.Println(file.Name(), file.IsDir())
if !file.IsDir() {
extension := strings.Split(file.Name(), ".")[1]
if extension == "png" || extension == "jpg" || extension == "jpeg" {
image := canvas.NewImageFromFile(root_src + "\\" + file.Name())
//image.FillMode = canvas.ImageFillContain
tabs.Append(container.NewTabItem(file.Name(), image))
}
}
}
tabs.SetTabLocation(container.TabLocationLeading)
w.SetContent(container.NewBorder(nil, panelContent, nil, nil, tabs))
w.Resize(fyne.NewSize(1280, 720))
w.Show()
}