Changeset 762ee3e in sasview


Ignore:
Timestamp:
Sep 15, 2016 8:33:57 AM (2 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_Invariant, ESS_GUI_Pr_fixes, ESS_GUI_batch_fitting, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_ordering, SVCC-1
Children:
f0858b6
Parents:
2d647cf
git-author:
Lewis O'Driscoll <lewis.o'driscoll@…> (08/11/16 11:54:28)
git-committer:
Piotr Rozyczko <rozyczko@…> (09/15/16 08:33:57)
Message:

Update GUI on TEXT_EVT instead of TEXT_EVT_ENTER (closes #186)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/calculator/data_operator.py

    re871a2d r762ee3e  
    1515from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
    1616 
    17 #Control panel width  
     17#Control panel width 
    1818if sys.platform.count("win32") > 0: 
    1919    PANEL_TOP = 0 
     
    156156 
    157157        wx.EVT_TEXT_ENTER(self.data_namectr, -1, self.on_name) 
    158         wx.EVT_TEXT_ENTER(self.numberctr, -1, self.on_number) 
     158        wx.EVT_TEXT(self.numberctr, -1, self.on_number) 
    159159        wx.EVT_COMBOBOX(self.data1_cbox, -1, self.on_select_data1) 
    160160        wx.EVT_COMBOBOX(self.operator_cbox, -1, self.on_select_operator) 
     
    235235        self.name_sizer.Layout() 
    236236 
    237     def on_number(self, event=None): 
     237    def on_number(self, event=None, control=None): 
    238238        """ 
    239239        On selecting Number for Data2 
    240240        """ 
    241241        self.send_warnings('') 
    242         item = event.GetEventObject() 
     242        item = control 
     243        if item is None and event is not None: 
     244            item = event.GetEventObject() 
     245        elif item is None: 
     246            raise ValueError("Event or control must be supplied") 
    243247        text = item.GetValue().strip() 
    244248        if self.numberctr.IsShown(): 
     
    251255                except: 
    252256                    self._set_textctrl_color(self.numberctr, 'pink') 
    253                     msg = "DataOperation: Number requires a float number." 
    254                     self.send_warnings(msg, 'error') 
    255                     return 
     257                    if event is None: 
     258                        msg = "DataOperation: Number requires a float number." 
     259                        self.send_warnings(msg, 'error') 
     260                    return False 
    256261            else: 
    257262                self._set_textctrl_color(self.numberctr, self.color) 
     
    263268        self.draw_output(self.output) 
    264269        self.Refresh() 
     270        return True 
    265271 
    266272    def on_select_data1(self, event=None): 
     
    607613            wx.MessageBox(msg, 'Error') 
    608614            return 
     615        if self.numberctr.IsEnabled() and self.numberctr.IsShown(): 
     616            valid_num = self.on_number(control=self.numberctr) 
     617            if not valid_num: 
     618                return 
    609619        # send data to data manager 
    610620        self.output.name = name 
     
    731741        #add plot 
    732742        self.graph.add(plot) 
    733         #draw         
     743        #draw 
    734744        self.graph.render(self) 
    735745 
     
    985995    window = DataOperatorWindow(parent=None, data=[], title="Data Editor") 
    986996    app.MainLoop() 
    987  
Note: See TracChangeset for help on using the changeset viewer.