Package reflectometry :: Package model1d :: Package profileview :: Module initModelDialog

Source Code for Module reflectometry.model1d.profileview.initModelDialog

  1  import wx 
  2  from   reflutils import CheckValid 
  3   
  4   
  5  # ----------------------------------------------------------------------- 
6 -class InitModelDialog(wx.Dialog):
7 - def __init__( 8 self, 9 parent, 10 ID, 11 title, 12 size = (300, 300),#wx.DefaultSize, 13 pos = wx.DefaultPosition, 14 style = wx.DEFAULT_DIALOG_STYLE, 15 useMetal = False, 16 ):
17 self.parent = parent 18 19 pre = wx.PreDialog() 20 pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) 21 pre.Create(parent, ID, title, pos, size, style) 22 23 self.PostCreate(pre) 24 25 # This extra style can be set after the UI object has been created. 26 if 'wxMac' in wx.PlatformInfo and useMetal: 27 self.SetExtraStyle(wx.DIALOG_EX_METAL) 28 29 self._mgr = wx.aui.AuiManager(self) 30 31 32 33 self.Txts = [r'Name', # layer name 34 r'rho', # rho 35 r'mu', # mu 36 r'phi', # phi 37 r'theta' # theta 38 ] 39 40 self.SubstrateTxts = [r'Si', # layer name 41 #r'5.0', # roghhness 42 r'2.07', # rho 43 r'0.0', # mu 44 r'0', # phi 45 r'0' # theta 46 ] 47 48 self.IncidentTxts = [r'Air', # layer name 49 #r'5.0', # roghhness 50 r'0.0', # rho 51 r'0.0', # mu 52 r'0', # phi 53 r'0' # theta 54 ] 55 56 for x in xrange(5): 57 wx.StaticText(self, -1, self.Txts[x], (25, 50+x*30)) 58 59 wx.StaticText(self, -1, "Incident", ( 70, 20) ) 60 wx.StaticText(self, -1, "Substrate", (180, 20) ) 61 62 63 self.textCtrls = [] 64 65 for x in xrange(5): 66 textctl = wx.TextCtrl(self, 67 -1, 68 pos=(70, 50+x*30), 69 size=wx.Size(90, 20) 70 #style=wx.TE_MULTILINE|wx.TE_RICH|wx.TE_RICH2 71 ) 72 self.textCtrls.append( textctl ) 73 74 75 self.textCtrls2 = [] 76 for x in xrange(5): 77 textctl = wx.TextCtrl(self, 78 -1, 79 pos=(180, 50+x*30), 80 size=wx.Size(90, 20) 81 # style=wx.TE_MULTILINE|wx.TE_RICH|wx.TE_RICH2 82 ) 83 self.textCtrls2.append( textctl ) 84 85 self._mgr.Update() 86 87 for x in xrange( 5 ): 88 self.textCtrls[x].SetValue( self.IncidentTxts[x] ) 89 90 for x in xrange( 5 ): 91 self.textCtrls2[x].SetValue( self.SubstrateTxts[x] ) 92 93 self.button = wx.Button(self, 94 wx.ID_OK, 95 '', 96 (100, 70+5*30) 97 ) 98 self.cancelbutton = wx.Button(self, 99 wx.ID_CANCEL, 100 '', 101 (200, 70+5*30) 102 ) 103 104 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnClosePage) 105 self.Bind(wx.EVT_CLOSE, self.OnClose) 106 107 # Layer Information 108 self.layer_info=[]
109 110 111 112 # --------------------------------------------------
113 - def getIncidentNameValue(self):
114 return self.textCtrls[0].GetValue().strip()
115
116 - def getSubstrateNameValue(self):
117 return self.textCtrls2[0].GetValue().strip()
118
119 - def getIncidentRhoValue(self):
120 ret = CheckValid( self.textCtrls[1].GetValue() ) 121 return ret
122
123 - def getSubstrateRhoValue(self):
124 ret = CheckValid( self.textCtrls2[1].GetValue() ) 125 return ret
126
127 - def getIncidentMuValue(self):
128 ret = CheckValid( self.textCtrls[2].GetValue() ) 129 return ret
130
131 - def getSubstrateMuValue(self):
132 ret = CheckValid( self.textCtrls2[2].GetValue() ) 133 return ret
134
135 - def getIncidentPhiValue(self):
136 ret = CheckValid( self.textCtrls[3].GetValue() ) 137 return ret
138
139 - def getSubstratePhiValue(self):
140 ret = CheckValid( self.textCtrls2[3].GetValue() ) 141 return ret
142
143 - def getIncidentThetaValue(self):
144 ret = CheckValid( self.textCtrls[4].GetValue() ) 145 return ret
146
147 - def getSubstrateThetaValue(self):
148 ret = CheckValid( self.textCtrls2[4].GetValue() ) 149 return ret
150 151
152 - def GetOwnerManager(self):
153 return self._mgr
154 155
156 - def OnClose(self, event):
157 self._mgr.UnInit() 158 event.Skip()
159 160
161 - def OnClosePage(self, event):
162 event.Veto()
163 164
165 - def getIncidentInfo(self):
166 ret = [] 167 ret.append( self.getIncidentNameValue() ) 168 ret.append( self.getIncidentRhoValue() ) 169 ret.append( self.getIncidentMuValue() ) 170 if 1: 171 ret.append( self.getIncidentPhiValue() ) 172 ret.append( self.getIncidentThetaValue() ) 173 174 return ret
175 176
177 - def getSubstrateInfo(self):
178 ret = [] 179 ret.append( self.getSubstrateNameValue() ) 180 ret.append( self.getSubstrateRhoValue() ) 181 ret.append( self.getSubstrateMuValue() ) 182 if 1: 183 ret.append( self.getSubstratePhiValue() ) 184 ret.append( self.getSubstrateThetaValue() ) 185 186 return ret
187 188 189 190 # ------------------------------------------------------------------- 191
192 -class InitModelDialogNM(wx.Dialog):
193 - def __init__( 194 self, 195 parent, 196 ID, 197 title, 198 size = (300, 240),#wx.DefaultSize, 199 pos = wx.DefaultPosition, 200 style = wx.DEFAULT_DIALOG_STYLE, 201 useMetal = False, 202 ):
203 self.parent = parent 204 205 pre = wx.PreDialog() 206 pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) 207 pre.Create(parent, ID, title, pos, size, style) 208 209 self.PostCreate(pre) 210 211 # This extra style can be set after the UI object has been created. 212 if 'wxMac' in wx.PlatformInfo and useMetal: 213 self.SetExtraStyle(wx.DIALOG_EX_METAL) 214 215 self._mgr = wx.aui.AuiManager(self) 216 217 218 219 self.Txts = [r'Name', # layer name 220 r'rho', # rho 221 r'mu' 222 ] 223 224 self.SubstrateTxts = [r'Si', # layer name 225 #r'5.0', # roghhness 226 r'2.07', # rho 227 r'0.0' 228 ] 229 230 self.IncidentTxts = [r'Air', # layer name 231 #r'5.0', # roghhness 232 r'0.0', # rho 233 r'0.0' 234 ] 235 236 for x in xrange(3): 237 wx.StaticText(self, -1, self.Txts[x], (25, 50+x*30)) 238 239 wx.StaticText(self, -1, "Incident", ( 70, 20) ) 240 wx.StaticText(self, -1, "Substrate", (180, 20) ) 241 242 243 self.textCtrls = [] 244 245 for x in xrange(3): 246 textctl = wx.TextCtrl(self, 247 -1, 248 pos=(70, 50+x*30), 249 size=wx.Size(90, 20) 250 #style=wx.TE_MULTILINE|wx.TE_RICH|wx.TE_RICH2 251 ) 252 self.textCtrls.append( textctl ) 253 254 255 self.textCtrls2 = [] 256 for x in xrange(3): 257 textctl = wx.TextCtrl(self, 258 -1, 259 pos=(180, 50+x*30), 260 size=wx.Size(90, 20) 261 #style=wx.TE_MULTILINE|wx.TE_RICH|wx.TE_RICH2 262 ) 263 self.textCtrls2.append( textctl ) 264 265 self._mgr.Update() 266 267 for x in xrange( 3 ): 268 self.textCtrls[x].SetValue( self.IncidentTxts[x] ) 269 270 for x in xrange( 3 ): 271 self.textCtrls2[x].SetValue( self.SubstrateTxts[x] ) 272 273 self.button = wx.Button(self, 274 wx.ID_OK, 275 '', 276 (100, 70+3*30) 277 ) 278 self.cancelbutton = wx.Button(self, 279 wx.ID_CANCEL, 280 '', 281 (200, 70+3*30) 282 ) 283 284 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnClosePage) 285 self.Bind(wx.EVT_CLOSE, self.OnClose) 286 287 # Layer Information 288 self.layer_info=[]
289 290
291 - def getIncidentNameValue(self):
292 return self.textCtrls[0].GetValue().strip()
293
294 - def getSubstrateNameValue(self):
295 return self.textCtrls2[0].GetValue().strip()
296
297 - def getIncidentRhoValue(self):
298 ret = CheckValid( self.textCtrls[1].GetValue() ) 299 return ret
300
301 - def getSubstrateRhoValue(self):
302 ret = CheckValid( self.textCtrls2[1].GetValue() ) 303 return ret
304
305 - def getIncidentMuValue(self):
306 ret = CheckValid( self.textCtrls[2].GetValue() ) 307 return ret
308
309 - def getSubstrateMuValue(self):
310 ret = CheckValid( self.textCtrls2[2].GetValue() ) 311 return ret
312 313
314 - def GetOwnerManager(self):
315 return self._mgr
316 317
318 - def OnClose(self, event):
319 self._mgr.UnInit() 320 event.Skip()
321 322
323 - def OnClosePage(self, event):
324 event.Veto()
325 326
327 - def getIncidentInfo(self):
328 ret = [] 329 ret.append( self.getIncidentNameValue() ) 330 ret.append( self.getIncidentRhoValue() ) 331 ret.append( self.getIncidentMuValue() ) 332 333 return ret
334 335
336 - def getSubstrateInfo(self):
337 ret = [] 338 ret.append( self.getSubstrateNameValue() ) 339 ret.append( self.getSubstrateRhoValue() ) 340 ret.append( self.getSubstrateMuValue() ) 341 342 return ret
343