Changeset cacbd7d in sasview for invariantview
- Timestamp:
- Jan 21, 2011 1:27:06 PM (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:
- df7046f
- Parents:
- 75a7ece
- Location:
- invariantview/perspectives/invariant
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
invariantview/perspectives/invariant/invariant.py
rf1e06a8e rcacbd7d 17 17 import copy 18 18 import logging 19 20 19 21 20 from DataLoader.data_info import Data1D as LoaderData1D … … 184 183 """ 185 184 if len(data_list) > 1: 186 msg = "invariant panel does not allow more than one value" 187 msg += " at this time" 188 raise ValueError, msg 185 msg = "invariant panel does not allow multiple data!\n" 186 msg += "Please select one.\n" 187 from invariant_widgets import DataDialog 188 dlg = DataDialog(data_list=data_list, text=msg) 189 if dlg.ShowModal() == wx.ID_OK: 190 data = dlg.get_data() 191 if issubclass(data.__class__, LoaderData1D): 192 self.compute_helper(data_list[0]) 193 wx.PostEvent(self.parent, NewPlotEvent(plot=data_list[0], 194 title=data_list[0].title)) 195 else: 196 msg = "invariant cannot be computed for data of " 197 msg += "type %s" % (data_list[0].__class__.__name__) 198 wx.PostEvent(self.parent, 199 StatusEvent(status=msg, info='error')) 189 200 elif len(data_list) == 1: 190 201 if issubclass(data_list[0].__class__, LoaderData1D): … … 195 206 msg = "invariant cannot be computed for" 196 207 msg += " data of type %s" % (data_list[0].__class__.__name__) 197 raise ValueError, msg 208 wx.PostEvent(self.parent, 209 StatusEvent(status=msg, info='error')) 198 210 199 211 -
invariantview/perspectives/invariant/invariant_widgets.py
r4a2b054 rcacbd7d 14 14 15 15 import wx 16 #import os 17 #from invariant_state import InvariantState as IState 18 #import copy 16 from wx.lib.scrolledpanel import ScrolledPanel 19 17 18 WIDTH = 400 19 HEIGHT = 200 20 20 21 class InvTextCtrl(wx.TextCtrl): 21 22 """ … … 90 91 pass 91 92 93 class DataDialog(wx.Dialog): 94 """ 95 Allow file selection at loading time 96 """ 97 def __init__(self, data_list, parent=None, text='', *args, **kwds): 98 wx.Dialog.__init__(self, parent, *args, **kwds) 99 self.SetTitle("Data Selection") 100 self.SetSize((WIDTH, HEIGHT)) 101 self.list_of_ctrl = [] 102 if not data_list: 103 return 104 self._sizer_main = wx.BoxSizer(wx.VERTICAL) 105 self._sizer_txt = wx.BoxSizer(wx.VERTICAL) 106 self._sizer_button = wx.BoxSizer(wx.HORIZONTAL) 107 self._choice_sizer = wx.GridBagSizer(5, 5) 108 self._panel = ScrolledPanel(self, style=wx.RAISED_BORDER, 109 size=(WIDTH-20, HEIGHT-50)) 110 self._panel.SetupScrolling() 111 self.__do_layout(data_list, text=text) 112 113 def __do_layout(self, data_list, text=''): 114 """ 115 layout the dialog 116 """ 117 if not data_list or len(data_list) <= 1: 118 return 119 #add text 120 if text.strip() == "": 121 text = "This Perspective does not allow multiple data !\n" 122 text += "Please select only one Data.\n" 123 text_ctrl = wx.StaticText(self, -1, str(text)) 124 self._sizer_txt.Add(text_ctrl) 125 iy = 0 126 ix = 0 127 rbox = wx.RadioButton(self._panel, -1, str(data_list[0].name), 128 (10, 10), style= wx.RB_GROUP) 129 rbox.SetValue(True) 130 self.list_of_ctrl.append((rbox, data_list[0])) 131 self._choice_sizer.Add(rbox, (iy, ix), (1, 1), 132 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 133 for i in range(1, len(data_list)): 134 iy += 1 135 rbox = wx.RadioButton(self._panel, -1, 136 str(data_list[i].name), (10, 10)) 137 rbox.SetValue(False) 138 self.list_of_ctrl.append((rbox, data_list[i])) 139 self._choice_sizer.Add(rbox, (iy, ix), 140 (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 141 self._panel.SetSizer(self._choice_sizer) 142 #add sizer 143 self._sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 144 button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") 145 self._sizer_button.Add(button_cancel, 0, 146 wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 147 button_OK = wx.Button(self, wx.ID_OK, "Ok") 148 button_OK.SetFocus() 149 self._sizer_button.Add(button_OK, 0, 150 wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 151 static_line = wx.StaticLine(self, -1) 152 153 self._sizer_txt.Add(self._panel, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 5) 154 self._sizer_main.Add(self._sizer_txt, 1, wx.EXPAND|wx.ALL, 10) 155 self._sizer_main.Add(static_line, 0, wx.EXPAND, 0) 156 self._sizer_main.Add(self._sizer_button, 0, wx.EXPAND|wx.ALL, 10) 157 self.SetSizer(self._sizer_main) 158 self.Layout() 159 160 def get_data(self): 161 """ 162 return the selected data 163 """ 164 for item in self.list_of_ctrl: 165 rbox, data = item 166 if rbox.GetValue(): 167 return data 168 92 169 93 170
Note: See TracChangeset
for help on using the changeset viewer.