Changeset c9a519f in sasview for src/sas


Ignore:
Timestamp:
Jul 14, 2016 3:14:42 AM (8 years ago)
Author:
lewis
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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
8b633dd
Parents:
a8ed421
Message:

Abstract vector inputs into their own class

Location:
src/sas/sasgui/perspectives/file_converter
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/file_converter/converter_panel.py

    rfdbea3c rc9a519f  
    99from sas.sasgui.guiframe.panel_base import PanelBase 
    1010from sas.sasgui.perspectives.calculator import calculator_widgets as widget 
     11from sas.sasgui.perspectives.file_converter.converter_widgets import VectorInput 
    1112from sas.sasgui.guiframe.events import StatusEvent 
    1213from sas.sasgui.guiframe.dataFitting import Data1D 
     
    155156 
    156157        for ctrl in self.to_validate: 
    157             if ctrl.GetValue() == '': continue 
    158             ctrl_valid = check_float(ctrl) 
     158            ctrl_valid = True 
     159            invalid_control = None 
     160            if isinstance(ctrl, VectorInput): 
     161                ctrl_valid, invalid_control = ctrl.Validate() 
     162            else: 
     163                if ctrl.GetValue() == '': continue 
     164                ctrl_valid = check_float(ctrl) 
     165                invalid_control = ctrl 
    159166            if not ctrl_valid: 
    160167                msg = "{} must be a valid float".format( 
    161                     ctrl.GetName().replace('_', ' ')) 
     168                    invalid_control.GetName().replace('_', ' ')) 
    162169                wx.PostEvent(self.parent.manager.parent, 
    163170                    StatusEvent(status=msg, info='error')) 
    164171                return False 
     172 
    165173        return True 
    166174 
     
    293301        metadata_grid.Add(offset_label, (y,1), (1,1)) 
    294302 
    295         offset_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    296         x_label = wx.StaticText(metadata_pane, -1, "x: ", 
    297             style=wx.ALIGN_CENTER_VERTICAL) 
    298         offset_sizer.Add(x_label, wx.ALIGN_CENTER_VERTICAL) 
    299         offset_x_input = wx.TextCtrl(metadata_pane, -1, 
    300             name="detector_offset_x", size=(50, -1)) 
    301         offset_sizer.Add(offset_x_input) 
    302         self.to_validate.append(offset_x_input) 
    303         offset_x_input.Bind(wx.EVT_TEXT, self.metadata_changed) 
    304         offset_sizer.AddSpacer((15, -1)) 
    305         y_label = wx.StaticText(metadata_pane, -1, "y: ", 
    306             style=wx.ALIGN_CENTER_VERTICAL) 
    307         offset_sizer.Add(y_label, wx.ALIGN_CENTER_VERTICAL) 
    308         offset_y_input = wx.TextCtrl(metadata_pane, -1, 
    309             name="detector_offset_y", size=(50, -1)) 
    310         offset_sizer.Add(offset_y_input) 
    311         self.to_validate.append(offset_y_input) 
    312         offset_y_input.Bind(wx.EVT_TEXT, self.metadata_changed) 
    313         metadata_grid.Add(offset_sizer, (y,2), (1,1), wx.BOTTOM, 5) 
     303        offset_input = VectorInput(metadata_pane, "detector_offset", 
     304            callback=self.metadata_changed) 
     305        self.to_validate.append(offset_input) 
     306        metadata_grid.Add(offset_input.GetSizer(), (y,2), (1,1), wx.BOTTOM, 5) 
    314307        y += 1 
    315308 
     
    318311        metadata_grid.Add(orientation_label, (y, 1), (1, 1)) 
    319312 
    320         orientation_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    321         roll_label = wx.StaticText(metadata_pane, -1, "Roll: ") 
    322         orientation_sizer.Add(roll_label) 
    323         roll_input = wx.TextCtrl(metadata_pane, -1, 
    324             name="detector_orientation_x", size=(50, -1)) 
    325         self.to_validate.append(roll_input) 
    326         roll_input.Bind(wx.EVT_TEXT, self.metadata_changed) 
    327         orientation_sizer.Add(roll_input) 
    328         orientation_sizer.AddSpacer((15, -1)) 
    329         pitch_label = wx.StaticText(metadata_pane, -1, "Pitch: ") 
    330         orientation_sizer.Add(pitch_label) 
    331         pitch_input = wx.TextCtrl(metadata_pane, 1, 
    332             name="detector_orientation_y", size=(50,-1)) 
    333         self.to_validate.append(pitch_input) 
    334         pitch_input.Bind(wx.EVT_TEXT, self.metadata_changed) 
    335         orientation_sizer.Add(pitch_input) 
    336         orientation_sizer.AddSpacer((15, -1)) 
    337         yaw_label = wx.StaticText(metadata_pane, -1, "Yaw: ") 
    338         orientation_sizer.Add(yaw_label) 
    339         yaw_input = wx.TextCtrl(metadata_pane, 1, 
    340             name="detector_orientation_z", size=(50,-1)) 
    341         yaw_input.Bind(wx.EVT_TEXT, self.metadata_changed) 
    342         self.to_validate.append(yaw_input) 
    343         orientation_sizer.Add(yaw_input) 
    344  
    345         metadata_grid.Add(orientation_sizer, (y,2), (1,1), wx.BOTTOM, 5) 
     313        orientation_input = VectorInput(metadata_pane, "detector_orientation", 
     314            callback=self.metadata_changed, z_enabled=True, 
     315            labels=["Roll: ", "Pitch: ", "Yaw: "]) 
     316        self.to_validate.append(orientation_input) 
     317        metadata_grid.Add(orientation_input.GetSizer(), 
     318            (y,2), (1,1), wx.BOTTOM, 5) 
    346319        y += 1 
    347320 
     
    349322        metadata_grid.Add(pixel_label, (y,1), (1,1)) 
    350323 
    351         pixel_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    352         pixel_x_label = wx.StaticText(metadata_pane, -1, "x: ") 
    353         pixel_sizer.Add(pixel_x_label) 
    354         pixel_x_input = wx.TextCtrl(metadata_pane, -1, 
    355             name="detector_pixel_size_x", size=(50, -1)) 
    356         self.to_validate.append(pixel_x_input) 
    357         pixel_x_input.Bind(wx.EVT_TEXT, self.metadata_changed) 
    358         pixel_sizer.Add(pixel_x_input) 
    359         pixel_sizer.AddSpacer((15, -1)) 
    360         pixel_y_label = wx.StaticText(metadata_pane, -1, "y: ") 
    361         pixel_sizer.Add(pixel_y_label) 
    362         pixel_y_input = wx.TextCtrl(metadata_pane, 1, 
    363             name="detector_pixel_size_y", size=(50,-1)) 
    364         self.to_validate.append(pixel_y_input) 
    365         pixel_y_input.Bind(wx.EVT_TEXT, self.metadata_changed) 
    366         pixel_sizer.Add(pixel_y_input) 
    367  
    368         metadata_grid.Add(pixel_sizer, (y,2), (1,1), wx.BOTTOM, 5) 
     324        pixel_input = VectorInput(metadata_pane, "detector_pixel_size", 
     325             callback=self.metadata_changed) 
     326        self.to_validate.append(pixel_input) 
     327        metadata_grid.Add(pixel_input.GetSizer(), (y,2), (1,1), wx.BOTTOM, 5) 
    369328 
    370329        metadata_pane.SetSizer(metadata_grid) 
Note: See TracChangeset for help on using the changeset viewer.