-
Notifications
You must be signed in to change notification settings - Fork 0
/
radiobutton.go
102 lines (96 loc) · 1.68 KB
/
radiobutton.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright 2013 The Walk Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
)
import (
. "github.com/lxn/walk/declarative"
)
type Foo struct {
Bar string
Baz int
}
func main() {
foo := &Foo{"b", 0}
MainWindow{
Title: "Walk RadioButton Example",
MinSize: Size{320, 240},
Layout: VBox{},
DataBinder: DataBinder{
DataSource: foo,
AutoSubmit: true,
OnSubmitted: func() {
fmt.Println(foo)
},
},
Children: []Widget{
// RadioButtonGroup is needed for data binding only.
RadioButtonGroup{
DataMember: "Bar",
Buttons: []RadioButton{
RadioButton{
Name: "aRB",
Text: "A",
Value: "a",
},
RadioButton{
Name: "bRB",
Text: "B",
Value: "b",
},
RadioButton{
Name: "cRB",
Text: "C",
Value: "c",
},
},
},
Label{
Text: "A",
Enabled: Bind("aRB.Checked"),
},
Label{
Text: "B",
Enabled: Bind("bRB.Checked"),
},
Label{
Text: "C",
Enabled: Bind("cRB.Checked"),
},
RadioButtonGroup{
DataMember: "Baz",
Buttons: []RadioButton{
RadioButton{
Name: "oneRB",
Text: "1",
Value: 1,
},
RadioButton{
Name: "twoRB",
Text: "2",
Value: 2,
},
RadioButton{
Name: "threeRB",
Text: "3",
Value: 3,
},
},
},
Label{
Text: "1",
Enabled: Bind("oneRB.Checked"),
},
Label{
Text: "2",
Enabled: Bind("twoRB.Checked"),
},
Label{
Text: "3",
Enabled: Bind("threeRB.Checked"),
},
},
}.Run()
}