Changeset a03d419 in sasview
- Timestamp:
- May 13, 2011 4:08:36 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:
- e26d0db
- Parents:
- 13a63ab
- Location:
- guiframe
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/data_panel.py
r13a63ab ra03d419 23 23 from sans.guiframe.events import StatusEvent 24 24 from sans.guiframe.events import EVT_DELETE_PLOTPANEL 25 from sans.guiframe.events import NewLoadDataEvent 26 from sans.guiframe.gui_style import GUIFRAME 25 27 from DataLoader.loader import Loader 26 28 … … 236 238 """ 237 239 w, _ = self.GetSize() 240 238 241 self.bt_add = wx.Button(self, wx.NewId(), "Load Data", 239 242 size=(BUTTON_WIDTH, -1)) … … 287 290 288 291 self.sizer3.AddGrowableCol(1, 1) 289 292 self.show_data_button() 290 293 self.enable_remove() 291 294 self.enable_import() … … 582 585 def _load_data(self, event): 583 586 """ 584 Load data 585 """ 586 path = None 587 if self._default_save_location == None: 588 self._default_save_location = os.getcwd() 589 590 cards = self.loader.get_wildcards() 591 temp = [APPLICATION_WLIST] + PLUGINS_WLIST 592 for item in temp: 593 if item in cards: 594 cards.remove(item) 595 wlist = '|'.join(cards) 596 style = wx.OPEN|wx.FD_MULTIPLE 597 dlg = wx.FileDialog(self.parent, 598 "Choose a file", 599 self._default_save_location, "", 600 wlist, 601 style=style) 602 if dlg.ShowModal() == wx.ID_OK: 603 file_list = dlg.GetPaths() 604 if len(file_list) >= 0 and not(file_list[0]is None): 605 self._default_save_location = os.path.dirname(file_list[0]) 606 path = self._default_save_location 607 dlg.Destroy() 608 609 if path is None or not file_list or file_list[0] is None: 610 return 611 self._get_data(file_list) 612 613 def _get_data(self, path, format=None): 614 """ 615 """ 616 message = "" 617 log_msg = '' 618 output = {} 619 error_message = "" 620 for p_file in path: 621 basename = os.path.basename(p_file) 622 root, extension = os.path.splitext(basename) 623 if extension.lower() in EXTENSIONS: 624 log_msg = "Data Loader cannot " 625 log_msg += "load: %s\n" % str(p_file) 626 log_msg += """Please try to open that file from "open project" """ 627 log_msg += """or "open analysis" menu\n""" 628 error_message = log_msg + "\n" 629 logging.info(log_msg) 630 continue 631 632 try: 633 temp = self.loader.load(p_file, format) 634 if temp.__class__.__name__ == "list": 635 for item in temp: 636 data = self.parent.create_gui_data(item, p_file) 637 output[data.id] = data 638 else: 639 data = self.parent.create_gui_data(temp, p_file) 640 output[data.id] = data 641 message = "Loading Data..." + str(p_file) + "\n" 642 self.load_update(output=output, message=message) 643 except: 644 error = "Error while loading Data: %s\n" % str(p_file) 645 error += str(sys.exc_value) + "\n" 646 error_message = "The data file you selected could not be loaded.\n" 647 error_message += "Make sure the content of your file" 648 error_message += " is properly formatted.\n\n" 649 error_message += "When contacting the DANSE team, mention the" 650 error_message += " following:\n%s" % str(error) 651 self.load_update(output=output, message=error_message) 652 653 message = "Loading Data Complete! " 654 message += log_msg 655 self.load_complete(output=output, error_message=error_message, 656 message=message, path=path) 587 send an event to the parent to trigger load from plugin module 588 """ 589 if self.parent is not None: 590 wx.PostEvent(self.parent, NewLoadDataEvent()) 657 591 658 def load_update(self, output=None, message=""): 659 """ 660 print update on the status bar 661 """ 662 if message != "" and self.parent is not None: 663 wx.PostEvent(self.parent, StatusEvent(status=message, 664 type="progress", 665 info="warning")) 666 667 def load_complete(self, output, message="", error_message="", path=None): 668 """ 669 post message to status bar and return list of data 670 """ 671 if self.parent is not None: 672 wx.PostEvent(self.parent, StatusEvent(status=message, 673 info="warning", 674 type="stop")) 675 if error_message != "": 676 self.load_error(error_message) 677 if self.parent is not None: 678 self.parent.add_data(data_list=output) 679 592 680 593 def on_remove(self, event): 681 594 """ … … 917 830 self.selection_cbox.Disable() 918 831 919 832 def show_data_button(self): 833 """ 834 show load data and remove data button if 835 dataloader on else hide them 836 """ 837 try: 838 gui_style = self.parent.get_style() 839 style = gui_style & GUIFRAME.DATALOADER_ON 840 if style == GUIFRAME.DATALOADER_ON: 841 #self.bt_remove.Show(True) 842 self.bt_add.Show(True) 843 else: 844 #self.bt_remove.Hide() 845 self.bt_add.Hide() 846 except: 847 #self.bt_remove.Hide() 848 self.bt_add.Hide() 849 920 850 921 851 class DataFrame(wx.Frame): -
guiframe/events.py
r13a63ab ra03d419 24 24 #book mark event 25 25 (AppendBookmarkEvent, EVT_APPEND_BOOKMARK) = wx.lib.newevent.NewEvent() 26 #event to ask dataloader plugin to load data if dataloader plugin exist 27 (NewLoadDataEvent, EVT_NEW_LOAD_DATA) = wx.lib.newevent.NewEvent() 26 28 -
guiframe/gui_manager.py
rb46b1b9 ra03d419 40 40 from sans.guiframe.events import EVT_APPEND_BOOKMARK 41 41 from sans.guiframe.events import EVT_PANEL_ON_FOCUS 42 from sans.guiframe.events import EVT_NEW_LOAD_DATA 42 43 from sans.guiframe.events import StatusEvent 43 44 from sans.guiframe.events import NewPlotEvent 44 45 from sans.guiframe.gui_style import GUIFRAME 45 46 from sans.guiframe.gui_style import GUIFRAME_ID 46 from sans.guiframe.events import NewLoadedDataEvent47 #from sans.guiframe.events import NewLoadedDataEvent 47 48 from sans.guiframe.data_panel import DataPanel 48 49 from sans.guiframe.panel_base import PanelBase … … 190 191 self.Bind(EVT_PANEL_ON_FOCUS, self.set_panel_on_focus) 191 192 self.Bind(EVT_APPEND_BOOKMARK, self.append_bookmark) 192 193 193 self.Bind(EVT_NEW_LOAD_DATA, self.on_load_data) 194 195 196 def on_load_data(self, event): 197 """ 198 received an event to trigger load from data plugin 199 """ 200 if self._data_plugin is not None: 201 self._data_plugin.load_data(event) 202 194 203 def get_current_perspective(self): 195 204 """ … … 958 967 style = self.__gui_style & GUIFRAME.DATALOADER_ON 959 968 style1 = self.__gui_style & GUIFRAME.MULTIPLE_APPLICATIONS 960 if style == GUIFRAME.DATALOADER_ON: 969 970 id = wx.NewId() 971 hint_load_file = "read all analysis states save previously" 972 self._save_appl_menu = self._file_menu.Append(id, 973 '&Open Project', hint_load_file) 974 wx.EVT_MENU(self, id, self._on_open_state_project) 975 976 if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: 977 # some menu of plugin to be seen under file menu 978 hint_load_file = "Read a status files and load" 979 hint_load_file += " them into the analysis" 961 980 id = wx.NewId() 962 hint_load_file = "read all analysis states save previously"963 981 self._save_appl_menu = self._file_menu.Append(id, 964 '&Open Project', hint_load_file) 965 wx.EVT_MENU(self, id, self._on_open_state_project) 966 967 if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: 968 # some menu of plugin to be seen under file menu 969 hint_load_file = "Read a status files and load" 970 hint_load_file += " them into the analysis" 971 id = wx.NewId() 972 self._save_appl_menu = self._file_menu.Append(id, 973 '&Open Analysis', hint_load_file) 974 wx.EVT_MENU(self, id, self._on_open_state_application) 982 '&Open Analysis', hint_load_file) 983 wx.EVT_MENU(self, id, self._on_open_state_application) 975 984 976 self._file_menu.AppendSeparator() 985 self._file_menu.AppendSeparator() 986 id = wx.NewId() 987 self._file_menu.Append(id, '&Save Project', 988 'Save the state of the whole analysis') 989 wx.EVT_MENU(self, id, self._on_save_project) 990 if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: 991 #self._file_menu.AppendSeparator() 977 992 id = wx.NewId() 978 self._file_menu.Append(id, '&Save Project', 979 'Save the state of the whole analysis') 980 981 wx.EVT_MENU(self, id, self._on_save_project) 982 if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: 983 #self._file_menu.AppendSeparator() 984 id = wx.NewId() 985 self._save_appl_menu = self._file_menu.Append(id, 986 '&Save Analysis', 987 'Save state of the current active analysis panel') 988 wx.EVT_MENU(self, id, self._on_save_application) 989 990 self._file_menu.AppendSeparator() 993 self._save_appl_menu = self._file_menu.Append(id, 994 '&Save Analysis', 995 'Save state of the current active analysis panel') 996 wx.EVT_MENU(self, id, self._on_save_application) 997 998 self._file_menu.AppendSeparator() 991 999 992 1000 id = wx.NewId() -
guiframe/local_perspectives/data_loader/data_loader.py
r8cb8c89 ra03d419 57 57 menu_list = [] 58 58 data_file_hint = "load one or more data in the application" 59 menu_list = [('&Load Data File(s)', data_file_hint, self. _load_data)]59 menu_list = [('&Load Data File(s)', data_file_hint, self.load_data)] 60 60 gui_style = self.parent.get_style() 61 61 style = gui_style & GUIFRAME.MULTIPLE_APPLICATIONS … … 78 78 self._data_menu.Append(data_file_id, 79 79 '&Load Data File(s)', data_file_hint) 80 wx.EVT_MENU(self.parent, data_file_id, self. _load_data)80 wx.EVT_MENU(self.parent, data_file_id, self.load_data) 81 81 gui_style = self.parent.get_style() 82 82 style = gui_style & GUIFRAME.MULTIPLE_APPLICATIONS … … 92 92 return [(self._data_menu, 'Data')] 93 93 94 def _load_data(self, event):94 def load_data(self, event): 95 95 """ 96 96 Load data
Note: See TracChangeset
for help on using the changeset viewer.