[3c44c66] | 1 | ################################################################################ |
---|
| 2 | #This software was developed by the University of Tennessee as part of the |
---|
| 3 | #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
| 4 | #project funded by the US National Science Foundation. |
---|
| 5 | # |
---|
| 6 | #See the license text in license.txt |
---|
| 7 | # |
---|
| 8 | #copyright 2010, University of Tennessee |
---|
| 9 | ################################################################################ |
---|
| 10 | """ |
---|
| 11 | This module provides Graphic interface for the data_manager module. |
---|
| 12 | """ |
---|
| 13 | import wx |
---|
| 14 | import sys |
---|
| 15 | import warnings |
---|
| 16 | from wx.lib.scrolledpanel import ScrolledPanel |
---|
| 17 | import wx.lib.mixins.listctrl as listmix |
---|
| 18 | from sans.guicomm.events import NewPlotEvent |
---|
| 19 | |
---|
| 20 | class CheckListCtrl(wx.ListCtrl, listmix.CheckListCtrlMixin, |
---|
| 21 | listmix.ListCtrlAutoWidthMixin): |
---|
| 22 | """ |
---|
| 23 | Check list control to be used for Data Panel |
---|
| 24 | """ |
---|
| 25 | def __init__(self, parent, *args, **kwds): |
---|
| 26 | kwds['style']= wx.LC_REPORT|wx.SUNKEN_BORDER |
---|
| 27 | wx.ListCtrl.__init__(self, parent, -1, *args, **kwds) |
---|
| 28 | listmix.CheckListCtrlMixin.__init__(self) |
---|
| 29 | listmix.ListCtrlAutoWidthMixin.__init__(self) |
---|
| 30 | |
---|
| 31 | class DataPanel(ScrolledPanel): |
---|
| 32 | """ |
---|
| 33 | This panel displays data available in the application and widgets to |
---|
| 34 | interact with data. |
---|
| 35 | """ |
---|
| 36 | def __init__(self, parent, list=[],list_of_perspective=[], *args, **kwds): |
---|
| 37 | ScrolledPanel.__init__(self, parent=parent, *args, **kwds) |
---|
| 38 | self.SetupScrolling() |
---|
| 39 | self.parent = parent |
---|
| 40 | self.manager = None |
---|
| 41 | self.owner = None |
---|
| 42 | self.list_of_data = list |
---|
| 43 | self.perspectives = [] |
---|
| 44 | |
---|
| 45 | self.define_panel_structure() |
---|
| 46 | self.layout_list() |
---|
| 47 | self.layout_selection() |
---|
| 48 | self.layout_perspective(list_of_perspective=list_of_perspective) |
---|
| 49 | self.load_list() |
---|
| 50 | self.layout_theory() |
---|
| 51 | self.layout_button() |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | def define_panel_structure(self): |
---|
| 55 | """ |
---|
| 56 | Define the skeleton of the panel |
---|
| 57 | """ |
---|
| 58 | self.vbox = wx.BoxSizer(wx.VERTICAL) |
---|
| 59 | self.sizer1 = wx.BoxSizer(wx.VERTICAL) |
---|
| 60 | |
---|
| 61 | box_description_2 = wx.StaticBox(self, -1, "Selection Patterns") |
---|
| 62 | self.boxsizer_2 = wx.StaticBoxSizer(box_description_2, wx.HORIZONTAL) |
---|
| 63 | box_description_2_2 = wx.StaticBox(self, -1, "Set Active Perspective") |
---|
| 64 | self.boxsizer_2_2 = wx.StaticBoxSizer(box_description_2_2, wx.HORIZONTAL) |
---|
| 65 | |
---|
| 66 | w, h = self.parent.GetSize() |
---|
| 67 | self.sizer2 = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 68 | self.sizer2.Add(self.boxsizer_2,1, wx.ALL, 10) |
---|
| 69 | self.sizer2.Add(self.boxsizer_2_2,1, wx.ALL, 10) |
---|
| 70 | |
---|
| 71 | box_description_3 = wx.StaticBox(self, -1,"Import to Active perspective") |
---|
| 72 | self.boxsizer_3 = wx.StaticBoxSizer(box_description_3, wx.HORIZONTAL) |
---|
| 73 | self.sizer3 = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 74 | self.sizer3.Add(self.boxsizer_3,1, wx.ALL, 10) |
---|
| 75 | |
---|
| 76 | self.sizer4 = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 77 | self.sizer5 = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 78 | |
---|
| 79 | self.sizer1.SetMinSize((w-10, h/3)) |
---|
| 80 | self.sizer2.SetMinSize((w-10, -1)) |
---|
| 81 | self.sizer3.SetMinSize((w-10, -1)) |
---|
| 82 | self.sizer4.SetMinSize((w-10, -1)) |
---|
| 83 | self.sizer5.SetMinSize((w-10, -1)) |
---|
| 84 | |
---|
| 85 | self.vbox.Add(self.sizer1) |
---|
| 86 | self.vbox.Add(self.sizer2) |
---|
| 87 | self.vbox.Add(self.sizer3) |
---|
| 88 | self.vbox.Add(wx.StaticLine(self, -1),0, wx.EXPAND, 0) |
---|
| 89 | self.vbox.Add(self.sizer4) |
---|
| 90 | self.vbox.Add(self.sizer5) |
---|
| 91 | self.SetSizer(self.vbox) |
---|
| 92 | |
---|
| 93 | def GetListCtrl(self): |
---|
| 94 | return self.list_ctrl |
---|
| 95 | |
---|
| 96 | def layout_list(self): |
---|
| 97 | """ |
---|
| 98 | Add a listcrtl in the panel |
---|
| 99 | """ |
---|
| 100 | self.list_ctrl = CheckListCtrl(parent=self) |
---|
| 101 | |
---|
| 102 | self.list_ctrl.InsertColumn(0, 'Name') |
---|
| 103 | self.list_ctrl.InsertColumn(1, 'Type') |
---|
| 104 | self.list_ctrl.InsertColumn(2, 'Date Modified') |
---|
| 105 | self.sizer1.Add(self.list_ctrl, 1, wx.EXPAND|wx.ALL, 10) |
---|
| 106 | |
---|
| 107 | def layout_perspective(self, list_of_perspective=[]): |
---|
| 108 | """ |
---|
| 109 | Layout widgets related to the list of plug-ins of the gui_manager |
---|
| 110 | """ |
---|
| 111 | self.boxsizer_2_2.Clear(True) |
---|
| 112 | self.perspectives = [] |
---|
| 113 | sizer = wx.GridBagSizer(5,5) |
---|
| 114 | |
---|
| 115 | if list_of_perspective: |
---|
| 116 | item = list_of_perspective[0].sub_menu |
---|
| 117 | rb = wx.RadioButton(self, -1, item, style=wx.RB_GROUP) |
---|
| 118 | rb.SetToolTipString("Data will be applied to this perspective") |
---|
| 119 | if hasattr(item,"set_default_perspective"): |
---|
| 120 | if item.set_default_perspective(): |
---|
| 121 | rb.SetValue(item.set_default_perspective()) |
---|
| 122 | self.Bind(wx.EVT_RADIOBUTTON, self.on_set_active_perspective, |
---|
| 123 | id=rb.GetId()) |
---|
| 124 | self.perspectives.append(rb) |
---|
| 125 | ix = 0 |
---|
| 126 | iy = 0 |
---|
| 127 | sizer.Add(rb,(iy, ix),(1,1), |
---|
| 128 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
| 129 | for index in range(1, len(list_of_perspective)): |
---|
| 130 | item = list_of_perspective[index].sub_menu |
---|
| 131 | rb = wx.RadioButton(self, -1,item) |
---|
| 132 | rb.SetToolTipString("Data will be applied to this perspective") |
---|
| 133 | self.Bind(wx.EVT_RADIOBUTTON, self.on_set_active_perspective, |
---|
| 134 | id=rb.GetId()) |
---|
| 135 | self.perspectives.append(rb) |
---|
| 136 | iy += 1 |
---|
| 137 | sizer.Add(rb,(iy, ix),(1,1), |
---|
| 138 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
| 139 | if hasattr(item,"set_default_perspective"): |
---|
| 140 | if item.set_default_perspective(): |
---|
| 141 | rb.SetValue(item.set_default_perspective()) |
---|
| 142 | else: |
---|
| 143 | rb = wx.RadioButton(self, -1, 'No Perspective', |
---|
| 144 | style=wx.RB_GROUP) |
---|
| 145 | rb.SetValue(True) |
---|
| 146 | rb.Disable() |
---|
| 147 | ix = 0 |
---|
| 148 | iy = 0 |
---|
| 149 | sizer.Add(rb,(iy, ix),(1,1), |
---|
| 150 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
| 151 | self.boxsizer_2_2.Add(sizer) |
---|
| 152 | |
---|
| 153 | |
---|
| 154 | def layout_selection(self): |
---|
| 155 | """ |
---|
| 156 | Layout widgets related to selection patterns |
---|
| 157 | """ |
---|
| 158 | sizer = wx.GridBagSizer(5,5) |
---|
| 159 | self.cb_select_data1d = wx.CheckBox(self, -1, "Select/Unselect Data 1D", |
---|
| 160 | (10, 10)) |
---|
| 161 | msg_data1d = "To check/uncheck to select/unselect all Data 1D" |
---|
| 162 | self.cb_select_data1d.SetToolTipString(msg_data1d) |
---|
| 163 | wx.EVT_CHECKBOX(self, self.cb_select_data1d.GetId(), |
---|
| 164 | self.on_select_all_data1d) |
---|
| 165 | |
---|
| 166 | self.cb_select_data2d = wx.CheckBox(self, -1, |
---|
| 167 | "Select/Unselect all Data 2D", (10, 10)) |
---|
| 168 | msg_data2d = "To check/uncheck to select/unselect all Data 2D" |
---|
| 169 | self.cb_select_data2d.SetToolTipString(msg_data2d) |
---|
| 170 | wx.EVT_CHECKBOX(self, self.cb_select_data2d.GetId(), |
---|
| 171 | self.on_select_all_data2d) |
---|
| 172 | |
---|
| 173 | self.cb_select_theory1d = wx.CheckBox(self, -1, |
---|
| 174 | "Select/Unselect all Theory 1D",(10, 10)) |
---|
| 175 | msg_theory1d = "To check/uncheck to select/unselect all Theory 1D" |
---|
| 176 | self.cb_select_theory1d.SetToolTipString(msg_theory1d) |
---|
| 177 | wx.EVT_CHECKBOX(self, self.cb_select_theory1d.GetId(), |
---|
| 178 | self.on_select_all_theory1d) |
---|
| 179 | |
---|
| 180 | self.cb_select_theory2d = wx.CheckBox(self, -1, |
---|
| 181 | "Select/Unselect all Theory 2D",(10, 10)) |
---|
| 182 | msg_theory2d = "To check/uncheck to select/unselect all Theory 2D" |
---|
| 183 | self.cb_select_theory2d.SetToolTipString(msg_theory2d) |
---|
| 184 | wx.EVT_CHECKBOX(self, self.cb_select_theory2d.GetId(), |
---|
| 185 | self.on_select_all_theory2d) |
---|
| 186 | |
---|
| 187 | self.cb_select_all = wx.CheckBox(self, -1, "Select/Unselect all", (10, 10)) |
---|
| 188 | msg_select_all = "To check/uncheck to select/unselect all" |
---|
| 189 | self.cb_select_all.SetToolTipString(msg_select_all) |
---|
| 190 | wx.EVT_CHECKBOX(self, self.cb_select_all.GetId(), self.on_select_all) |
---|
| 191 | |
---|
| 192 | iy = 0 |
---|
| 193 | ix = 0 |
---|
| 194 | sizer.Add(self.cb_select_data1d,(iy, ix),(1,1), |
---|
| 195 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
| 196 | iy += 1 |
---|
| 197 | sizer.Add(self.cb_select_data2d,(iy, ix),(1,1), |
---|
| 198 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
| 199 | iy += 1 |
---|
| 200 | sizer.Add(self.cb_select_theory1d,(iy, ix),(1,1), |
---|
| 201 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
| 202 | iy += 1 |
---|
| 203 | sizer.Add( self.cb_select_theory2d,(iy, ix),(1,1), |
---|
| 204 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
| 205 | iy += 1 |
---|
| 206 | sizer.Add(self.cb_select_all,(iy, ix),(1,1), |
---|
| 207 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
| 208 | self.boxsizer_2.Add(sizer) |
---|
| 209 | |
---|
| 210 | def layout_theory(self): |
---|
| 211 | """ |
---|
| 212 | Layout widget related to theory to import |
---|
| 213 | """ |
---|
| 214 | msg = "Import the Selected Theory\n" |
---|
| 215 | msg += "to active perspective." |
---|
| 216 | st_description = wx.StaticText(self, -1, msg) |
---|
| 217 | self.cb_theory = wx.ComboBox(self, -1) |
---|
| 218 | wx.EVT_COMBOBOX(self.cb_theory,-1, self.on_select_theory) |
---|
| 219 | |
---|
| 220 | self.boxsizer_3.AddMany([(st_description, 0, wx.ALL,10), |
---|
| 221 | (self.cb_theory, 0, wx.ALL, 10 )]) |
---|
| 222 | self.load_theory(list=[]) |
---|
| 223 | |
---|
| 224 | def layout_button(self): |
---|
| 225 | """ |
---|
| 226 | Layout widgets related to buttons |
---|
| 227 | """ |
---|
| 228 | self.bt_import = wx.Button(self, wx.NewId(), "Import", (30, 10)) |
---|
| 229 | self.bt_import.SetToolTipString("Import set of Data to active perspective") |
---|
| 230 | wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import) |
---|
| 231 | |
---|
| 232 | self.bt_plot = wx.Button(self, wx.NewId(), "Plot", (30, 10)) |
---|
| 233 | self.bt_plot.SetToolTipString("To trigger plotting") |
---|
| 234 | wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot) |
---|
| 235 | |
---|
| 236 | self.bt_close = wx.Button(self, wx.NewId(), "Close", (30, 10)) |
---|
| 237 | self.bt_close.SetToolTipString("close the current window") |
---|
| 238 | wx.EVT_BUTTON(self, self.bt_close.GetId(), self.on_close) |
---|
| 239 | |
---|
| 240 | self.sizer5.AddMany([((40,40), 0, wx.LEFT|wx.ADJUST_MINSIZE, 180 ), |
---|
| 241 | (self.bt_import, 0, wx.ALL,5), |
---|
| 242 | (self.bt_plot, 0, wx.ALL,5), |
---|
| 243 | (self.bt_close, 0, wx.ALL, 5 )]) |
---|
| 244 | |
---|
| 245 | def set_manager(self, manager): |
---|
| 246 | """ |
---|
| 247 | :param manager: object responsible of filling on empty the listcrtl of |
---|
| 248 | this panel. for sansview manager is data_manager |
---|
| 249 | """ |
---|
| 250 | self.manager = manager |
---|
| 251 | |
---|
| 252 | def set_owner(self, owner): |
---|
| 253 | """ |
---|
| 254 | :param owner: is the main widget creating this frame |
---|
| 255 | for sansview owner is gui_manager |
---|
| 256 | """ |
---|
| 257 | self.owner = owner |
---|
| 258 | |
---|
| 259 | def load_theory(self, list=[]): |
---|
| 260 | """ |
---|
| 261 | Recieve a list of theory name and fill the combobox with that list |
---|
| 262 | """ |
---|
| 263 | for theory in list: |
---|
| 264 | self.cb_theory.Append(theory) |
---|
| 265 | if list: |
---|
| 266 | self.cb_theory.Enable() |
---|
| 267 | else: |
---|
| 268 | self.cb_theory.Disable() |
---|
| 269 | |
---|
| 270 | def load_list(self, list=[]): |
---|
| 271 | """ |
---|
| 272 | Get a list of turple and store each string in these turples in |
---|
| 273 | the column of the listctrl. |
---|
| 274 | |
---|
| 275 | :param list: list of turples containing string only. |
---|
| 276 | """ |
---|
| 277 | for i in list: |
---|
| 278 | index = self.list_ctrl.InsertStringItem(sys.maxint, i[0]) |
---|
| 279 | self.list_ctrl.SetStringItem(index, 1, i[1]) |
---|
| 280 | self.list_ctrl.SetStringItem(index, 2, i[2]) |
---|
| 281 | |
---|
| 282 | def set_perspective(self, sub_menu): |
---|
| 283 | """ |
---|
| 284 | Receive the name of the current perspective and set |
---|
| 285 | the active perspective |
---|
| 286 | """ |
---|
| 287 | for item in self.perspectives: |
---|
| 288 | if item.GetLabelText()== sub_menu: |
---|
| 289 | item.SetValue(True) |
---|
| 290 | else: |
---|
| 291 | item.SetValue(False) |
---|
| 292 | |
---|
| 293 | def select_data_type(self, type='Data1D', check=False): |
---|
| 294 | """ |
---|
| 295 | check item in the list according to a type. |
---|
| 296 | :param check: if check true set checkboxes toTrue else to False |
---|
| 297 | :param type: type of data to select |
---|
| 298 | """ |
---|
| 299 | num = self.list_ctrl.GetItemCount() |
---|
| 300 | for index in range(num): |
---|
| 301 | if self.list_ctrl.GetItem(index, 1).GetText() == type: |
---|
| 302 | self.list_ctrl.CheckItem(index, check) |
---|
| 303 | |
---|
| 304 | def on_select_all_data1d(self, event): |
---|
| 305 | """ |
---|
| 306 | check/ uncheck list of all data 1D |
---|
| 307 | """ |
---|
| 308 | ctrl = event.GetEventObject() |
---|
| 309 | self.select_data_type(type='Data1D', check=ctrl.GetValue()) |
---|
| 310 | |
---|
| 311 | def on_select_all_data2d(self, event): |
---|
| 312 | """ |
---|
| 313 | check/ uncheck list of all data 2D |
---|
| 314 | """ |
---|
| 315 | ctrl = event.GetEventObject() |
---|
| 316 | self.select_data_type(type='Data2D', check=ctrl.GetValue()) |
---|
| 317 | |
---|
| 318 | def on_select_all_theory1d(self, event): |
---|
| 319 | """ |
---|
| 320 | check/ uncheck list of all theory 1D |
---|
| 321 | """ |
---|
| 322 | ctrl = event.GetEventObject() |
---|
| 323 | self.select_data_type(type='Theory1D', check=ctrl.GetValue()) |
---|
| 324 | |
---|
| 325 | def on_select_all_theory2d(self, event): |
---|
| 326 | """ |
---|
| 327 | check/ uncheck list of all theory 2D |
---|
| 328 | """ |
---|
| 329 | ctrl = event.GetEventObject() |
---|
| 330 | self.select_data_type(type='Theory2D', check=ctrl.GetValue()) |
---|
| 331 | |
---|
| 332 | def on_select_all(self, event): |
---|
| 333 | """ |
---|
| 334 | Check or uncheck all data listed |
---|
| 335 | """ |
---|
| 336 | ctrl = event.GetEventObject() |
---|
| 337 | self.cb_select_data1d.SetValue(ctrl.GetValue()) |
---|
| 338 | self.cb_select_data2d.SetValue(ctrl.GetValue()) |
---|
| 339 | self.cb_select_theory1d.SetValue(ctrl.GetValue()) |
---|
| 340 | self.cb_select_theory2d.SetValue(ctrl.GetValue()) |
---|
| 341 | num = self.list_ctrl.GetItemCount() |
---|
| 342 | for i in range(num): |
---|
| 343 | self.list_ctrl.CheckItem(i, ctrl.GetValue()) |
---|
| 344 | |
---|
| 345 | def on_select_theory(self, event): |
---|
| 346 | """ |
---|
| 347 | Select the theory to import in the active perspective |
---|
| 348 | """ |
---|
| 349 | |
---|
| 350 | def on_set_active_perspective(self, event): |
---|
| 351 | """ |
---|
| 352 | Select the active perspective |
---|
| 353 | """ |
---|
| 354 | ctrl = event.GetEventObject() |
---|
| 355 | #if ctrl. |
---|
| 356 | def set_data_helper(self): |
---|
| 357 | """ |
---|
| 358 | """ |
---|
| 359 | data_to_plot = [] |
---|
| 360 | |
---|
| 361 | num = self.list_ctrl.GetItemCount() |
---|
| 362 | for index in range(num): |
---|
| 363 | if self.list_ctrl.IsChecked(index): |
---|
| 364 | data_to_plot.append(self.list_ctrl.GetItemText(index)) |
---|
| 365 | return data_to_plot |
---|
| 366 | |
---|
| 367 | def on_import(self, event=None): |
---|
| 368 | """ |
---|
| 369 | Get all select data and set them to the current active perspetive |
---|
| 370 | """ |
---|
| 371 | data_to_plot = self.set_data_helper() |
---|
| 372 | current_perspective = None |
---|
| 373 | if self.perspectives: |
---|
| 374 | for item in self.perspectives: |
---|
| 375 | if item.GetValue(): |
---|
| 376 | current_perspective = item.GetLabelText() |
---|
| 377 | if self.manager is not None: |
---|
| 378 | self.manager.post_data(data_name_list=data_to_plot, |
---|
| 379 | perspective=current_perspective, plot=False) |
---|
| 380 | |
---|
| 381 | def on_plot(self, event=None): |
---|
| 382 | """ |
---|
| 383 | Send a list of data names to plot |
---|
| 384 | """ |
---|
| 385 | data_to_plot = self.set_data_helper() |
---|
| 386 | if self.manager is not None: |
---|
| 387 | self.manager.post_data(data_name_list=data_to_plot, plot=True) |
---|
| 388 | |
---|
| 389 | def on_close(self, event): |
---|
| 390 | """ |
---|
| 391 | Close the current panel's parent |
---|
| 392 | """ |
---|
| 393 | self.parent._onClose() |
---|
| 394 | |
---|
| 395 | |
---|
| 396 | data_list = [('Data1', 'Data1D', '07/01/2010'), |
---|
| 397 | ('Data2', 'Data2D', '07/03/2011'), |
---|
| 398 | ('Data3', 'Theory1D', '06/01/2010'), |
---|
| 399 | ('Data4', 'Theory2D', '07/01/2010'), |
---|
| 400 | ('Data5', 'Theory2D', '07/02/2010')] |
---|
| 401 | |
---|
| 402 | class DataFrame(wx.Frame): |
---|
| 403 | def __init__(self, parent=None, owner=None, manager=None, |
---|
| 404 | list_of_perspective=[],list=[], *args, **kwds): |
---|
| 405 | kwds['size'] = (500, 500) |
---|
| 406 | kwds['id'] = -1 |
---|
| 407 | kwds['title']= "Loaded Data" |
---|
| 408 | wx.Frame.__init__(self, parent=parent, *args, **kwds) |
---|
| 409 | self.parent = parent |
---|
| 410 | self.owner = owner |
---|
| 411 | self.manager = manager |
---|
| 412 | self.panel = DataPanel(parent=self, list_of_perspective=list_of_perspective) |
---|
| 413 | self.panel.load_list(list=list) |
---|
| 414 | wx.EVT_CLOSE(self, self._onClose) |
---|
| 415 | |
---|
| 416 | def set_owner(self, owner): |
---|
| 417 | """ |
---|
| 418 | :param owner: is the main widget creating this frame |
---|
| 419 | for sansview owner is gui_manager |
---|
| 420 | """ |
---|
| 421 | self.owner = owner |
---|
| 422 | self.panel.set_owner(owner=self.owner) |
---|
| 423 | |
---|
| 424 | def set_manager(self, manager): |
---|
| 425 | """ |
---|
| 426 | :param manager: object responsible of filling on empty the listcrtl of |
---|
| 427 | this panel. for sansview manager is data_manager |
---|
| 428 | |
---|
| 429 | """ |
---|
| 430 | self.manager = manager |
---|
| 431 | self.panel.set_manager(manager=self.manager) |
---|
| 432 | |
---|
| 433 | def load_list(self, list=[]): |
---|
| 434 | """ |
---|
| 435 | Fill the list inside its panel |
---|
| 436 | """ |
---|
| 437 | self.panel.load_list(list=list) |
---|
| 438 | |
---|
| 439 | def layout_perspective(self, list_of_perspective=[]): |
---|
| 440 | """ |
---|
| 441 | fill the panel with list of perspective |
---|
| 442 | """ |
---|
| 443 | self.panel.layout_perspective(list_of_perspective=list_of_perspective) |
---|
| 444 | |
---|
| 445 | def set_perspective(self, sub_menu): |
---|
| 446 | """ |
---|
| 447 | Receive the name of the current perspective and set |
---|
| 448 | the active perspective |
---|
| 449 | """ |
---|
| 450 | self.panel.set_perspective(sub_menu=sub_menu) |
---|
| 451 | def _onClose(self, event=None): |
---|
| 452 | """ |
---|
| 453 | this frame can only be hidden unless the application destroys it |
---|
| 454 | """ |
---|
| 455 | self.Hide() |
---|
| 456 | |
---|
| 457 | if __name__ == "__main__": |
---|
| 458 | app = wx.App() |
---|
| 459 | window = DataFrame(list=data_list, list_of_perspective=[]) |
---|
| 460 | window.Show(True) |
---|
| 461 | app.MainLoop() |
---|
| 462 | |
---|
| 463 | |
---|