-
Notifications
You must be signed in to change notification settings - Fork 59
/
main.go
42 lines (33 loc) · 911 Bytes
/
main.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
package main
import (
"time"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
xwidget "fyne.io/x/fyne/widget"
)
func main() {
a := app.New()
w := a.NewWindow("Calendar")
i := widget.NewLabel("Please Choose a Date")
i.Alignment = fyne.TextAlignCenter
l := widget.NewLabel("")
l.Alignment = fyne.TextAlignCenter
d := &date{instruction: i, dateChosen: l}
// Defines which date you would like the calendar to start
startingDate := time.Now()
calendar := xwidget.NewCalendar(startingDate, d.onSelected)
c := container.NewVBox(i, l, calendar)
w.SetContent(c)
w.ShowAndRun()
}
type date struct {
instruction *widget.Label
dateChosen *widget.Label
}
func (d *date) onSelected(t time.Time) {
// use time object to set text on label with given format
d.instruction.SetText("Date Selected:")
d.dateChosen.SetText(t.Format("Mon 02 Jan 2006"))
}