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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
<?xml version="1.0"?>
<!--
###################################################
##Variable Chooser:
## a gui form with enumerated choices
## radio buttons, drop down, or button
###################################################
-->
<block>
<name>WX GUI Chooser</name>
<key>variable_chooser</key>
<category>WX GUI Widgets</category>
<import>from gnuradio.wxgui import forms</import>
<var_make>self.$(id) = $(id) = $value</var_make>
<make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
#set $win = 'self._%s_chooser'%$id
$win = forms.$(type)(
parent=$(parent).GetWin(),
value=self.$id,
callback=self.set_$(id),
#if $label()
label=$label,
#else
label='$id',
#end if
choices=$choices,
labels=$labels,
#if $type() == 'radio_buttons'
style=$style,
#end if
)
#if not $grid_pos()
$(parent).Add($win)
#else
$(parent).GridAdd($win, $(', '.join(map(str, $grid_pos()))))
#end if</make>
<callback>self.set_$(id)($value)</callback>
<callback>self._$(id)_chooser.set_value($id)</callback>
<param>
<name>Label</name>
<key>label</key>
<value></value>
<type>string</type>
<hide>#if $label() then 'none' else 'part'#</hide>
</param>
<param>
<name>Default Value</name>
<key>value</key>
<value>1</value>
<type>raw</type>
</param>
<param>
<name>Choices</name>
<key>choices</key>
<value>[1, 2, 3]</value>
<type>raw</type>
</param>
<param>
<name>Labels</name>
<key>labels</key>
<value>[]</value>
<type>raw</type>
</param>
<param>
<name>Type</name>
<key>type</key>
<value>drop_down</value>
<type>enum</type>
<option>
<name>Drop Down</name>
<key>drop_down</key>
</option>
<option>
<name>Radio Buttons</name>
<key>radio_buttons</key>
</option>
<option>
<name>Button</name>
<key>button</key>
</option>
</param>
<param>
<name>Style</name>
<key>style</key>
<value>wx.RA_HORIZONTAL</value>
<type>enum</type>
<hide>#if $type() == 'radio_buttons' then 'part' else 'all'#</hide>
<option>
<name>Horizontal</name>
<key>wx.RA_HORIZONTAL</key>
</option>
<option>
<name>Vertical</name>
<key>wx.RA_VERTICAL</key>
</option>
</param>
<param>
<name>Grid Position</name>
<key>grid_pos</key>
<value></value>
<type>grid_pos</type>
</param>
<param>
<name>Notebook</name>
<key>notebook</key>
<value></value>
<type>notebook</type>
</param>
<check>$value in $choices</check>
<check>not $labels or len($labels) == len($choices)</check>
<doc>
This block creates a variable with a drop down, radio buttons, or a button. \
Leave the label blank to use the variable id as the label. \
The value index is the index of a particular choice, \
which defines the default choice when the flow graph starts. \
The choices must be a list of possible values. \
Leave labels empty to use the choices as the labels.
Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
</doc>
</block>
|