1
1
import wx
2
2
from odmtools .view .WizardVariableView import WizardVariableView
3
3
from wx .wizard import WizardPageSimple
4
+ from odmtools .odmdata import Variable
4
5
5
6
6
7
class WizardVariableController (WizardPageSimple ):
7
- def __init__ (self , parent , service_manager ):
8
+ def __init__ (self , parent , service_manager , current_variable ):
8
9
WizardPageSimple .__init__ (self , parent )
9
10
10
11
self .service_manager = service_manager
12
+ self .current_variable = current_variable
11
13
main_sizer = wx .BoxSizer (wx .VERTICAL )
12
14
self .variable_view = WizardVariableView (self )
13
15
main_sizer .Add (self .variable_view , 1 , wx .EXPAND | wx .RIGHT , - 16 )
@@ -17,8 +19,35 @@ def __init__(self, parent, service_manager):
17
19
"Sample Medium" , "Value Type" , "IsRegular" , "Time Support" ,
18
20
"Time Units" , "DataType" , "Genaral Category" , "NoDataValue" , "ID" ]
19
21
self .variable_view .variable_table .set_columns (table_columns )
22
+ self .on_current_radio (None )
20
23
21
24
self .__fetch_data ()
25
+ self .variable_view .current_variable_radio .Bind (wx .EVT_RADIOBUTTON , self .on_current_radio )
26
+ self .variable_view .existing_variable_radio .Bind (wx .EVT_RADIOBUTTON , self .on_existing_radio )
27
+ self .variable_view .create_variable_radio .Bind (wx .EVT_RADIOBUTTON , self .on_create_radio )
28
+
29
+ def on_current_radio (self , event ):
30
+ self .variable_view .variable_table .Enable (False )
31
+ self .__set_create_variable_section (False )
32
+
33
+ def on_create_radio (self , event ):
34
+ self .variable_view .variable_table .Enable (False )
35
+ self .__set_create_variable_section (True )
36
+
37
+ def on_existing_radio (self , event ):
38
+ self .variable_view .variable_table .Enable (True )
39
+ self .__set_create_variable_section (False )
40
+
41
+ def __set_create_variable_section (self , active ):
42
+ if not isinstance (active , bool ):
43
+ raise Exception ("active must be type bool" )
44
+
45
+ self .variable_view .variable_code_text_ctrl .Enable (active )
46
+ self .variable_view .variable_name_combo .Enable (active )
47
+ self .variable_view .variable_type_combo .Enable (active )
48
+ self .variable_view .no_data_value_text_ctrl .Enable (active )
49
+ self .variable_view .speciation_combo .Enable (active )
50
+ self .variable_view .definition_text_ctrl .Enable (active )
22
51
23
52
def __fetch_data (self ):
24
53
self .__populate_variable_table ()
@@ -53,6 +82,21 @@ def __populate_variable_table(self):
53
82
54
83
self .variable_view .variable_table .set_table_content (data = data )
55
84
85
+ def get_variable (self ):
86
+ v = Variable ()
87
+ if self .variable_view .current_variable_radio .GetValue ():
88
+ v = self .current_variable
89
+ elif self .variable_view .existing_variable_radio .GetValue ():
90
+ row = self .variable_view .variable_table .get_selected_row ()
91
+ code = row [0 ]
92
+ v = self .service_manager .get_series_service ().get_variable_by_code (code )
93
+
94
+ elif self .variable_view .create_variable_radio .GetValue ():
95
+ # v = self.createdVar
96
+ pass
97
+
98
+ return v
99
+
56
100
57
101
58
102
0 commit comments