Changeset 49ab5d7 in sasview for src/sas/perspectives/calculator/aperture_editor.py
- Timestamp:
- Mar 4, 2015 3:28:39 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:
- 2f732b0
- Parents:
- 76aed53
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/calculator/aperture_editor.py
r79492222 r49ab5d7 7 7 8 8 _BOX_WIDTH = 60 9 if sys.platform.count("win32") >0:9 if sys.platform.count("win32") > 0: 10 10 _STATICBOX_WIDTH = 450 11 11 PANEL_WIDTH = 500 … … 17 17 PANEL_HEIGHT = 320 18 18 FONT_VARIANT = 1 19 19 20 20 class ApertureDialog(wx.Dialog): 21 21 def __init__(self, parent=None, manager=None, aperture=None, *args, **kwds): … … 32 32 self._notes = "" 33 33 #self_description = "Edit aperture" 34 34 35 35 #Attributes for panel 36 36 self.aperture_name_tcl = None … … 40 40 self.name_sizer = None 41 41 self.name_sizer = None 42 self.size_name_tcl 42 self.size_name_tcl = None 43 43 self.type_sizer = None 44 44 self.distance_sizer = None … … 57 57 self.bt_cancel = None 58 58 self.bt_close = None 59 59 60 60 self._do_layout() 61 61 self.set_values() 62 62 63 63 def _define_structure(self): 64 64 """ 65 define initial sizer 65 define initial sizer 66 66 """ 67 67 self.main_sizer = wx.BoxSizer(wx.VERTICAL) 68 68 self.box_aperture = wx.StaticBox(self, -1, str("Aperture")) 69 self.boxsizer_aperture = wx.StaticBoxSizer(self.box_aperture, 69 self.boxsizer_aperture = wx.StaticBoxSizer(self.box_aperture, 70 70 wx.VERTICAL) 71 71 72 72 self.name_sizer = wx.BoxSizer(wx.HORIZONTAL) 73 73 self.type_sizer = wx.BoxSizer(wx.HORIZONTAL) … … 76 76 self.aperture_size_sizer = wx.BoxSizer(wx.HORIZONTAL) 77 77 self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 78 78 79 79 def _layout_name(self): 80 80 """ … … 82 82 """ 83 83 #Aperture name [string] 84 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) 87 self.name_sizer.AddMany([(aperture_name_txt, 0, wx.LEFT |wx.RIGHT, 10),84 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) 87 self.name_sizer.AddMany([(aperture_name_txt, 0, wx.LEFT | wx.RIGHT, 10), 88 88 (self.aperture_name_tcl, 0, wx.EXPAND)]) 89 89 def _layout_type(self): … … 92 92 """ 93 93 #Aperture type [string] 94 type_txt = wx.StaticText(self, -1, 'Type: ') 94 type_txt = wx.StaticText(self, -1, 'Type: ') 95 95 self.type_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 96 self.type_sizer.AddMany([(type_txt, 0, wx.LEFT |wx.RIGHT, 10),96 self.type_sizer.AddMany([(type_txt, 0, wx.LEFT | wx.RIGHT, 10), 97 97 (self.type_tcl, 0, wx.LEFT, 20)]) 98 98 99 99 def _layout_distance(self): 100 100 """ … … 102 102 """ 103 103 #Aperture distance [float] 104 distance_txt = wx.StaticText(self, -1, 'Distance:') 105 self.distance_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), 106 style=0) 107 distance_unit_txt = wx.StaticText(self, -1, 'Unit: ') 104 distance_txt = wx.StaticText(self, -1, 'Distance:') 105 self.distance_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), 106 style=0) 107 distance_unit_txt = wx.StaticText(self, -1, 'Unit: ') 108 108 self.distance_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), 109 style=0) 110 self.distance_sizer.AddMany([(distance_txt, 0, wx.LEFT |wx.RIGHT, 10),109 style=0) 110 self.distance_sizer.AddMany([(distance_txt, 0, wx.LEFT | wx.RIGHT, 10), 111 111 (self.distance_tcl, 0, wx.LEFT, 10), 112 (distance_unit_txt, 0, wx.LEFT|wx.RIGHT, 10),113 (self.distance_unit_tcl, 0, wx.EXPAND)]) 112 (distance_unit_txt, 0, wx.LEFT | wx.RIGHT, 10), 113 (self.distance_unit_tcl, 0, wx.EXPAND)]) 114 114 def _layout_size_name(self): 115 115 """ … … 117 117 """ 118 118 # Size name [string] 119 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) 122 self.size_name_sizer.AddMany([(size_name_txt, 0, wx.LEFT |wx.RIGHT, 10),119 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) 122 self.size_name_sizer.AddMany([(size_name_txt, 0, wx.LEFT | wx.RIGHT, 10), 123 123 (self.size_name_tcl, 0, wx.EXPAND)]) 124 124 125 125 def _layout_size(self): 126 126 """ … … 128 128 """ 129 129 #Aperture size [Vector] 130 aperture_size_txt = wx.StaticText(self, -1, 'Size:') 131 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)134 y_aperture_size_txt = wx.StaticText(self, -1, 'y = ') 130 aperture_size_txt = wx.StaticText(self, -1, 'Size:') 131 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) 134 y_aperture_size_txt = wx.StaticText(self, -1, 'y = ') 135 135 self.y_aperture_size_tcl = wx.TextCtrl(self, -1, 136 size=(_BOX_WIDTH, 20), style=0)137 z_aperture_size_txt = wx.StaticText(self, -1, 'z = ') 136 size=(_BOX_WIDTH, 20), style=0) 137 z_aperture_size_txt = wx.StaticText(self, -1, 'z = ') 138 138 self.z_aperture_size_tcl = wx.TextCtrl(self, -1, 139 size=(_BOX_WIDTH, 20), style=0)140 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)139 size=(_BOX_WIDTH, 20), style=0) 140 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 143 self.aperture_size_sizer.AddMany([(aperture_size_txt, 144 0, wx.LEFT |wx.RIGHT, 10),144 0, wx.LEFT | wx.RIGHT, 10), 145 145 (x_aperture_size_txt, 0, wx.LEFT, 17), 146 146 (self.x_aperture_size_tcl, 0, wx.RIGHT, 10), … … 151 151 (aperture_size_unit_txt, 0, wx.EXPAND), 152 152 (self.aperture_size_unit_tcl, 0, wx.RIGHT, 10)]) 153 154 def _layout_button(self): 153 154 def _layout_button(self): 155 155 """ 156 156 Do the layout for the button widgets 157 """ 158 self.bt_apply = wx.Button(self, -1, 'Apply')157 """ 158 self.bt_apply = wx.Button(self, -1, 'Apply') 159 159 self.bt_apply.Bind(wx.EVT_BUTTON, self.on_click_apply) 160 160 self.bt_apply.SetToolTipString("Apply current changes to aperture.") 161 self.bt_cancel = wx.Button(self, -1, 'Cancel')161 self.bt_cancel = wx.Button(self, -1, 'Cancel') 162 162 self.bt_cancel.SetToolTipString("Cancel current changes.") 163 163 self.bt_cancel.Bind(wx.EVT_BUTTON, self.on_click_cancel) 164 self.bt_close = wx.Button(self, wx.ID_CANCEL, 'Close')164 self.bt_close = wx.Button(self, wx.ID_CANCEL, 'Close') 165 165 self.bt_close.SetToolTipString("Close window.") 166 166 self.button_sizer.AddMany([(self.bt_apply, 0, wx.LEFT, 200), 167 167 (self.bt_cancel, 0, wx.LEFT, 10), 168 168 (self.bt_close, 0, wx.LEFT, 10)]) 169 170 def _do_layout(self 169 170 def _do_layout(self):#, data=None): 171 171 """ 172 172 Draw the current panel … … 180 180 self._layout_button() 181 181 self.boxsizer_aperture.AddMany([(self.name_sizer, 0, 182 wx.EXPAND |wx.TOP|wx.BOTTOM, 5),182 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 183 183 (self.type_sizer, 0, 184 wx.EXPAND |wx.TOP|wx.BOTTOM, 5),184 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 185 185 (self.distance_sizer, 0, 186 wx.EXPAND |wx.TOP|wx.BOTTOM, 5),186 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 187 187 (self.size_name_sizer, 0, 188 wx.EXPAND |wx.TOP|wx.BOTTOM, 5),188 wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 189 189 (self.aperture_size_sizer, 0, 190 wx.EXPAND |wx.TOP|wx.BOTTOM, 5)])190 wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 191 191 self.main_sizer.AddMany([(self.boxsizer_aperture, 0, wx.ALL, 10), 192 192 (self.button_sizer, 0, 193 wx.EXPAND |wx.TOP|wx.BOTTOM, 5)])193 wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 194 194 self.SetSizer(self.main_sizer) 195 195 self.SetAutoLayout(True) 196 196 197 197 def set_manager(self, manager): 198 """ 198 """ 199 199 Set manager of this window 200 200 """ 201 201 self.manager = manager 202 202 203 203 def reset_aperture(self): 204 204 """ … … 214 214 self._aperture.distance = self._reset_aperture.distance 215 215 self._aperture.distance_unit = self._reset_aperture.distance_unit 216 216 217 217 def set_values(self): 218 218 """ … … 233 233 #Aperture size as a vector 234 234 x, y, z = aperture.size.x, aperture.size.y, aperture.size.z 235 self.x_aperture_size_tcl.SetValue(str(x)) 236 self.y_aperture_size_tcl.SetValue(str(y)) 237 self.z_aperture_size_tcl.SetValue(str(z)) 235 self.x_aperture_size_tcl.SetValue(str(x)) 236 self.y_aperture_size_tcl.SetValue(str(y)) 237 self.z_aperture_size_tcl.SetValue(str(z)) 238 238 self.aperture_size_unit_tcl.SetValue(str(aperture.size_unit)) 239 239 240 240 def get_aperture(self): 241 241 """ … … 243 243 """ 244 244 return self._aperture 245 245 246 246 def get_notes(self): 247 247 """ … … 249 249 """ 250 250 return self._notes 251 251 252 252 def on_change_name(self): 253 253 """ … … 260 260 if self._aperture.name != name: 261 261 self._notes += "Change sample 's " 262 self._notes += "name from %s to %s \n" % (self._aperture.name, name)262 self._notes += "name from %s to %s \n" % (self._aperture.name, name) 263 263 self._aperture.name = name 264 264 265 265 def on_change_type(self): 266 266 """ … … 271 271 self._aperture.type = type 272 272 self._notes += " Change type from" 273 self._notes += " %s to %s \n" % (self._aperture.type, type)274 273 self._notes += " %s to %s \n" % (self._aperture.type, type) 274 275 275 def on_change_distance(self): 276 276 """ … … 286 286 if self._aperture.distance != float(distance): 287 287 self._notes += "Change distance from " 288 self._notes += "%s to %s \n" % (self._aperture.distance,288 self._notes += "%s to %s \n" % (self._aperture.distance, 289 289 distance) 290 self._aperture.distance 290 self._aperture.distance = float(distance) 291 291 else: 292 292 self._notes += "Error: Expected a float for distance " 293 293 self._notes += "won't changes distance from " 294 self._notes += "%s to %s" % (self._aperture.distance, distance)294 self._notes += "%s to %s" % (self._aperture.distance, distance) 295 295 #change the distance unit 296 296 unit = self.distance_unit_tcl.GetValue().lstrip().rstrip() 297 297 if self._aperture.distance_unit != unit: 298 298 self._notes += " Change distance 's unit from " 299 self._notes += "%s to %s" % (self._aperture.distance_unit, unit)300 299 self._notes += "%s to %s" % (self._aperture.distance_unit, unit) 300 301 301 def on_change_size_name(self): 302 302 """ … … 307 307 self._aperture.size_name = size_name 308 308 self._notes += " Change size name from" 309 self._notes += " %s to %s \n" % (self._aperture.size_name, size_name)310 309 self._notes += " %s to %s \n" % (self._aperture.size_name, size_name) 310 311 311 def on_change_size(self): 312 312 """ … … 321 321 if self._aperture.size.x != float(x_aperture_size) : 322 322 self._notes += "Change x of aperture size from " 323 self._notes += "%s to %s \n" % (self._aperture.size.x,323 self._notes += "%s to %s \n" % (self._aperture.size.x, 324 324 x_aperture_size) 325 self._aperture.aperture_size.x 325 self._aperture.aperture_size.x = float(x_aperture_size) 326 326 else: 327 327 self._notes += "Error: Expected a" 328 328 self._notes += " float for the aperture size 's x " 329 329 self._notes += "won't changes x aperture size from " 330 self._notes += "%s to %s" % (self._aperture.size.x,330 self._notes += "%s to %s" % (self._aperture.size.x, 331 331 x_aperture_size) 332 332 #Change y coordinate … … 339 339 if self._aperture.size.y != float(y_aperture_size): 340 340 self._notes += "Change y of aperture size from " 341 self._notes += "%s to %s \n" % (self._aperture.size.y,341 self._notes += "%s to %s \n" % (self._aperture.size.y, 342 342 y_aperture_size) 343 self._aperture.size.y 343 self._aperture.size.y = float(y_aperture_size) 344 344 else: 345 345 self._notes += "Error: Expected a float for the" 346 346 self._notes += " aperture size's y " 347 347 self._notes += "won't changes y aperture size from " 348 self._notes += "%s to %s" % (self._aperture.size.y,348 self._notes += "%s to %s" % (self._aperture.size.y, 349 349 y_aperture_size) 350 350 #Change z coordinate … … 357 357 if self._aperture.size.z != float(z_aperture_size): 358 358 self._notes += "Change z of aperture size from " 359 self._notes += "%s to %s \n" % (self._aperture.size.z,359 self._notes += "%s to %s \n" % (self._aperture.size.z, 360 360 z_aperture_size) 361 self._aperture.size.z 361 self._aperture.size.z = float(z_aperture_size) 362 362 else: 363 363 self._notes += "Error: Expected a float for the offset 's x " 364 364 self._notes += "won't changes z aperture size from " 365 self._notes += "%s to %s" % (self._aperture.size.z,365 self._notes += "%s to %s" % (self._aperture.size.z, 366 366 z_aperture_size) 367 367 #change the aperture center unit … … 369 369 if self._aperture.size_unit != unit: 370 370 self._notes += " Change aperture size's unit from " 371 self._notes += "%s to %s" % (self._aperture.size_unit, unit)371 self._notes += "%s to %s" % (self._aperture.size_unit, unit) 372 372 self._aperture.size_unit = unit 373 373 374 374 def on_click_apply(self, event): 375 375 """ … … 386 386 if event is not None: 387 387 event.Skip() 388 388 389 389 def on_click_cancel(self, event): 390 390 """ … … 397 397 if event is not None: 398 398 event.Skip() 399 399 400 400 if __name__ == "__main__": 401 402 app 401 402 app = wx.App() 403 403 # Instantiate a loader 404 404 loader = Loader() … … 409 409 dlg.ShowModal() 410 410 app.MainLoop() 411
Note: See TracChangeset
for help on using the changeset viewer.