Changeset 117


Ignore:
Timestamp:
Jul 16, 2010 10:19:12 AM (11 years ago)
Author:
vondreel
Message:

refactor background GUI
implement "KILL_FOCUS" for all TextCtrl?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwdGUI.py

    r94 r117  
    229229       
    230230def UpdateBackgroundGrid(self,data):
    231     if self.dataDisplay:
    232         self.dataFrame.Clear()
     231#    if self.dataDisplay:
     232    self.dataFrame.Clear()
    233233    BackId = G2gd.GetPatternTreeItemId(self,self.PatternId, 'Background')
     234    maxTerm = 9
     235    Types = [wg.GRID_VALUE_CHOICE+':chebyschev,another,more',
     236        wg.GRID_VALUE_BOOL,
     237        wg.GRID_VALUE_NUMBER+':1,'+str(maxTerm)]
     238    for i in range(maxTerm):
     239        Types.append(wg.GRID_VALUE_FLOAT+':10,3')
    234240   
    235241    def RefreshBackgroundGrid(event):
     
    253259            msg = wg.GridTableMessage(self.BackTable,
    254260                wg.GRIDTABLE_NOTIFY_COLS_DELETED,0,M-N)
    255             self.dataDisplay.ProcessTableMessage(msg)                         
     261            self.dataDisplay.ProcessTableMessage(msg)
    256262        self.PatternTree.SetItemPyData(BackId,data)
    257         UpdateBackgroundGrid(self,data)
    258263                 
    259     maxTerm = 9
    260264    self.BackTable = []
    261265    N = len(data[0])
     
    264268    rowLabels=['background']
    265269    for i in range(M): colLabels.append(str(i+1))
    266     Types = [wg.GRID_VALUE_CHOICE+':chebyschev,another,more',
    267         wg.GRID_VALUE_BOOL,
    268         wg.GRID_VALUE_NUMBER+':1,'+str(maxTerm)]
    269     for i in range(maxTerm):
    270         Types.append(wg.GRID_VALUE_FLOAT+':10,3')
    271270    self.BackTable = G2gd.Table(data,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    272271    self.dataFrame.SetLabel('Background')
     
    274273    gridPanel = wx.Panel(self.dataFrame)
    275274    self.dataDisplay = G2gd.GSGrid(gridPanel)               
     275    self.dataDisplay.SetTable(self.BackTable, True)
    276276    self.dataDisplay.Bind(wg.EVT_GRID_CELL_CHANGE, RefreshBackgroundGrid)               
    277     self.dataDisplay.SetTable(self.BackTable, True)
    278277    self.dataDisplay.SetMargins(0,0)
    279278    self.dataDisplay.AutoSizeColumns(False)
     
    372371        self.dataDisplay.SetMargins(0,0)
    373372        self.dataDisplay.AutoSizeColumns(False)
    374         print len(Types)
    375373        beg = 4
    376374        if Ka2: beg = 6
     
    508506            stVol = 25
    509507        controls[3] = stVol
     508        startVol.SetValue("%d"%(stVol))
    510509       
    511510    def OnBravais(event):
     
    517516            Zero = min(0.1,max(-0.1,float(zero.GetValue())))
    518517        except ValueError:
    519             Zero = 0.0
     518            Zero = 0.1
    520519        controls[1] = Zero
    521520        zero.SetValue("%.2f"%(Zero))
     
    738737    startVol = wx.TextCtrl(self.dataDisplay,value=str(controls[3]),style=wx.TE_PROCESS_ENTER)
    739738    startVol.Bind(wx.EVT_TEXT_ENTER,OnStartVol)
     739    startVol.Bind(wx.EVT_KILL_FOCUS,OnStartVol)
    740740    littleSizer.Add(startVol,0,wx.ALIGN_CENTER_VERTICAL)
    741741    mainSizer.Add(littleSizer,0)
     
    759759    zero = wx.TextCtrl(self.dataDisplay,value=str(controls[1]),style=wx.TE_PROCESS_ENTER)
    760760    zero.Bind(wx.EVT_TEXT_ENTER,OnZero)
     761    zero.Bind(wx.EVT_KILL_FOCUS,OnZero)
    761762    littleSizer.Add(zero,0,wx.ALIGN_CENTER_VERTICAL)
    762763    zeroVar = wx.CheckBox(self.dataDisplay,label="Vary? (not implemented)")
     
    787788            cellVal = wx.TextCtrl(self.dataDisplay,value=(fmt%(controls[6+Id])),style=wx.TE_PROCESS_ENTER)
    788789            cellVal.Bind(wx.EVT_TEXT_ENTER,OnCellChange)       
     790            cellVal.Bind(wx.EVT_KILL_FOCUS,OnCellChange)
    789791            littleSizer.Add(cellVal,0,wx.ALIGN_CENTER_VERTICAL)
    790792            cellList.append(cellVal.GetId())
Note: See TracChangeset for help on using the changeset viewer.