1 import wx
2 from reflutils import CheckValid
3 from reflectometry.model1d.model.bspline import BSpline, spline, slope, Slope
4 from reflectometry.model1d.model.tetheredPolymer import tetheredPolymer, TetheredPolymer, brush, Brush, BRUSH
5
6
7
9 - def __init__(
10 self,
11 parent,
12 ID,
13 title,
14 size = (300, 300),
15 pos = wx.DefaultPosition,
16 style = wx.DEFAULT_DIALOG_STYLE,
17 useMetal = False,
18 model = None
19 ):
20 self.parent = parent
21 self.model = model
22
23 pre = wx.PreDialog()
24 pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
25 pre.Create(parent, ID, title, pos, size, style)
26
27 self.PostCreate(pre)
28
29
30 if 'wxMac' in wx.PlatformInfo and useMetal:
31 self.SetExtraStyle(wx.DIALOG_EX_METAL)
32
33 self._mgr = wx.aui.AuiManager(self)
34
35 self.txts=[r'Layer name',
36 r'depth',
37 r'roughness',
38 r'Rho',
39 r'mu',
40 r'Phi',
41 r'Theta'
42 ]
43
44 self.DefaultTxts = [
45 r'None',
46 r'200',
47 r'5.0',
48 r'1.0',
49 r'0.0',
50 r'0',
51 r'0'
52 ]
53
54
55 if model.magnetic:
56 self.num = 7
57 else:
58 self.num = 5
59
60 for x in xrange( self.num ):
61 wx.StaticText(self, -1, self.txts[x], (10, 20+x*30))
62
63 self.textCtrls = []
64
65 for x in xrange( self.num ):
66 textctl = wx.TextCtrl(self,
67 -1,
68 pos=(80, 20+x*30),
69 size=wx.Size(400, 20)
70
71 )
72 self.textCtrls.append( textctl )
73
74
75 self._mgr.Update()
76
77 for x in xrange( self.num ):
78 self.textCtrls[x].SetValue( self.DefaultTxts[x] )
79
80 self.button = wx.Button(self,
81 wx.ID_OK,
82 '',
83 (200, 20+(self.num)*30)
84 )
85 self.cancelbutton = wx.Button(self,
86 wx.ID_CANCEL,
87 '',
88 (300, 20+(self.num)*30)
89 )
90
91 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnClosePage)
92 self.Bind(wx.EVT_CLOSE, self.OnClose)
93
94
95 self.layer_info=[]
96
97
98 self._error = 0
99
100
101
102
103
119
120
122 return self.textCtrls[0].GetValue().strip()
123
124
126 try:
127 ret = CheckValid( self.textCtrls[1].GetValue() )
128 except:
129 self._error = 1
130 ret = None
131
132 return ret
133
134
136 try:
137 ret = CheckValid( self.textCtrls[2].GetValue() )
138 except:
139 self._error = 1
140 ret = None
141 return ret
142
143
145 try:
146 ret = eval( self.textCtrls[3].GetValue().strip() )
147 except:
148 self._error = 1
149 ret = None
150
151 return ret
152
153
154
156 try:
157 ret = eval( self.textCtrls[4].GetValue().strip() )
158 except:
159 self._error = 1
160 ret = None
161
162 return ret
163
164
166 try:
167 ret = eval( self.textCtrls[5].GetValue().strip() )
168 except:
169 self._error = 1
170 ret = None
171
172 return ret
173
174
176 try:
177 ret = eval( self.textCtrls[6].GetValue().strip() )
178 except:
179 self._error = 1
180 ret = None
181
182 return ret
183
184
187
188
190 self._mgr.UnInit()
191 event.Skip()
192
193
194 - def OnClosePage(self, event):
196
197
198
199
200
201
203 - def __init__(
204 self,
205 parent,
206 ID,
207 title,
208 size = (300, 240),
209 pos = wx.DefaultPosition,
210 style = wx.DEFAULT_DIALOG_STYLE,
211 useMetal = False,
212 model = None
213 ):
214 self.parent = parent
215 self.model = model
216
217
218
219 pre = wx.PreDialog()
220 pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
221 pre.Create(parent, ID, title, pos, size, style)
222
223
224
225
226 self.PostCreate(pre)
227
228
229 if 'wxMac' in wx.PlatformInfo and useMetal:
230 self.SetExtraStyle(wx.DIALOG_EX_METAL)
231
232 self._mgr = wx.aui.AuiManager(self)
233
234 self.txts=[r'Type', r'Layer number', r'Layer name',
235 r'depth', r'roughness',
236 r'Rho', r'mu' ]
237
238 self.DefaultTxts = [r'Flat',
239 r'1',
240 r'None',
241 r'100',
242 r'5.0',
243 r'1.0',
244 r'1.0'
245 ]
246
247 self.LayerTypes = [r"Flat", r"Slope", r"Spline", r"Cosine"]
248
249 if model.magnetic:
250 self.num = 9
251 else:
252 self.num = 7
253
254 for x in xrange( self.num ):
255 wx.StaticText(self, -1, self.txts[x], (20, 20+x*30))
256
257 self.textCtrls = []
258
259 self.typeComboBox = wx.ComboBox(choices=self.LayerTypes,
260 id=-1,
261 name=u'typeComboBox',
262 parent=self,
263 pos=wx.Point(100, 20),
264 size=wx.Size(150, 20),
265 style= 0,
266 value=u'Flat'
267 )
268 self.typeComboBox.SetSelection(0)
269 self.Bind(wx.EVT_COMBOBOX, self.OnTypeCombobox, self.typeComboBox)
270
271
272
273 for x in xrange( self.num -1):
274 textctl = wx.TextCtrl(self,
275 -1,
276 pos=(100, 50+x*30),
277 size=wx.Size(150, 20)
278
279 )
280 self.textCtrls.append( textctl )
281
282
283 self._mgr.Update()
284
285 for x in xrange( self.num -1 ):
286 self.textCtrls[x].SetValue( self.DefaultTxts[x+1] )
287
288
289 self.button = wx.Button(self,
290 wx.ID_OK,
291 '',
292 (200, 20+(self.num)*30)
293 )
294 self.cancelbutton = wx.Button(self,
295 wx.ID_CANCEL,
296 '',
297 (300, 50+(self.num)*30)
298 )
299
300 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnClosePage)
301 self.Bind(wx.EVT_CLOSE, self.OnClose)
302
303
304 self.layer_info=[]
305
306
307 if _DEBUG < 5:
308 print self.typeComboBox.GetValue()
309
310
325
326
328 return self.typeComboBox.GetValue().strip()
329
330
335
337 return self.textCtrls[1].GetValue().strip()
338
339
343
344
348
352
356
360
364
365
368
369
371 self._mgr.UnInit()
372 event.Skip()
373
374
375 - def OnClosePage(self, event):
377
378
380 self.selection = self.typeComboBox.GetSelection()
381 self.typeComboBox.SetLabel( self.LayerTypes[self.selection] )
382 self.typeComboBox.SetValue( self.LayerTypes[self.selection] )
383
384
385 - def OnTypeComboboxText(self, event):
386 if self.selection < 0:
387 return
388 else:
389 txt = self.typeComboBox.GetValue()
390 self.typeComboBox.SetString(self.selection,txt)
391