Changeset 6d48919 in sasview for calculatorview/perspectives/calculator/aperture_editor.py
- Timestamp:
- Oct 5, 2010 9:38:03 AM (14 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 35aface
- Parents:
- ec1c554
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/perspectives/calculator/aperture_editor.py
r6137b150 r6d48919 19 19 20 20 class ApertureDialog(wx.Dialog): 21 def __init__(self, parent=None, manager=None, aperture=None, *args, **kwds):21 def __init__(self, parent=None, manager=None, aperture=None, *args, **kwds): 22 22 """ 23 23 Dialog allows to enter values for aperture 24 24 """ 25 kwds['size'] = (PANEL_WIDTH, PANEL_HEIGHT)25 kwds['size'] = (PANEL_WIDTH, PANEL_HEIGHT) 26 26 kwds['title'] = "Aperture Editor" 27 27 wx.Dialog.__init__(self, parent=parent, *args, **kwds) … … 40 40 """ 41 41 self.main_sizer = wx.BoxSizer(wx.VERTICAL) 42 self.box_aperture = wx.StaticBox(self, -1,str("Aperture")) 43 self.boxsizer_aperture = wx.StaticBoxSizer(self.box_aperture, wx.VERTICAL) 42 self.box_aperture = wx.StaticBox(self, -1, str("Aperture")) 43 self.boxsizer_aperture = wx.StaticBoxSizer(self.box_aperture, 44 wx.VERTICAL) 44 45 45 46 self.name_sizer = wx.BoxSizer(wx.HORIZONTAL) … … 56 57 #Aperture name [string] 57 58 aperture_name_txt = wx.StaticText(self, -1, 'Aperture Name : ') 58 self.aperture_name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH*5, 20), style=0) 59 self.aperture_name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH*5, 20), 60 style=0) 59 61 self.name_sizer.AddMany([(aperture_name_txt, 0, wx.LEFT|wx.RIGHT, 10), 60 62 (self.aperture_name_tcl, 0, wx.EXPAND)]) … … 75 77 #Aperture distance [float] 76 78 distance_txt = wx.StaticText(self, -1, 'Distance:') 77 self.distance_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 79 self.distance_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), 80 style=0) 78 81 distance_unit_txt = wx.StaticText(self, -1, 'Unit: ') 79 self.distance_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20),style=0) 82 self.distance_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), 83 style=0) 80 84 self.distance_sizer.AddMany([(distance_txt, 0, wx.LEFT|wx.RIGHT, 10), 81 85 (self.distance_tcl, 0, wx.LEFT, 10), 82 (distance_unit_txt, 0,wx.LEFT|wx.RIGHT, 10),86 (distance_unit_txt, 0, wx.LEFT|wx.RIGHT, 10), 83 87 (self.distance_unit_tcl, 0, wx.EXPAND)]) 84 88 def _layout_size_name(self): … … 88 92 # Size name [string] 89 93 size_name_txt = wx.StaticText(self, -1, 'Size Name : ') 90 self.size_name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH*5, 20), style=0) 94 self.size_name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH*5, 20), 95 style=0) 91 96 self.size_name_sizer.AddMany([(size_name_txt, 0, wx.LEFT|wx.RIGHT, 10), 92 97 (self.size_name_tcl, 0, wx.EXPAND)]) … … 99 104 aperture_size_txt = wx.StaticText(self, -1, 'Size:') 100 105 x_aperture_size_txt = wx.StaticText(self, -1, 'x = ') 101 self.x_aperture_size_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0) 106 self.x_aperture_size_tcl = wx.TextCtrl(self, -1, 107 size=(_BOX_WIDTH,20), style=0) 102 108 y_aperture_size_txt = wx.StaticText(self, -1, 'y = ') 103 self.y_aperture_size_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0) 109 self.y_aperture_size_tcl = wx.TextCtrl(self, -1, 110 size=(_BOX_WIDTH,20), style=0) 104 111 z_aperture_size_txt = wx.StaticText(self, -1, 'z = ') 105 self.z_aperture_size_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0) 112 self.z_aperture_size_tcl = wx.TextCtrl(self, -1, 113 size=(_BOX_WIDTH,20), style=0) 106 114 aperture_size_unit_txt = wx.StaticText(self, -1, 'Unit: ') 107 self.aperture_size_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0) 108 self.aperture_size_sizer.AddMany([(aperture_size_txt, 0, wx.LEFT|wx.RIGHT, 10), 115 self.aperture_size_unit_tcl = wx.TextCtrl(self, -1, 116 size=(_BOX_WIDTH,20), style=0) 117 self.aperture_size_sizer.AddMany([(aperture_size_txt, 118 0, wx.LEFT|wx.RIGHT, 10), 109 119 (x_aperture_size_txt, 0, wx.LEFT, 17), 110 120 (self.x_aperture_size_tcl, 0, wx.RIGHT, 10), 111 121 (y_aperture_size_txt, 0, wx.EXPAND), 112 122 (self.y_aperture_size_tcl, 0, wx.RIGHT, 10), 113 123 (z_aperture_size_txt, 0, wx.EXPAND), 114 124 (self.z_aperture_size_tcl, 0, wx.RIGHT, 10), 115 125 (aperture_size_unit_txt, 0, wx.EXPAND), 116 126 (self.aperture_size_unit_tcl, 0, wx.RIGHT, 10)]) 117 127 118 128 def _layout_button(self): … … 132 142 (self.bt_close, 0, wx.LEFT, 10)]) 133 143 134 def _do_layout(self , data=None):144 def _do_layout(self ):#, data=None): 135 145 """ 136 146 Draw the current panel … … 224 234 if self._aperture.name != name: 225 235 self._notes += "Change sample 's " 226 self._notes += "name from %s to %s \n"% (self._aperture.name, name)236 self._notes += "name from %s to %s \n"% (self._aperture.name, name) 227 237 self._aperture.name = name 228 238 … … 235 245 self._aperture.type = type 236 246 self._notes += " Change type from" 237 self._notes += " %s to %s \n"% (self._aperture.type, type)247 self._notes += " %s to %s \n"% (self._aperture.type, type) 238 248 239 249 def on_change_distance(self): … … 250 260 if self._aperture.distance != float(distance): 251 261 self._notes += "Change distance from " 252 self._notes += "%s to %s \n"%(self._aperture.distance, distance) 262 self._notes += "%s to %s \n"% (self._aperture.distance, 263 distance) 253 264 self._aperture.distance = float(distance) 254 265 else: 255 266 self._notes += "Error: Expected a float for distance " 256 267 self._notes += "won't changes distance from " 257 self._notes += "%s to %s"% (self._aperture.distance, distance)268 self._notes += "%s to %s"% (self._aperture.distance, distance) 258 269 #change the distance unit 259 270 unit = self.distance_unit_tcl.GetValue().lstrip().rstrip() 260 271 if self._aperture.distance_unit != unit: 261 272 self._notes += " Change distance 's unit from " 262 self._notes += "%s to %s"% (self._aperture.distance_unit, unit)273 self._notes += "%s to %s"% (self._aperture.distance_unit, unit) 263 274 264 275 def on_change_size_name(self): … … 270 281 self._aperture.size_name = size_name 271 282 self._notes += " Change size name from" 272 self._notes += " %s to %s \n"% (self._aperture.size_name, size_name)283 self._notes += " %s to %s \n"% (self._aperture.size_name, size_name) 273 284 274 285 def on_change_size(self): … … 284 295 if self._aperture.size.x != float(x_aperture_size) : 285 296 self._notes += "Change x of aperture size from " 286 self._notes += "%s to %s \n"%(self._aperture.size.x, x_aperture_size) 297 self._notes += "%s to %s \n"% (self._aperture.size.x, 298 x_aperture_size) 287 299 self._aperture.aperture_size.x = float(x_aperture_size) 288 300 else: 289 self._notes += "Error: Expected a float for the aperture size 's x " 301 self._notes += "Error: Expected a" 302 self._notes += " float for the aperture size 's x " 290 303 self._notes += "won't changes x aperture size from " 291 self._notes += "%s to %s"%(self._aperture.size.x, x_aperture_size) 304 self._notes += "%s to %s"% (self._aperture.size.x, 305 x_aperture_size) 292 306 #Change y coordinate 293 307 y_aperture_size = self.y_aperture_size_tcl.GetValue().lstrip().rstrip() … … 299 313 if self._aperture.size.y != float(y_aperture_size): 300 314 self._notes += "Change y of aperture size from " 301 self._notes += "%s to %s \n"%(self._aperture.size.y, y_aperture_size) 315 self._notes += "%s to %s \n"% (self._aperture.size.y, 316 y_aperture_size) 302 317 self._aperture.size.y = float(y_aperture_size) 303 318 else: 304 self._notes += "Error: Expected a float for the aperture size's y " 319 self._notes += "Error: Expected a float for the" 320 self._notes += " aperture size's y " 305 321 self._notes += "won't changes y aperture size from " 306 self._notes += "%s to %s"%(self._aperture.size.y, y_aperture_size) 322 self._notes += "%s to %s"% (self._aperture.size.y, 323 y_aperture_size) 307 324 #Change z coordinate 308 325 z_aperture_size = self.z_aperture_size_tcl.GetValue().lstrip().rstrip() … … 314 331 if self._aperture.size.z != float(z_aperture_size): 315 332 self._notes += "Change z of aperture size from " 316 self._notes += "%s to %s \n"% (self._aperture.size.z,333 self._notes += "%s to %s \n"% (self._aperture.size.z, 317 334 z_aperture_size) 318 335 self._aperture.size.z = float(z_aperture_size) … … 320 337 self._notes += "Error: Expected a float for the offset 's x " 321 338 self._notes += "won't changes z aperture size from " 322 self._notes += "%s to %s"%(self._aperture.size.z, z_aperture_size) 339 self._notes += "%s to %s"% (self._aperture.size.z, 340 z_aperture_size) 323 341 #change the aperture center unit 324 342 unit = self.aperture_size_unit_tcl.GetValue().lstrip().rstrip() 325 343 if self._aperture.size_unit != unit: 326 344 self._notes += " Change aperture size's unit from " 327 self._notes += "%s to %s"% (self._aperture.size_unit, unit)345 self._notes += "%s to %s"% (self._aperture.size_unit, unit) 328 346 self._aperture.size_unit = unit 329 347 … … 340 358 if self.manager is not None: 341 359 self.manager.set_aperture(self._aperture) 342 360 if event is not None: 361 event.Skip() 362 343 363 def on_click_cancel(self, event): 344 364 """ … … 349 369 if self.manager is not None: 350 370 self.manager.set_aperture(self._aperture) 371 if event is not None: 372 event.Skip() 351 373 352 if __name__ == "__main__":374 if __name__ == "__main__": 353 375 354 376 app = wx.App() … … 357 379 # Load data 358 380 from DataLoader.data_info import Aperture 359 ap erture= Aperture()360 dlg = ApertureDialog(aperture=ap erture)381 ap = Aperture() 382 dlg = ApertureDialog(aperture=ap) 361 383 dlg.ShowModal() 362 384 app.MainLoop()
Note: See TracChangeset
for help on using the changeset viewer.