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 noe user function GUI elements."""
25
26
27 from os import sep
28 from string import split
29 import wx
30
31
32 from generic_fns import pipes
33
34
35 from base import UF_base, UF_page
36 from gui.paths import ANALYSIS_IMAGE_PATH
37 from gui.misc import gui_to_float, gui_to_int, gui_to_str, str_to_gui
38
39
40
42 """The container class for holding all GUI elements."""
43
50
51
58
59
60
62 """The noe.read_restraints() user function page."""
63
64
65 image_path = ANALYSIS_IMAGE_PATH + 'noe_200x200.png'
66 uf_path = ['noe', 'read_restraints']
67
68 - def add_contents(self, sizer):
69 """Add the page specific GUI elements.
70
71 @param sizer: A sizer object.
72 @type sizer: wx.Sizer instance
73 """
74
75
76 self.file = self.file_selection(sizer, "The restraint file:", message="Restraint file selection", style=wx.FD_OPEN, tooltip=self.uf._doc_args_dict['file'])
77
78
79 self.proton1_col = self.input_field(sizer, "The 1st proton column:", tooltip=self.uf._doc_args_dict['proton1_col'])
80 self.proton2_col = self.input_field(sizer, "The 2nd proton column:", tooltip=self.uf._doc_args_dict['proton2_col'])
81 self.lower_col = self.input_field(sizer, "The lower bound column:", tooltip=self.uf._doc_args_dict['lower_col'])
82 self.upper_col = self.input_field(sizer, "The upper bound column:", tooltip=self.uf._doc_args_dict['upper_col'])
83
84
85 self.sep = self.combo_box(sizer, "Column separator:", ["white space", ",", ";", ":", ""], read_only=False)
86
87
88 sizer.AddStretchSpacer()
89
90
91 - def on_execute(self):
92 """Execute the user function."""
93
94
95 file = gui_to_str(self.file.GetValue())
96
97
98 if not file:
99 return
100
101
102 proton1_col = gui_to_int(self.proton1_col.GetValue())
103 proton2_col = gui_to_int(self.proton2_col.GetValue())
104 lower_col = gui_to_int(self.lower_col.GetValue())
105 upper_col = gui_to_int(self.upper_col.GetValue())
106
107
108 sep = str(self.sep.GetValue())
109 if sep == 'white space':
110 sep = None
111
112
113 self.execute('noe.read_restraints', file=file, proton1_col=proton1_col, proton2_col=proton2_col, lower_col=lower_col, upper_col=upper_col, sep=sep)
114
115
116
117 -class Spectrum_type_page(UF_page):
118 """The noe.spectrum_type() user function page."""
119
120
121 image_path = ANALYSIS_IMAGE_PATH + 'noe_200x200.png'
122 uf_path = ['noe', 'spectrum_type']
123
124 - def add_contents(self, sizer):
125 """Add the page specific GUI elements.
126
127 @param sizer: A sizer object.
128 @type sizer: wx.Sizer instance
129 """
130
131
132 self.spectrum_type = self.combo_box(sizer, "The spectrum type:", tooltip=self.uf._doc_args_dict['spectrum_type'], choices=['Saturated spectrum', 'Reference spectrum'])
133 self.spectrum_type.SetClientData(0, 'sat')
134 self.spectrum_type.SetClientData(1, 'ref')
135
136
137 self.spectrum_id = self.combo_box(sizer, "The spectrum ID:", tooltip=self.uf._doc_args_dict['spectrum_id'])
138
139
140 sizer.AddStretchSpacer()
141
142
143 - def on_execute(self):
144 """Execute the user function."""
145
146
147 spectrum_type = gui_to_str(self.spectrum_type.GetClientData(self.spectrum_type.GetSelection()))
148
149
150 spectrum_id = gui_to_str(self.spectrum_id.GetValue())
151
152
153 self.execute('noe.spectrum_type', spectrum_type=spectrum_type, spectrum_id=spectrum_id)
154
155
156 - def on_display(self):
157 """Clear previous data and update the spectrum ID list."""
158
159
160 self.spectrum_id.Clear()
161
162
163 if not hasattr(cdp, 'spectrum_ids'):
164 return
165
166
167 for i in range(len(cdp.spectrum_ids)):
168 self.spectrum_id.Append(str_to_gui(cdp.spectrum_ids[i]))
169