Changeset 3ecaa2b in sasview for inversionview
- Timestamp:
- Oct 21, 2011 2:30:21 PM (13 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:
- 18476d6
- Parents:
- 9cec2dd
- Location:
- inversionview/src/sans/perspectives/pr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inversionview/src/sans/perspectives/pr/pr.py
rd80f7e1 r3ecaa2b 1356 1356 data = data_list[0] 1357 1357 else: 1358 msg = "Pr panel does not allow multiple Data.\n" 1359 msg += "Please select one!\n" 1358 data_1d_list = [] 1359 data_2d_list = [] 1360 error_msg = "" 1361 # separate data into data1d and data2d list 1362 for data in data_list: 1363 if data is not None: 1364 if issubclass(data.__class__, Data1D): 1365 data_1d_list.append(data) 1366 else: 1367 error_msg += " %s type %s \n" % (str(data.name), 1368 str(data.__class__.__name__)) 1369 data_2d_list.append(data) 1370 if len(data_2d_list) > 0: 1371 msg = "PrView does not support the following data types:\n" 1372 msg += error_msg 1373 if len(data_1d_list) == 0: 1374 wx.PostEvent(self.parent, 1375 StatusEvent(status=msg, info='error')) 1376 return 1377 msg += "Prview does not allow multiple data!\n" 1378 msg += "Please select one.\n" 1360 1379 from pr_widgets import DataDialog 1361 dlg = DataDialog(data_list=data_ list, text=msg)1380 dlg = DataDialog(data_list=data_1d_list, text=msg) 1362 1381 if dlg.ShowModal() == wx.ID_OK: 1363 1382 data = dlg.get_data() 1364 1383 if data is None: 1384 msg += "PrView receives no data. \n" 1385 wx.PostEvent(self.parent, 1386 StatusEvent(status=msg, info='error')) 1365 1387 return 1366 1388 if issubclass(data.__class__, Data1D): -
inversionview/src/sans/perspectives/pr/pr_widgets.py
r11f5196 r3ecaa2b 17 17 import os 18 18 from wx.lib.scrolledpanel import ScrolledPanel 19 20 WIDTH = 400 21 HEIGHT = 350 22 23 24 class DialogPanel(ScrolledPanel): 25 def __init__(self, *args, **kwds): 26 ScrolledPanel.__init__(self, *args, **kwds) 27 self.SetupScrolling() 28 29 19 30 class PrTextCtrl(wx.TextCtrl): 20 31 """ … … 120 131 return self._complete_path 121 132 133 134 135 136 def load_error(error=None): 137 """ 138 Pop up an error message. 139 140 :param error: details error message to be displayed 141 """ 142 message = "The data file you selected could not be loaded.\n" 143 message += "Make sure the content of your file is properly formatted.\n\n" 144 145 if error is not None: 146 message += "When contacting the DANSE team, mention the" 147 message += " following:\n%s" % str(error) 148 149 dial = wx.MessageDialog(None, message, 'Error Loading File', 150 wx.OK | wx.ICON_EXCLAMATION) 151 dial.ShowModal() 152 153 122 154 class DataDialog(wx.Dialog): 123 155 """ … … 125 157 """ 126 158 def __init__(self, data_list, parent=None, text='', *args, **kwds): 159 kwds['size'] = (WIDTH, HEIGHT) 160 kwds['title'] = "Data Selection" 127 161 wx.Dialog.__init__(self, parent, *args, **kwds) 128 162 self.list_of_ctrl = [] 129 self._do_layout(data_list, text=text) 130 131 def _do_layout(self, data_list, text=''): 163 if not data_list: 164 return 165 self._sizer_main = wx.BoxSizer(wx.VERTICAL) 166 self._sizer_txt = wx.BoxSizer(wx.VERTICAL) 167 self._sizer_button = wx.BoxSizer(wx.HORIZONTAL) 168 self._choice_sizer = wx.GridBagSizer(5, 5) 169 self._panel = DialogPanel(self, style=wx.RAISED_BORDER, 170 size=(WIDTH-20, HEIGHT/3)) 171 self.SetSizer(self._sizer_main) 172 self.__do_layout(data_list, text=text) 173 self.Layout() 174 175 def __do_layout(self, data_list, text=''): 132 176 """ 133 177 layout the dialog … … 135 179 if not data_list or len(data_list) <= 1: 136 180 return 137 # Dialog box properties138 self.SetTitle("Data Selection")139 w = 400140 h = 200141 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 181 #add text 150 182 if text.strip() == "": 151 183 text = "This Perspective does not allow multiple data !\n" 152 184 text += "Please select only one Data.\n" 153 text_ctrl = wx.StaticText(self, -1, str(text)) 154 sizer_txt.Add(text_ctrl) 185 text_ctrl = wx.TextCtrl(self, -1, str(text), style=wx.TE_MULTILINE, 186 size=(-1, HEIGHT/3)) 187 text_ctrl.SetEditable(False) 188 self._sizer_txt.Add(text_ctrl , 1, wx.EXPAND|wx.ALL, 10) 155 189 iy = 0 156 190 ix = 0 157 rbox = wx.RadioButton( panel, -1, str(data_list[0].name),191 rbox = wx.RadioButton(self._panel, -1, str(data_list[0].name), 158 192 (10, 10), style= wx.RB_GROUP) 159 193 rbox.SetValue(True) 160 194 self.list_of_ctrl.append((rbox, data_list[0])) 161 choice_sizer.Add(rbox, (iy, ix), (1, 1),195 self._choice_sizer.Add(rbox, (iy, ix), (1, 1), 162 196 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 163 197 for i in range(1, len(data_list)): 164 198 iy += 1 165 rbox = wx.RadioButton(panel, -1, str(data_list[i].name), (10, 10)) 199 rbox = wx.RadioButton(self._panel, -1, 200 str(data_list[i].name), (10, 10)) 166 201 rbox.SetValue(False) 167 202 self.list_of_ctrl.append((rbox, data_list[i])) 168 choice_sizer.Add(rbox, (iy, ix),203 self._choice_sizer.Add(rbox, (iy, ix), 169 204 (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 170 panel.SetSizer(choice_sizer)205 self._panel.SetSizer(self._choice_sizer) 171 206 #add sizer 172 s izer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)207 self._sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 173 208 button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") 174 s izer_button.Add(button_cancel, 0,209 self._sizer_button.Add(button_cancel, 0, 175 210 wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 176 211 button_OK = wx.Button(self, wx.ID_OK, "Ok") 177 212 button_OK.SetFocus() 178 sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 213 self._sizer_button.Add(button_OK, 0, 214 wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 179 215 static_line = wx.StaticLine(self, -1) 180 216 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() 217 self._sizer_txt.Add(self._panel, 0, wx.EXPAND|wx.ALL, 5) 218 self._sizer_main.Add(self._sizer_txt, 0, wx.EXPAND|wx.ALL, 5) 219 self._sizer_main.Add(static_line, 0, wx.EXPAND, 0) 220 self._sizer_main.Add(self._sizer_button, 0, wx.EXPAND|wx.ALL, 10) 221 187 222 188 223 def get_data(self): … … 194 229 if rbox.GetValue(): 195 230 return data 196 def load_error(error=None): 197 """ 198 Pop up an error message. 199 200 :param error: details error message to be displayed 201 """ 202 message = "The data file you selected could not be loaded.\n" 203 message += "Make sure the content of your file is properly formatted.\n\n" 204 205 if error is not None: 206 message += "When contacting the DANSE team, mention the" 207 message += " following:\n%s" % str(error) 208 209 dial = wx.MessageDialog(None, message, 'Error Loading File', 210 wx.OK | wx.ICON_EXCLAMATION) 211 dial.ShowModal() 212 231 232 233 234
Note: See TracChangeset
for help on using the changeset viewer.