This repository was archived by the owner on Nov 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.go
More file actions
51 lines (43 loc) · 1.2 KB
/
plot.go
File metadata and controls
51 lines (43 loc) · 1.2 KB
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
package main
import (
"image/color"
"time"
"fyne.io/fyne"
"fyne.io/fyne/app"
"fyne.io/fyne/canvas"
"fyne.io/fyne/driver/desktop"
"fyne.io/fyne/layout"
"fyne.io/fyne/widget"
)
func errorSplashScreen(message string) {
drv := fyne.CurrentApp().Driver()
if drv, ok := drv.(desktop.Driver); ok {
w := drv.CreateSplashWindow()
w.SetContent(widget.NewLabelWithStyle(message,
fyne.TextAlignCenter, fyne.TextStyle{Bold: true}))
w.Show()
go func() {
time.Sleep(time.Second * 2)
w.Close()
}()
}
}
func onPlotButtonPressed() {
errorSplashScreen("success!")
}
func onEnterPressed() {
errorSplashScreen("enter pressed!")
}
func main() {
a := app.NewWithID("plot")
w := a.NewWindow("plot")
w.Resize(fyne.NewSize(200, 300))
fEntry := NewCustomEntry(onEnterPressed)
fEntry.SetPlaceHolder("e.g. f(x)=2x+3")
fText := canvas.NewText("Enter Function: ", color.White)
menu := fyne.NewContainerWithLayout(layout.NewBorderLayout(nil, nil, fText, nil), fText, fEntry)
plotContent := NewPlotWindow()
plotButton := widget.NewButton("plot!", onPlotButtonPressed)
w.SetContent(fyne.NewContainerWithLayout(layout.NewBorderLayout(menu, plotButton, nil, nil), menu, plotContent, plotButton))
w.ShowAndRun()
}