Changeset 2656


Ignore:
Timestamp:
Jan 22, 2017 4:27:37 PM (5 years ago)
Author:
toby
Message:

Way cleaner approach to grid pointer; handles multiple grids in a frame, too.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrls.py

    r2655 r2656  
    27392739    def __init__(self, parent, name=''):
    27402740        wg.Grid.__init__(self,parent,-1,name=name)
    2741         parent.TopLevelParent.currentGrid = self      # save a reference to the grid in the Frame
     2741        if hasattr(parent.TopLevelParent,'currentGrids'):
     2742            parent.TopLevelParent.currentGrids.append(self)      # save a reference to the grid in the Frame
    27422743           
    27432744    def Clear(self):
  • trunk/GSASIIgrid.py

    r2655 r2656  
    44284428    if G2frame.dataFrame:
    44294429        # 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()
     4430        for grid in G2frame.dataFrame.currentGrids:  # complete any open wx.Grid edits
     4431            if grid.IsCellEditControlEnabled(): # complete any grid edits in progress
     4432                if GSASIIpath.GetConfigValue('debug'): print 'Completing grid edit in',grid
     4433                grid.HideCellEditControl()
     4434                grid.DisableCellEditControl()
    44354435        if G2frame.dataFrame.GetLabel() == 'Comments': # save any recently entered comments
    44364436            try:
     
    44614461    SetDataMenuBar(G2frame)
    44624462    G2frame.dataFrame.Raise()           
    4463     G2frame.dataFrame.currentGrid = None # this will be a pointer to a grid placed in the frame
     4463    G2frame.dataFrame.currentGrids = [] # this will contain pointers to a grid placed in the frame
    44644464    G2frame.PickId = item
    44654465    G2frame.PickIdText = None
  • trunk/GSASIIphsGUI.py

    r2655 r2656  
    39993999
    40004000################################################################################
    4001 ##### Atom draw routines
     4001##### Draw Atom routines
    40024002################################################################################
    40034003           
    40044004    def UpdateDrawAtoms(atomStyle=''):
    4005         def RefreshAtomGrid(event):
     4005        def RefreshDrawAtomGrid(event):
    40064006            def SetChoice(name,c,n=0):
    40074007                choice = []
     
    41724172        drawAtoms.SetColSize(colLabels.index('Style'),80)
    41734173        drawAtoms.SetColSize(colLabels.index('Color'),50)
    4174         drawAtoms.Bind(wg.EVT_GRID_CELL_CHANGE, RefreshAtomGrid)
    4175         drawAtoms.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK, RefreshAtomGrid)
    4176         drawAtoms.Bind(wg.EVT_GRID_CELL_LEFT_DCLICK, RefreshAtomGrid)
     4174        drawAtoms.Bind(wg.EVT_GRID_CELL_CHANGE, RefreshDrawAtomGrid)
     4175        drawAtoms.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK, RefreshDrawAtomGrid)
     4176        drawAtoms.Bind(wg.EVT_GRID_CELL_LEFT_DCLICK, RefreshDrawAtomGrid)
    41774177        drawAtoms.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK, RowSelect)
    41784178        for i,atom in enumerate(drawingData['Atoms']):
     
    79187918        G2frame.dataDisplayPhaseText = text
    79197919        G2frame.dataFrame.helpKey = text # use name of Phase tab for help lookup
    7920         G2frame.dataFrame.currentGrid = None
    79217920        if text == 'General':
    79227921            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.DataGeneral)
     
    79297928            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.AtomsMenu)
    79307929            FillAtomsGrid(Atoms)
    7931             G2frame.dataFrame.currentGrid = Atoms
    79327930        elif text == 'Layers':
    79337931            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.LayerData)
     
    79447942            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.DrawAtomsMenu)
    79457943            UpdateDrawAtoms()
    7946             G2frame.dataFrame.currentGrid = drawAtoms
    79477944            wx.CallAfter(G2plt.PlotStructure,G2frame,data,firstCall=True)
    79487945        elif text == 'RB Models':
     
    79527949            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.MapPeaksMenu)
    79537950            FillMapPeaksGrid()
    7954             G2frame.dataFrame.currentGrid = MapPeaks
    79557951            wx.CallAfter(G2plt.PlotStructure,G2frame,data,firstCall=True)
    79567952        elif text == 'MC/SA':
     
    79657961            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.PawleyMenu)
    79667962            FillPawleyReflectionsGrid()
    7967             G2frame.dataFrame.currentGrid = G2frame.PawleyRefl
    79687963        else:
    79697964            G2gd.SetDataMenuBar(G2frame)
Note: See TracChangeset for help on using the changeset viewer.