1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """The relaxation data user function GUI elements."""
25
26
27 from string import split
28 import wx
29
30
31 from generic_fns import pipes
32
33
34 from base import UF_base, UF_page
35 from gui.paths import WIZARD_IMAGE_PATH
36 from gui.misc import gui_to_float, gui_to_int, gui_to_str, str_to_gui
37
38
39
41 """The container class for holding all GUI elements."""
42
44 """The relax_data.delete user function.
45
46 @keyword ri_id: The starting relaxation data ID string.
47 @type ri_id: str
48 """
49
50
51 wizard, page = self.create_wizard(size_x=700, size_y=400, name='relax_data.delete', uf_page=Delete_page, return_page=True)
52
53
54 if ri_id:
55 page.ri_id.SetValue(str_to_gui(ri_id))
56
57
58 wizard.run()
59
60
67
68
69
70 -class Delete_page(UF_page):
71 """The relax_data.read() user function page."""
72
73
74 image_path = WIZARD_IMAGE_PATH + 'fid.png'
75 uf_path = ['relax_data', 'delete']
76
77 - def add_contents(self, sizer):
78 """Add the relaxation data deletion specific GUI elements.
79
80 @param sizer: A sizer object.
81 @type sizer: wx.Sizer instance
82 """
83
84
85 self.ri_id = self.combo_box(sizer, "The relaxation data ID:", tooltip=self.uf._doc_args_dict['ri_id'])
86
87
88 - def on_execute(self):
89 """Execute the user function."""
90
91
92 ri_id = gui_to_str(self.ri_id.GetValue())
93
94
95 self.execute('relax_data.delete', ri_id=ri_id)
96
97
98 - def on_display(self):
99 """Clear previous data and update the label lists."""
100
101
102 self.ri_id.Clear()
103
104
105 if not hasattr(cdp, 'ri_ids'):
106 return
107
108
109 for i in range(len(cdp.ri_ids)):
110 self.ri_id.Append(str_to_gui(cdp.ri_ids[i]))
111
112
113
114 -class Read_page(UF_page):
115 """The relax_data.read() user function page."""
116
117
118 height_desc = 140
119 image_path = WIZARD_IMAGE_PATH + 'fid.png'
120 uf_path = ['relax_data', 'read']
121
122 - def add_contents(self, sizer):
123 """Add the relaxation data reading specific GUI elements.
124
125 @param sizer: A sizer object.
126 @type sizer: wx.Sizer instance
127 """
128
129
130 self.file = self.file_selection(sizer, "The relaxation data file:", message="Relaxation data file selection", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file'])
131
132
133 self.ri_id = self.input_field(sizer, "The relaxation data ID:", tooltip=self.uf._doc_args_dict['ri_id'])
134 self.ri_type = self.combo_box(sizer, "The relaxation data type:", choices=['R1', 'R2', 'NOE'], tooltip=self.uf._doc_args_dict['ri_type'])
135
136
137 self.frq = self.input_field(sizer, "The exact spectrometer frequency in Hz:", tooltip=self.uf._doc_args_dict['frq'])
138
139
140 self.spin_id = self.spin_id_element(sizer, desc="Restrict data loading to certain spins:")
141
142
143 self.free_file_format(sizer, data_cols=True, padding=3, spacer=0)
144
145
146 - def on_execute(self):
147 """Execute the user function."""
148
149
150 ri_id = gui_to_str(self.ri_id.GetValue())
151 ri_type = gui_to_str(self.ri_type.GetValue())
152 frq = gui_to_float(self.frq.GetValue())
153
154
155 file = gui_to_str(self.file.GetValue())
156
157
158 if not file:
159 return
160
161
162 spin_id_col = gui_to_int(self.spin_id_col.GetValue())
163 mol_name_col = gui_to_int(self.mol_name_col.GetValue())
164 res_num_col = gui_to_int(self.res_num_col.GetValue())
165 res_name_col = gui_to_int(self.res_name_col.GetValue())
166 spin_num_col = gui_to_int(self.spin_num_col.GetValue())
167 spin_name_col = gui_to_int(self.spin_name_col.GetValue())
168 data_col = gui_to_int(self.data_col.GetValue())
169 err_col = gui_to_int(self.err_col.GetValue())
170
171
172 sep = str(self.sep.GetValue())
173 if sep == 'white space':
174 sep = None
175
176
177 spin_id = gui_to_str(self.spin_id.GetValue())
178
179
180 self.execute('relax_data.read', ri_id=ri_id, ri_type=ri_type, frq=frq, file=file, spin_id_col=spin_id_col, mol_name_col=mol_name_col, res_num_col=res_num_col, res_name_col=res_name_col, spin_num_col=spin_num_col, spin_name_col=spin_name_col, data_col=data_col, error_col=err_col, sep=sep, spin_id=spin_id)
181