Ignore:
Timestamp:
Aug 11, 2016 11:54:28 AM (8 years ago)
Author:
lewis
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:
98d89df
Parents:
1a696bf
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 r0e760e9  
    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.