Skip to content

Commit b7029dd

Browse files
committed
column selection for DrawAtoms now calls the corresponding DrawAtom routine (Color, Label, Style) & not using code in RefreshDrawAtomGrid - avoids a crash when changing DrawAtom colors.
1 parent d996e4b commit b7029dd

File tree

1 file changed

+40
-35
lines changed

1 file changed

+40
-35
lines changed

GSASII/GSASIIphsGUI.py

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6031,7 +6031,7 @@ def UpdateRMC(event=None):
60316031
global runFile
60326032
def OnRMCselect(event):
60336033
G2frame.RMCchoice = RMCsel.GetStringSelection()
6034-
wx.CallLater(100,UpdateRMC)
6034+
wx.CallLater(200,UpdateRMC)
60356035

60366036
def GetAtmChoice(pnl,RMCPdict):
60376037

@@ -10388,40 +10388,42 @@ def SetChoice(name,c,n=0):
1038810388
elif r < 0: #dclick on col label
1038910389
sel = -1
1039010390
if drawAtoms.GetColLabelValue(c) == 'Style':
10391-
dlg = wx.SingleChoiceDialog(G2frame,'Select','Atom drawing style',styleChoice)
10392-
if dlg.ShowModal() == wx.ID_OK:
10393-
sel = dlg.GetSelection()
10394-
parms = styleChoice[sel]
10395-
for r in range(len(atomData)):
10396-
atomData[r][c] = parms
10397-
drawAtoms.SetCellValue(r,c,parms)
10398-
FindBondsDraw(data)
10399-
# G2plt.PlotStructure(G2frame,data)
10400-
dlg.Destroy()
10391+
DrawAtomStyle(event)
10392+
# dlg = wx.SingleChoiceDialog(G2frame,'Select','Atom drawing style',styleChoice)
10393+
# if dlg.ShowModal() == wx.ID_OK:
10394+
# sel = dlg.GetSelection()
10395+
# parms = styleChoice[sel]
10396+
# for r in range(len(atomData)):
10397+
# atomData[r][c] = parms
10398+
# drawAtoms.SetCellValue(r,c,parms)
10399+
# FindBondsDraw(data)
10400+
# # G2plt.PlotStructure(G2frame,data)
10401+
# dlg.Destroy()
1040110402
elif drawAtoms.GetColLabelValue(c) == 'Label':
10402-
dlg = wx.SingleChoiceDialog(G2frame,'Select','Atom labelling style',labelChoice)
10403-
if dlg.ShowModal() == wx.ID_OK:
10404-
sel = dlg.GetSelection()
10405-
parms = labelChoice[sel]
10406-
for r in range(len(atomData)):
10407-
atomData[r][c] = parms
10408-
drawAtoms.SetCellValue(r,c,parms)
10409-
dlg.Destroy()
10403+
DrawAtomLabel(event)
10404+
# dlg = wx.SingleChoiceDialog(G2frame,'Select','Atom labelling style',labelChoice)
10405+
# if dlg.ShowModal() == wx.ID_OK:
10406+
# sel = dlg.GetSelection()
10407+
# parms = labelChoice[sel]
10408+
# for r in range(len(atomData)):
10409+
# atomData[r][c] = parms
10410+
# drawAtoms.SetCellValue(r,c,parms)
10411+
# dlg.Destroy()
1041010412
elif drawAtoms.GetColLabelValue(c) == 'Color':
10411-
colors = wx.ColourData()
10412-
colors.SetChooseFull(True)
10413-
dlg = wx.ColourDialog(G2frame.GetParent(),colors)
10414-
if dlg.ShowModal() == wx.ID_OK:
10415-
color = dlg.GetColourData().GetColour()[:3]
10416-
attr = wg.GridCellAttr() #needs to be here - gets lost if outside loop!
10417-
attr.SetReadOnly(True)
10418-
attr.SetBackgroundColour(color)
10419-
for r in range(len(atomData)):
10420-
atomData[r][c] = color
10421-
drawingData['Atoms'][r][c] = color
10422-
drawAtoms.SetAttr(r,c,attr)
10423-
UpdateDrawAtoms()
10424-
dlg.Destroy()
10413+
DrawAtomColor(event)
10414+
# colors = wx.ColourData()
10415+
# colors.SetChooseFull(True)
10416+
# dlg = wx.ColourDialog(G2frame.GetParent(),colors)
10417+
# if dlg.ShowModal() == wx.ID_OK:
10418+
# color = dlg.GetColourData().GetColour()[:3]
10419+
# dlg.Destroy()
10420+
# attr = wg.GridCellAttr() #needs to be here - gets lost if outside loop!
10421+
# attr.SetReadOnly(True)
10422+
# attr.SetBackgroundColour(color)
10423+
# for r in range(len(atomData)):
10424+
# atomData[r][c] = color
10425+
# drawingData['Atoms'][r][c] = color
10426+
# drawAtoms.SetAttr(r,c,attr)
1042510427
elif drawAtoms.GetColLabelValue(c) == 'Residue':
1042610428
SetChoice('Residue',c,3)
1042710429
elif drawAtoms.GetColLabelValue(c) == '1-letter':
@@ -10453,7 +10455,8 @@ def SetChoice(name,c,n=0):
1045310455
drawingData['Atoms'][r][c] = color
1045410456
drawAtoms.SetAttr(i,cs+2,attr)
1045510457
dlg.Destroy()
10456-
UpdateDrawAtoms()
10458+
# UpdateDrawAtoms()
10459+
wx.CallLater(100,UpdateDrawAtoms)
1045710460
G2plt.PlotStructure(G2frame,data)
1045810461

1045910462
def NextAtom(event):
@@ -10673,8 +10676,9 @@ def DrawAtomColor(event):
1067310676
colors.SetChooseFull(True)
1067410677
dlg = wx.ColourDialog(None,colors)
1067510678
if dlg.ShowModal() == wx.ID_OK:
10679+
color = dlg.GetColourData().GetColour()[:3]
1067610680
for i in range(len(atmColors)):
10677-
atmColors[i] = dlg.GetColourData().GetColour()[:3]
10681+
atmColors[i] = color
1067810682
colorDict = dict(zip(atmTypes,atmColors))
1067910683
for r in indx:
1068010684
color = colorDict[atomData[r][ct]]
@@ -10684,6 +10688,7 @@ def DrawAtomColor(event):
1068410688
drawAtoms.SetAttr(r,cs+2,attr)
1068510689
data['Drawing']['Atoms'][r][cs+2] = color
1068610690
dlg.Destroy()
10691+
UpdateDrawAtoms()
1068710692
drawAtoms.ClearSelection()
1068810693
G2plt.PlotStructure(G2frame,data)
1068910694

0 commit comments

Comments
 (0)