Changeset 75a7ece in sasview
- Timestamp:
- Jan 21, 2011 3:06:10 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:
- cacbd7d
- Parents:
- b5181f6
- Location:
- prview/perspectives/pr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
prview/perspectives/pr/pr.py
r75df58b r75a7ece 1311 1311 """ 1312 1312 if len(data_list) > 1: 1313 msg = "Pr panel does not allow more than one value" 1314 msg += " at this time" 1315 raise ValueError, msg 1313 msg = "Pr panel does not allow multiple Data.\n" 1314 msg += "Please select one!\n" 1315 from pr_widgets import DataDialog 1316 dlg = DataDialog(data_list=data_list, text=msg) 1317 if dlg.ShowModal() == wx.ID_OK: 1318 data = dlg.get_data() 1319 if issubclass(data.__class__, LoaderData1D): 1320 self.control_panel._change_file(evt=None, data=data) 1321 else: 1322 msg = "Pr cannot be computed for data of " 1323 msg += "type %s" % (data_list[0].__class__.__name__) 1324 wx.PostEvent(self.parent, 1325 StatusEvent(status=msg, info='error')) 1316 1326 elif len(data_list) == 1: 1317 1327 if issubclass(data_list[0].__class__, LoaderData1D): … … 1320 1330 msg = "Pr cannot be computed for" 1321 1331 msg += " data of type %s" % (data_list[0].__class__.__name__) 1322 raise ValueError, msg 1332 wx.PostEvent(self.parent, 1333 StatusEvent(status=msg, info='error')) 1334 else: 1335 msg = "Pr contain no data" 1336 wx.PostEvent(self.parent, StatusEvent(status=msg, info='warning')) 1323 1337 1324 1338 def post_init(self): -
prview/perspectives/pr/pr_widgets.py
r7116b6e0 r75a7ece 16 16 import wx 17 17 import os 18 18 from wx.lib.scrolledpanel import ScrolledPanel 19 19 class PrTextCtrl(wx.TextCtrl): 20 20 """ … … 119 119 """ 120 120 return self._complete_path 121 122 class DataDialog(wx.Dialog): 123 """ 124 Allow file selection at loading time 125 """ 126 def __init__(self, data_list, parent=None, text='', *args, **kwds): 127 wx.Dialog.__init__(self, parent, *args, **kwds) 128 self.list_of_ctrl = [] 129 self._do_layout(data_list, text=text) 130 131 def _do_layout(self, data_list, text=''): 132 """ 133 layout the dialog 134 """ 135 if not data_list or len(data_list) <= 1: 136 return 137 # Dialog box properties 138 self.SetTitle("Data Selection") 139 w = 400 140 h = 200 141 self.SetSize((w, h)) 142 sizer_main = wx.BoxSizer(wx.VERTICAL) 143 sizer_txt = wx.BoxSizer(wx.VERTICAL) 144 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 145 choice_sizer = wx.GridBagSizer(5, 5) 146 #choice_sizer.SetMinSize((w-20, h-50)) 147 panel = ScrolledPanel(self, style=wx.RAISED_BORDER, size=(w-20, h-50)) 148 panel.SetupScrolling() 149 #add text 150 if text.strip() == "": 151 text = "This Perspective does not allow multiple data !\n" 152 text += "Please select only one Data.\n" 153 text_ctrl = wx.StaticText(self, -1, str(text)) 154 sizer_txt.Add(text_ctrl) 155 iy = 0 156 ix = 0 157 rbox = wx.RadioButton(panel, -1, str(data_list[0].name), 158 (10, 10), style= wx.RB_GROUP) 159 rbox.SetValue(True) 160 self.list_of_ctrl.append((rbox, data_list[0])) 161 choice_sizer.Add(rbox, (iy, ix), (1, 1), 162 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 163 for i in range(1, len(data_list)): 164 iy += 1 165 rbox = wx.RadioButton(panel, -1, str(data_list[i].name), (10, 10)) 166 rbox.SetValue(False) 167 self.list_of_ctrl.append((rbox, data_list[i])) 168 choice_sizer.Add(rbox, (iy, ix), 169 (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 170 panel.SetSizer(choice_sizer) 171 #add sizer 172 sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 173 button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") 174 sizer_button.Add(button_cancel, 0, 175 wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 176 button_OK = wx.Button(self, wx.ID_OK, "Ok") 177 button_OK.SetFocus() 178 sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 179 static_line = wx.StaticLine(self, -1) 180 181 sizer_txt.Add(panel, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 5) 182 sizer_main.Add(sizer_txt, 1, wx.EXPAND|wx.ALL, 10) 183 sizer_main.Add(static_line, 0, wx.EXPAND, 0) 184 sizer_main.Add(sizer_button, 0, wx.EXPAND|wx.ALL, 10) 185 self.SetSizer(sizer_main) 186 self.Layout() 187 188 def get_data(self): 189 """ 190 return the selected data 191 """ 192 for item in self.list_of_ctrl: 193 rbox, data = item 194 if rbox.GetValue(): 195 return data
Note: See TracChangeset
for help on using the changeset viewer.