Changeset 051e22f in sasview for calculatorview/perspectives


Ignore:
Timestamp:
May 3, 2010 4:37:52 PM (14 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
0c0d458
Parents:
67ffb10
Message:

working on data loader

File:
1 edited

Legend:

Unmodified
Added
Removed
  • calculatorview/perspectives/calculator/data_editor.py

    r91f151a r051e22f  
    125125        data_run_txt = wx.StaticText(self, -1, 'Run : ')  
    126126        data_run_txt.SetToolTipString('')  
    127         self.data_run_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH*3/5, -1))  
    128         self.data_run_tcl.Bind(wx.EVT_TEXT_ENTER, self.on_change_run) 
     127        self.data_run_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH*3/5, -1), style=wx.TE_MULTILINE) 
    129128        hint_run = "Data's run." 
    130129        self.data_run_tcl.SetToolTipString(hint_run) 
     
    254253        self.data_cbox.Clear() 
    255254        for data in self._data: 
    256             pos = self.data_cbox.Append(str(data.filename)) 
     255            name = data.title 
     256            if data.run: 
     257                name = data.run[0] 
     258            if name.lstrip().rstrip() =="": 
     259                name = data.filename 
     260            pos = self.data_cbox.Append(str(name)) 
    257261            self.data_cbox.SetClientData(pos, data) 
    258262            self.data_cbox.SetSelection(pos) 
    259             self.data_cbox.SetStringSelection(str(data.filename))  
    260             
    261              
     263            self.data_cbox.SetStringSelection(str(name))  
     264        
    262265    def reset_panel(self): 
    263266        """ 
    264267        """ 
    265268        self.enable_data_cbox() 
     269        self.data_title_tcl.SetValue("") 
    266270        self.data_run_tcl.SetValue("") 
    267         self.data_title_tcl.SetValue("") 
    268271         
    269272    def on_select_data(self, event=None): 
     
    275278            return 
    276279        self.data_title_tcl.SetValue(str(data.title)) 
    277         for item in data.run: 
    278             self.data_run_tcl.AppendText(str(item)) 
     280        text = "" 
     281        if data.run: 
     282            for item in data.run: 
     283                text += item+"\n" 
     284        self.data_run_tcl.SetValue(str(text)) 
    279285             
    280286    def get_current_data(self): 
    281287        """ 
    282288        """ 
    283         if not self.data_cbox.IsEnabled(): 
    284             return None, None, None 
    285289        position = self.data_cbox.GetSelection()  
    286290        if position == wx.NOT_FOUND: 
     
    404408        dlg.ShowModal() 
    405409         
    406     def choose_data_file(parent, location=None): 
     410    def choose_data_file(self, location=None): 
    407411        """ 
    408412            Open a file dialog to allow loading a file 
     
    416420        wlist = '|'.join(cards) 
    417421         
    418         dlg = wx.FileDialog(parent, "Choose a file", location, "", wlist, wx.OPEN) 
     422        dlg = wx.FileDialog(self, "Choose a file", location, "", wlist, wx.OPEN) 
    419423        if dlg.ShowModal() == wx.ID_OK: 
    420424            path = dlg.GetPath() 
     
    423427        return path 
    424428     
     429     
    425430    def complete_loading(self, data=None, filename=''): 
    426431        """ 
    427432            Complete the loading and compute the slit size 
    428433        """ 
     434        self.done = True 
    429435        self._data = [] 
    430436        if data is None: 
    431437            msg = "Couldn't load data" 
    432             wx.PostEvent(self.parent.parent, StatusEvent(status=msg, type='stop')) 
     438            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="warning",type='stop')) 
    433439            return  
    434440        if not  data.__class__.__name__ == "list": 
     
    436442            self._reset_data.append(deepcopy(data)) 
    437443        else: 
    438             self._data = data 
     444            self._data = deepcopy(data) 
    439445            self._reset_data = deepcopy(data) 
    440         # set data field 
    441         self.reset_panel() 
    442446        self.set_values() 
    443          
    444447        if self.parent.parent is None: 
    445448            return  
    446449        msg = "Load Complete" 
    447         wx.PostEvent(self.parent.parent, StatusEvent(status=msg, type='stop')) 
     450        wx.PostEvent(self.parent.parent, StatusEvent(status=msg,info="info",type='stop')) 
    448451   
    449452    def set_values(self): 
     
    452455            through the panel 
    453456        """ 
    454         if self._data == []: 
    455             return  
    456         self.fill_data_combox() 
    457         self.on_select_data(event=None) 
     457        if self._data: 
     458            self.fill_data_combox() 
     459            self.on_select_data(event=None) 
    458460         
    459461    def get_data(self): 
     
    473475            Change run 
    474476        """ 
    475         data, data_name, position = self.get_current_data() 
     477        run = [] 
     478        data, data_name, position = self.get_current_data() 
     479        for i in range(self.data_run_tcl.GetNumberOfLines()): 
     480            run.append(self.data_run_tcl.GetLineText(i).lstrip().rstrip()) 
    476481        #Change data's name 
    477         run = self.data_run_tcl.GetValue().lstrip().rstrip() 
    478         if run == "": 
    479             run = [] 
     482        #run = self.data_run_tcl.GetValue().lstrip().rstrip() 
     483        
    480484        if data.run != run: 
    481485            self._notes += "Change data 's " 
    482486            self._notes += "run from %s to %s \n"%(data.run, str(run)) 
    483             data.run = [run] 
     487            data.run = run 
    484488             
    485489    def on_change_title(self, event=None): 
     
    502506        """ 
    503507        path = self.choose_data_file(location=self._default_save_location) 
    504          
    505508        if path is None: 
    506509            return  
     510        if self.parent.parent is not None: 
     511            wx.PostEvent(self.parent.parent, StatusEvent(status="Loading...",info="info", 
     512                                type="progress")) 
     513         
     514        self.done = False 
    507515        self._default_save_location = path 
    508516        try: 
     
    512520            if self.reader is not None and self.reader.isrunning(): 
    513521                self.reader.stop() 
    514             if self.parent.parent is not None: 
    515                 wx.PostEvent(self.parent.parent, StatusEvent(status="Loading...", 
    516                                 type="progress")) 
    517522            self.reader = DataReader(path=path, 
    518523                                    completefn=self.complete_loading, 
Note: See TracChangeset for help on using the changeset viewer.