-
Notifications
You must be signed in to change notification settings - Fork 3
/
gui.go
55 lines (50 loc) · 1.26 KB
/
gui.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"fmt"
"path/filepath"
"github.com/andlabs/ui"
_ "github.com/andlabs/ui/winmanifest"
)
// SimpleGui - using if main program run without arguments
func SimpleGui() {
err := ui.Main(func() {
packMsg := fmt.Sprintf("Pack: select any file in source dir")
unpackMsg := fmt.Sprintf("Unpack: select source file")
btnPack := ui.NewButton(packMsg)
btnUnpack := ui.NewButton(unpackMsg)
box := ui.NewHorizontalBox()
box.Append(btnPack, true)
box.Append(btnUnpack, true)
window := ui.NewWindow(currentTitle, 300, 100, false)
window.SetMargined(true)
window.SetChild(box)
btnPack.OnClicked(func(*ui.Button) {
packMode = true
wSelectFile := ui.NewWindow("select dir", 300, 100, false)
inputName = ui.OpenFile(wSelectFile)
if inputName != "" {
absPath, _ := filepath.Abs(inputName)
inputName = filepath.Dir(absPath) + separator
checkOutput()
ui.Quit()
}
})
btnUnpack.OnClicked(func(*ui.Button) {
unpackMode = true
wSelectFile := ui.NewWindow("select file", 300, 100, false)
inputName = ui.OpenFile(wSelectFile)
if inputName != "" {
checkOutput()
ui.Quit()
}
})
window.OnClosing(func(*ui.Window) bool {
ui.Quit()
return true
})
window.Show()
})
if err != nil {
panic(err)
}
}