Package reflectometry :: Package model1d :: Package profileview :: Module saveModelDialog

Source Code for Module reflectometry.model1d.profileview.saveModelDialog

  1  import wx 
  2   
  3  # ---------------------------------------------------------------------- 
4 -class SaveModelDialog(wx.Dialog):
5 - def __init__( 6 self, 7 parent, 8 ID, 9 title, 10 size = (300, 200),#wx.DefaultSize, 11 pos = wx.DefaultPosition, 12 style = wx.DEFAULT_DIALOG_STYLE, 13 useMetal = False, 14 model = None 15 ):
16 self.parent = parent 17 self.model = model 18 # Instead of calling wx.Dialog.__init__ we precreate the dialog 19 # so we can set an extra style that must be set before 20 # creation, and then we create the GUI object using the Create method. 21 pre = wx.PreDialog() 22 pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) 23 pre.Create(parent, ID, title, pos, size, style) 24 25 # This next step is the most important, it turns this Python 26 # object into the real wrapper of the dialog (instead of pre) 27 # as far as the wxPython extension is concerned. 28 self.PostCreate(pre) 29 30 # This extra style can be set after the UI object has been created. 31 if 'wxMac' in wx.PlatformInfo and useMetal: 32 self.SetExtraStyle(wx.DIALOG_EX_METAL) 33 34 self._mgr = wx.aui.AuiManager(self) 35 36 self.txts=[r'Model Name', r'Data Sets', r'Output filename'] 37 38 self.DefaultTxts = [r'M1', # type 39 r'inline', # layer number, layer 0 is "Air" 40 r'test.py' 41 ] 42 43 for x in xrange( 3 ): 44 wx.StaticText(self, -1, self.txts[x], (20, 20+x*40)) 45 46 self.textCtrls = [] 47 48 for x in xrange(3): 49 textctl = wx.TextCtrl(self, 50 -1, 51 pos=(110, 20+x*40), 52 size=wx.Size(150, 20), 53 #style=wx.TE_MULTILINE|wx.TE_RICH|wx.TE_RICH2 54 ) 55 self.textCtrls.append( textctl ) 56 57 58 self._mgr.Update() 59 60 for x in xrange( 3 ): 61 self.textCtrls[x].SetValue( self.DefaultTxts[x] ) 62 63 64 self.button = wx.Button(self, 65 wx.ID_OK, 66 '', 67 (100, 135) 68 ) 69 self.cancelbutton = wx.Button(self, 70 wx.ID_CANCEL, 71 '', 72 (200, 135) 73 ) 74 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnClosePage) 75 self.Bind(wx.EVT_CLOSE, self.OnClose)
76 77 78
79 - def getOutPutInfo(self):
80 ret = [] 81 ret.append( self.getModelNameValue() ) 82 ret.append( self.getDataSetNameValue() ) 83 ret.append( self.getOutPutNameValue() ) 84 85 return ret
86 87
88 - def getModelNameValue(self):
89 ret = self.textCtrls[0].GetValue() 90 return ret
91 92
93 - def getDataSetNameValue(self):
94 return self.textCtrls[1].GetValue().strip()
95 96
97 - def getOutPutNameValue(self):
98 ret = self.textCtrls[2].GetValue() 99 return ret
100 101
102 - def GetOwnerManager(self):
103 return self._mgr
104 105
106 - def OnClose(self, event):
107 self._mgr.UnInit() 108 event.Skip()
109 110
111 - def OnClosePage(self, event):
112 event.Veto()
113 114 115 116 #==========================================================================
117 -class SaveModelDialog2(wx.Dialog):
118 - def __init__( 119 self, 120 parent, 121 ID, 122 title, 123 size = (300, 200),#wx.DefaultSize, 124 pos = wx.DefaultPosition, 125 style = wx.DEFAULT_DIALOG_STYLE, 126 useMetal = False, 127 model = None 128 ):
129 self.parent = parent 130 self.model = model 131 # Instead of calling wx.Dialog.__init__ we precreate the dialog 132 # so we can set an extra style that must be set before 133 # creation, and then we create the GUI object using the Create method. 134 pre = wx.PreDialog() 135 pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) 136 pre.Create(parent, ID, title, pos, size, style) 137 138 # This next step is the most important, it turns this Python 139 # object into the real wrapper of the dialog (instead of pre) 140 # as far as the wxPython extension is concerned. 141 self.PostCreate(pre) 142 143 # This extra style can be set after the UI object has been created. 144 if 'wxMac' in wx.PlatformInfo and useMetal: 145 self.SetExtraStyle(wx.DIALOG_EX_METAL) 146 147 self._mgr = wx.aui.AuiManager(self) 148 149 self.txts=[r'Model Name', r'Data Sets', r'Output filename'] 150 151 self.DefaultTxts = [r'M1', # type 152 r'du53.dat', # layer number, layer 0 is "Air" 153 r'test_du53.xml' 154 ] 155 156 for x in xrange( 3 ): 157 wx.StaticText(self, -1, self.txts[x], (20, 20+x*40)) 158 159 self.textCtrls = [] 160 161 for x in xrange(3): 162 textctl = wx.TextCtrl(self, 163 -1, 164 pos=(110, 20+x*40), 165 size=wx.Size(150, 20), 166 #style=wx.TE_MULTILINE|wx.TE_RICH|wx.TE_RICH2 167 ) 168 self.textCtrls.append( textctl ) 169 170 171 self._mgr.Update() 172 173 for x in xrange( 3 ): 174 self.textCtrls[x].SetValue( self.DefaultTxts[x] ) 175 176 177 self.button = wx.Button(self, wx.ID_OK,'',(100, 135)) 178 self.cancelbutton = wx.Button(self, 179 wx.ID_CANCEL, 180 '', 181 (200, 135) 182 ) 183 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnClosePage) 184 self.Bind(wx.EVT_CLOSE, self.OnClose)
185 186 187
188 - def getOutPutInfo(self):
189 ret = [] 190 ret.append( self.getModelNameValue() ) 191 ret.append( self.getDataSetNameValue() ) 192 ret.append( self.getOutPutNameValue() ) 193 194 return ret
195 196
197 - def getModelNameValue(self):
198 ret = self.textCtrls[0].GetValue() 199 return ret
200 201
202 - def getDataSetNameValue(self):
203 return self.textCtrls[1].GetValue().strip()
204 205
206 - def getOutPutNameValue(self):
207 ret = self.textCtrls[2].GetValue() 208 return ret
209 210
211 - def GetOwnerManager(self):
212 return self._mgr
213 214
215 - def OnClose(self, event):
216 self._mgr.UnInit() 217 event.Skip()
218 219
220 - def OnClosePage(self, event):
221 event.Veto()
222