Changeset 2f732b0 in sasview
- Timestamp:
- Mar 4, 2015 3:37:14 PM (10 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:
- 2f4b430
- Parents:
- 49ab5d7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/calculator/aperture_editor.py
r49ab5d7 r2f732b0 3 3 import sys 4 4 from copy import deepcopy 5 from sas.dataloader.loader import Loader6 5 from sas.guiframe.utils import check_float 7 6 … … 31 30 self._reset_aperture = deepcopy(aperture) 32 31 self._notes = "" 33 #self_description = "Edit aperture"34 32 35 33 #Attributes for panel … … 67 65 self.main_sizer = wx.BoxSizer(wx.VERTICAL) 68 66 self.box_aperture = wx.StaticBox(self, -1, str("Aperture")) 69 self.boxsizer_aperture = wx.StaticBoxSizer(self.box_aperture, 70 wx.VERTICAL) 71 67 self.boxsizer_aperture = wx.StaticBoxSizer(self.box_aperture, wx.VERTICAL) 72 68 self.name_sizer = wx.BoxSizer(wx.HORIZONTAL) 73 69 self.type_sizer = wx.BoxSizer(wx.HORIZONTAL) … … 83 79 #Aperture name [string] 84 80 aperture_name_txt = wx.StaticText(self, -1, 'Aperture Name : ') 85 self.aperture_name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH * 5, 20), 86 style=0) 81 self.aperture_name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH * 5, 20), style=0) 87 82 self.name_sizer.AddMany([(aperture_name_txt, 0, wx.LEFT | wx.RIGHT, 10), 88 83 (self.aperture_name_tcl, 0, wx.EXPAND)]) 89 84 def _layout_type(self): 90 85 """ … … 95 90 self.type_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 96 91 self.type_sizer.AddMany([(type_txt, 0, wx.LEFT | wx.RIGHT, 10), 97 92 (self.type_tcl, 0, wx.LEFT, 20)]) 98 93 99 94 def _layout_distance(self): … … 106 101 style=0) 107 102 distance_unit_txt = wx.StaticText(self, -1, 'Unit: ') 108 self.distance_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), 109 style=0) 103 self.distance_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 110 104 self.distance_sizer.AddMany([(distance_txt, 0, wx.LEFT | wx.RIGHT, 10), 111 105 (self.distance_tcl, 0, wx.LEFT, 10), 112 (distance_unit_txt, 0, wx.LEFT | wx.RIGHT, 10),106 (distance_unit_txt, 0, wx.LEFT | wx.RIGHT, 10), 113 107 (self.distance_unit_tcl, 0, wx.EXPAND)]) 114 108 def _layout_size_name(self): … … 118 112 # Size name [string] 119 113 size_name_txt = wx.StaticText(self, -1, 'Size Name : ') 120 self.size_name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH * 5, 20), 121 style=0) 114 self.size_name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH * 5, 20), style=0) 122 115 self.size_name_sizer.AddMany([(size_name_txt, 0, wx.LEFT | wx.RIGHT, 10), 123 116 (self.size_name_tcl, 0, wx.EXPAND)]) 124 117 125 118 def _layout_size(self): … … 130 123 aperture_size_txt = wx.StaticText(self, -1, 'Size:') 131 124 x_aperture_size_txt = wx.StaticText(self, -1, 'x = ') 132 self.x_aperture_size_tcl = wx.TextCtrl(self, -1, 133 size=(_BOX_WIDTH, 20), style=0) 125 self.x_aperture_size_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 134 126 y_aperture_size_txt = wx.StaticText(self, -1, 'y = ') 135 self.y_aperture_size_tcl = wx.TextCtrl(self, -1, 136 size=(_BOX_WIDTH, 20), style=0) 127 self.y_aperture_size_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 137 128 z_aperture_size_txt = wx.StaticText(self, -1, 'z = ') 138 self.z_aperture_size_tcl = wx.TextCtrl(self, -1, 139 size=(_BOX_WIDTH, 20), style=0) 129 self.z_aperture_size_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 140 130 aperture_size_unit_txt = wx.StaticText(self, -1, 'Unit: ') 141 self.aperture_size_unit_tcl = wx.TextCtrl(self, -1, 142 size=(_BOX_WIDTH, 20), style=0) 143 self.aperture_size_sizer.AddMany([(aperture_size_txt, 144 0, wx.LEFT | wx.RIGHT, 10), 145 (x_aperture_size_txt, 0, wx.LEFT, 17), 146 (self.x_aperture_size_tcl, 0, wx.RIGHT, 10), 147 (y_aperture_size_txt, 0, wx.EXPAND), 148 (self.y_aperture_size_tcl, 0, wx.RIGHT, 10), 149 (z_aperture_size_txt, 0, wx.EXPAND), 150 (self.z_aperture_size_tcl, 0, wx.RIGHT, 10), 151 (aperture_size_unit_txt, 0, wx.EXPAND), 152 (self.aperture_size_unit_tcl, 0, wx.RIGHT, 10)]) 131 self.aperture_size_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 132 self.aperture_size_sizer.AddMany([(aperture_size_txt, 0, wx.LEFT | wx.RIGHT, 10), 133 (x_aperture_size_txt, 0, wx.LEFT, 17), 134 (self.x_aperture_size_tcl, 0, wx.RIGHT, 10), 135 (y_aperture_size_txt, 0, wx.EXPAND), 136 (self.y_aperture_size_tcl, 0, wx.RIGHT, 10), 137 (z_aperture_size_txt, 0, wx.EXPAND), 138 (self.z_aperture_size_tcl, 0, wx.RIGHT, 10), 139 (aperture_size_unit_txt, 0, wx.EXPAND), 140 (self.aperture_size_unit_tcl, 0, wx.RIGHT, 10)]) 153 141 154 142 def _layout_button(self): … … 179 167 self._layout_size() 180 168 self._layout_button() 181 self.boxsizer_aperture.AddMany([(self.name_sizer, 0, 182 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 183 (self.type_sizer, 0, 184 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 185 (self.distance_sizer, 0, 186 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 187 (self.size_name_sizer, 0, 188 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 189 (self.aperture_size_sizer, 0, 190 wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 169 self.boxsizer_aperture.AddMany([(self.name_sizer, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 170 (self.type_sizer, 0, 171 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 172 (self.distance_sizer, 0, 173 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 174 (self.size_name_sizer, 0, 175 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 176 (self.aperture_size_sizer, 0, 177 wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 191 178 self.main_sizer.AddMany([(self.boxsizer_aperture, 0, wx.ALL, 10), 192 193 179 (self.button_sizer, 0, 180 wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 194 181 self.SetSizer(self.main_sizer) 195 182 self.SetAutoLayout(True) … … 229 216 #distance unit 230 217 self.distance_unit_tcl.SetValue(str(aperture.distance_unit)) 231 #Size name 218 #Size name 232 219 self.size_name_tcl.SetValue(str(aperture.size_name)) 233 220 #Aperture size as a vector … … 267 254 Change aperture type 268 255 """ 269 #Change type 270 type = self.type_tcl.GetValue().lstrip().rstrip()271 self._aperture.type = type 256 #Change type 257 type_value = self.type_tcl.GetValue().lstrip().rstrip() 258 self._aperture.type = type_value 272 259 self._notes += " Change type from" 273 self._notes += " %s to %s \n" % (self._aperture.type, type )260 self._notes += " %s to %s \n" % (self._aperture.type, type_value) 274 261 275 262 def on_change_distance(self): … … 286 273 if self._aperture.distance != float(distance): 287 274 self._notes += "Change distance from " 288 self._notes += "%s to %s \n" % (self._aperture.distance, 289 distance) 275 self._notes += "%s to %s \n" % (self._aperture.distance, distance) 290 276 self._aperture.distance = float(distance) 291 277 else: … … 319 305 else: 320 306 if check_float(self.x_aperture_size_tcl): 321 if self._aperture.size.x != float(x_aperture_size) 307 if self._aperture.size.x != float(x_aperture_size): 322 308 self._notes += "Change x of aperture size from " 323 self._notes += "%s to %s \n" % (self._aperture.size.x, 324 x_aperture_size) 309 self._notes += "%s to %s \n" % (self._aperture.size.x, x_aperture_size) 325 310 self._aperture.aperture_size.x = float(x_aperture_size) 326 311 else: … … 328 313 self._notes += " float for the aperture size 's x " 329 314 self._notes += "won't changes x aperture size from " 330 self._notes += "%s to %s" % (self._aperture.size.x, 331 x_aperture_size) 315 self._notes += "%s to %s" % (self._aperture.size.x, x_aperture_size) 332 316 #Change y coordinate 333 317 y_aperture_size = self.y_aperture_size_tcl.GetValue().lstrip().rstrip() … … 339 323 if self._aperture.size.y != float(y_aperture_size): 340 324 self._notes += "Change y of aperture size from " 341 self._notes += "%s to %s \n" % (self._aperture.size.y, 342 y_aperture_size) 325 self._notes += "%s to %s \n" % (self._aperture.size.y, y_aperture_size) 343 326 self._aperture.size.y = float(y_aperture_size) 344 327 else: … … 346 329 self._notes += " aperture size's y " 347 330 self._notes += "won't changes y aperture size from " 348 self._notes += "%s to %s" % (self._aperture.size.y, 349 y_aperture_size) 331 self._notes += "%s to %s" % (self._aperture.size.y, y_aperture_size) 350 332 #Change z coordinate 351 333 z_aperture_size = self.z_aperture_size_tcl.GetValue().lstrip().rstrip() … … 357 339 if self._aperture.size.z != float(z_aperture_size): 358 340 self._notes += "Change z of aperture size from " 359 self._notes += "%s to %s \n" % (self._aperture.size.z, 360 z_aperture_size) 341 self._notes += "%s to %s \n" % (self._aperture.size.z, z_aperture_size) 361 342 self._aperture.size.z = float(z_aperture_size) 362 343 else: 363 344 self._notes += "Error: Expected a float for the offset 's x " 364 345 self._notes += "won't changes z aperture size from " 365 self._notes += "%s to %s" % (self._aperture.size.z, 366 z_aperture_size) 346 self._notes += "%s to %s" % (self._aperture.size.z, z_aperture_size) 367 347 #change the aperture center unit 368 348 unit = self.aperture_size_unit_tcl.GetValue().lstrip().rstrip() … … 394 374 self.set_values() 395 375 if self.manager is not None: 396 376 self.manager.set_aperture(self._aperture) 397 377 if event is not None: 398 378 event.Skip() 399 400 if __name__ == "__main__":401 402 app = wx.App()403 # Instantiate a loader404 loader = Loader()405 # Load data406 from sas.dataloader.data_info import Aperture407 ap = Aperture()408 dlg = ApertureDialog(aperture=ap)409 dlg.ShowModal()410 app.MainLoop()
Note: See TracChangeset
for help on using the changeset viewer.