Changeset 2655


Ignore:
Timestamp:
Jan 22, 2017 2:35:40 PM (5 years ago)
Author:
toby
Message:

Close out grids before deleting in G2gr.SelectDataTreeItem?; save pointer to grid in G2frame.dataFrame.currentGrid (special handling for Phase tabs in OnPageChanged?); use CallAfter? for SelectDataTreeItem?; fix problem when phs Paint gets called after grid is deleted

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r2646 r2655  
    24952495                self.G2plotNB.nb.GetPage(pltNum)
    24962496            item = event.GetItem()
    2497             wx.Yield()
    2498             G2gd.SelectDataTreeItem(self,item)
     2497            wx.CallAfter(G2gd.SelectDataTreeItem,self,item)
    24992498            if self.oldFocus: # Why do this?
    25002499                self.oldFocus.SetFocus()
  • trunk/GSASIIctrls.py

    r2653 r2655  
    27382738    '''
    27392739    def __init__(self, parent, name=''):
    2740         wg.Grid.__init__(self,parent,-1,name=name)                   
    2741         #self.SetSize(parent.GetClientSize())
    2742         # above removed to speed drawing of initial grid
    2743         # does not appear to be needed
     2740        wg.Grid.__init__(self,parent,-1,name=name)
     2741        parent.TopLevelParent.currentGrid = self      # save a reference to the grid in the Frame
    27442742           
    27452743    def Clear(self):
  • trunk/GSASIIgrid.py

    r2646 r2655  
    44234423    Also Called in GSASIIphsGUI.UpdatePhaseData by OnTransform callback.
    44244424    '''
    4425     if G2frame.PickIdText == G2frame.GetTreeItemsList(item):
     4425    if G2frame.PickIdText == G2frame.GetTreeItemsList(item): # don't redo the current data tree item
    44264426        return
    4427     wx.Yield()
    44284427    oldPage = None # will be set later if already on a Phase item
    44294428    if G2frame.dataFrame:
    4430         SetDataMenuBar(G2frame)
    4431         # save comments or notebook contents before clearing the window contents
    4432         if G2frame.dataFrame.GetLabel() == 'Comments':
     4429        # save or finish processing of outstanding events
     4430        if G2frame.dataFrame.currentGrid:  # complete any open wx.Grid edits
     4431            if G2frame.dataFrame.currentGrid.IsCellEditControlEnabled(): # complete any grid edits in progress
     4432                if GSASIIpath.GetConfigValue('debug'): print 'Completing grid edit in',G2frame.dataFrame.currentGrid
     4433                G2frame.dataFrame.currentGrid.HideCellEditControl()
     4434                G2frame.dataFrame.currentGrid.DisableCellEditControl()
     4435        if G2frame.dataFrame.GetLabel() == 'Comments': # save any recently entered comments
    44334436            try:
    44344437                data = [G2frame.dataDisplay.GetValue()]
     
    44384441            except:     #clumsy but avoids dead window problem when opening another project
    44394442                pass
    4440         elif G2frame.dataFrame.GetLabel() == 'Notebook':
     4443        elif G2frame.dataFrame.GetLabel() == 'Notebook': # save any recent notebook entries
    44414444            try:
    44424445                data = [G2frame.dataDisplay.GetValue()]
     
    44564459        G2frame.dataFrame.PhaseUserSize = None
    44574460       
     4461    SetDataMenuBar(G2frame)
    44584462    G2frame.dataFrame.Raise()           
     4463    G2frame.dataFrame.currentGrid = None # this will be a pointer to a grid placed in the frame
    44594464    G2frame.PickId = item
    44604465    G2frame.PickIdText = None
  • trunk/GSASIIphsGUI.py

    r2646 r2655  
    150150    Called only from :meth:`GSASIIgrid.SelectDataTreeItem`,
    151151    which in turn is called from :meth:`GSASII.GSASII.OnDataTreeSelChanged`
    152     when a Phase tree item is selected.
     152    when a Phase tree item is selected. This creates all tabs on the page and fills
     153    their contents. Routine OnPageChanged is called each time a tab is pressed
     154    and updates the contents of the tab's page.
    153155
    154156    :param wx.frame G2frame: the main GSAS-II frame object
     
    16941696                rowLabels.append(str(i))
    16951697            atomTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    1696             Atoms.SetTable(atomTable, True)
     1698            try:
     1699                Atoms.SetTable(atomTable, True)    # Paint may be called after the Grid has been deleted
     1700            except:
     1701                return
    16971702            Atoms.frm = -1           
    16981703            colType = colLabels.index('Type')
     
    79127917        text = G2frame.dataDisplay.GetPageText(page)
    79137918        G2frame.dataDisplayPhaseText = text
    7914         G2frame.dataFrame.helpKey = text # BHT: use name of Phase tab for help lookup
     7919        G2frame.dataFrame.helpKey = text # use name of Phase tab for help lookup
     7920        G2frame.dataFrame.currentGrid = None
    79157921        if text == 'General':
    79167922            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.DataGeneral)
     
    79237929            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.AtomsMenu)
    79247930            FillAtomsGrid(Atoms)
     7931            G2frame.dataFrame.currentGrid = Atoms
    79257932        elif text == 'Layers':
    79267933            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.LayerData)
     
    79377944            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.DrawAtomsMenu)
    79387945            UpdateDrawAtoms()
     7946            G2frame.dataFrame.currentGrid = drawAtoms
    79397947            wx.CallAfter(G2plt.PlotStructure,G2frame,data,firstCall=True)
    79407948        elif text == 'RB Models':
     
    79447952            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.MapPeaksMenu)
    79457953            FillMapPeaksGrid()
     7954            G2frame.dataFrame.currentGrid = MapPeaks
    79467955            wx.CallAfter(G2plt.PlotStructure,G2frame,data,firstCall=True)
    79477956        elif text == 'MC/SA':
     
    79567965            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.PawleyMenu)
    79577966            FillPawleyReflectionsGrid()
     7967            G2frame.dataFrame.currentGrid = G2frame.PawleyRefl
    79587968        else:
    79597969            G2gd.SetDataMenuBar(G2frame)
Note: See TracChangeset for help on using the changeset viewer.