Changeset 2343
 Timestamp:
 Jun 24, 2016 7:35:44 PM (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIrestrGUI.py
r1988 r2343 36 36 ##### Restraints 37 37 ################################################################################ 38 def GetSelectedRows(widget): 39 '''Returns a list of selected rows. Rows can be selected, blocks of cells 40 or individual cells can be selected. The column for selected cells is ignored. 41 ''' 42 rows = widget.GetSelectedRows() 43 if not rows: 44 top = widget.GetSelectionBlockTopLeft() 45 bot = widget.GetSelectionBlockBottomRight() 46 if top and bot: 47 rows = range(top[0][0],bot[0][0]+1) 48 if not rows: 49 rows = sorted(list(set([cell[0] for cell in widget.GetSelectedCells()]))) 50 return rows 38 51 39 52 def UpdateRestraints(G2frame,data,Phases,phaseName): … … 782 795 wtBox.Add(useData,0,wx.ALIGN_CENTER_VERTICAL) 783 796 if 'Bonds' in restData or 'Angles' in restData: 784 wtBox.Add(wx.StaticText(wind,1,' Search range:'),0,wx.ALIGN_CENTER_VERTICAL)797 wtBox.Add(wx.StaticText(wind,1,' Search range:'),0,wx.ALIGN_CENTER_VERTICAL) 785 798 sRange = wx.TextCtrl(wind,1,value='%.2f'%(restData['Range']),style=wx.TE_PROCESS_ENTER,size=(50,20)) 786 799 sRange.Bind(wx.EVT_TEXT_ENTER,OnRange) 787 800 sRange.Bind(wx.EVT_KILL_FOCUS,OnRange) 788 801 wtBox.Add(sRange,0,wx.ALIGN_CENTER_VERTICAL) 802 wtBox.Add(wx.StaticText(wind,1,'(x sum(atom radii)'),0,wx.ALIGN_CENTER_VERTICAL) 789 803 return wtBox 790 804 … … 830 844 pass 831 845 wx.CallAfter(UpdateBondRestr,bondRestData) 832 846 833 847 def OnChangeValue(event): 834 rows = Bonds.GetSelectedRows()848 rows = GetSelectedRows(Bonds) 835 849 if not rows: 836 850 return … … 846 860 847 861 def OnChangeEsd(event): 848 rows = Bonds.GetSelectedRows()862 rows = GetSelectedRows(Bonds) 849 863 if not rows: 850 864 return … … 860 874 861 875 def OnDeleteRestraint(event): 862 rows = Bonds.GetSelectedRows()876 rows = GetSelectedRows(Bonds) 863 877 if not rows: 864 878 return … … 870 884 UpdateBondRestr(bondRestData) 871 885 872 BondRestr.DestroyChildren() 886 #BondRestr.DestroyChildren() 887 if BondRestr.GetSizer(): 888 BondRestr.GetSizer().Clear(True) 873 889 dataDisplay = wx.Panel(BondRestr) 874 890 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 886 902 Types = [wg.GRID_VALUE_STRING,]+4*[wg.GRID_VALUE_FLOAT+':10,3',] 887 903 if 'macro' in General['Type']: 888 colLabels = ['(res) A  (res) B','calc',' obs','esd','delt/sig']904 colLabels = ['(res) A  (res) B','calc','target','esd','delt/sig'] 889 905 for i,[indx,ops,obs,esd] in enumerate(bondList): 890 906 try: … … 902 918 bad.append(i) 903 919 else: 904 colLabels = ['A+SymOp  B+SymOp','calc',' obs','esd','delt/sig']920 colLabels = ['A+SymOp  B+SymOp','calc','target','esd','delt/sig'] 905 921 for i,[indx,ops,obs,esd] in enumerate(bondList): 906 922 try: … … 942 958 Size = mainSizer.Fit(G2frame.dataFrame) 943 959 Size[0] = 600 944 Size[1] += 50 #make room for tab960 Size[1] = min(Size[1]+50,500) #make room for tab, but not too big 945 961 BondRestr.SetSize(Size) 946 962 BondRestr.SetScrollbars(10,10,Size[0]/104,Size[1]/101) … … 962 978 963 979 def OnChangeValue(event): 964 rows = Angles.GetSelectedRows()980 rows = GetSelectedRows(Angles) 965 981 if not rows: 966 982 return … … 976 992 977 993 def OnChangeEsd(event): 978 rows = Angles.GetSelectedRows()994 rows = GetSelectedRows(Angles) 979 995 if not rows: 980 996 return … … 990 1006 991 1007 def OnDeleteRestraint(event): 992 rows = Angles.GetSelectedRows()1008 rows = GetSelectedRows(Angles) 993 1009 if not rows: 994 1010 return … … 999 1015 UpdateAngleRestr(angleRestData) 1000 1016 1001 AngleRestr.DestroyChildren() 1017 #AngleRestr.DestroyChildren() 1018 if AngleRestr.GetSizer(): 1019 AngleRestr.GetSizer().Clear(True) 1002 1020 dataDisplay = wx.Panel(AngleRestr) 1003 1021 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 1013 1031 Types = [wg.GRID_VALUE_STRING,]+4*[wg.GRID_VALUE_FLOAT+':10,2',] 1014 1032 if 'macro' in General['Type']: 1015 colLabels = ['(res) A  (res) B  (res) C','calc',' obs','esd','delt/sig']1033 colLabels = ['(res) A  (res) B  (res) C','calc','target','esd','delt/sig'] 1016 1034 for i,[indx,ops,obs,esd] in enumerate(angleList): 1017 1035 try: … … 1029 1047 bad.append(i) 1030 1048 else: 1031 colLabels = ['A+SymOp  B+SymOp  C+SymOp','calc',' obs','esd','delt/sig']1049 colLabels = ['A+SymOp  B+SymOp  C+SymOp','calc','target','esd','delt/sig'] 1032 1050 for i,[indx,ops,obs,esd] in enumerate(angleList): 1033 1051 try: … … 1071 1089 Size = mainSizer.Fit(G2frame.dataFrame) 1072 1090 Size[0] = 600 1073 Size[1] += 50 #make room for tab1091 Size[1] = min(Size[1]+50,500) #make room for tab, but not too big 1074 1092 AngleRestr.SetSize(Size) 1075 1093 AngleRestr.SetScrollbars(10,10,Size[0]/104,Size[1]/101) … … 1096 1114 1097 1115 def OnChangeEsd(event): 1098 rows = Planes.GetSelectedRows()1116 rows = GetSelectedRows(Planes) 1099 1117 if not rows: 1100 1118 return … … 1110 1128 1111 1129 def OnDeleteRestraint(event): 1112 rows = Planes.GetSelectedRows()1130 rows = GetSelectedRows(Planes) 1113 1131 if not rows: 1114 1132 return … … 1119 1137 UpdatePlaneRestr(planeRestData) 1120 1138 1121 PlaneRestr.DestroyChildren() 1139 #PlaneRestr.DestroyChildren() 1140 if PlaneRestr.GetSizer(): 1141 PlaneRestr.GetSizer().Clear(True) 1122 1142 dataDisplay = wx.Panel(PlaneRestr) 1123 1143 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 1133 1153 Types = [wg.GRID_VALUE_STRING,]+3*[wg.GRID_VALUE_FLOAT+':10,2',] 1134 1154 if 'macro' in General['Type']: 1135 colLabels = ['(res) atom','calc',' obs','esd']1155 colLabels = ['(res) atom','calc','target','esd'] 1136 1156 for i,[indx,ops,obs,esd] in enumerate(planeList): 1137 1157 try: … … 1151 1171 bad.append(i) 1152 1172 else: 1153 colLabels = ['atom+SymOp','calc',' obs','esd']1173 colLabels = ['atom+SymOp','calc','target','esd'] 1154 1174 for i,[indx,ops,obs,esd] in enumerate(planeList): 1155 1175 try: … … 1196 1216 Size = mainSizer.Fit(G2frame.dataFrame) 1197 1217 Size[0] = 600 1198 Size[1] += 50 #make room for tab1218 Size[1] = min(Size[1]+50,500) #make room for tab, but not too big 1199 1219 PlaneRestr.SetSize(Size) 1200 1220 PlaneRestr.SetScrollbars(10,10,Size[0]/104,Size[1]/101) … … 1217 1237 1218 1238 def OnDeleteRestraint(event): 1219 rows = Volumes.GetSelectedRows()1239 rows = GetSelectedRows(Volumes) 1220 1240 if not rows: 1221 1241 return … … 1227 1247 1228 1248 def OnChangeValue(event): 1229 rows = Volumes.GetSelectedRows()1249 rows = GetSelectedRows(Volumes) 1230 1250 if not rows: 1231 1251 return … … 1241 1261 1242 1262 def OnChangeEsd(event): 1243 rows = Volumes.GetSelectedRows()1263 rows = GetSelectedRows(Volumes) 1244 1264 if not rows: 1245 1265 return … … 1254 1274 UpdateChiralRestr(chiralRestData) 1255 1275 1256 ChiralRestr.DestroyChildren() 1276 #ChiralRestr.DestroyChildren() 1277 if ChiralRestr.GetSizer(): 1278 ChiralRestr.GetSizer().Clear(True) 1257 1279 dataDisplay = wx.Panel(ChiralRestr) 1258 1280 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 1268 1290 Types = [wg.GRID_VALUE_STRING,]+4*[wg.GRID_VALUE_FLOAT+':10,2',] 1269 1291 if 'macro' in General['Type']: 1270 colLabels = ['(res) O (res) A (res) B (res) C','calc',' obs','esd','delt/sig']1292 colLabels = ['(res) O (res) A (res) B (res) C','calc','target','esd','delt/sig'] 1271 1293 for i,[indx,ops,obs,esd] in enumerate(volumeList): 1272 1294 try: … … 1284 1306 bad.append(i) 1285 1307 else: 1286 colLabels = ['O+SymOp A+SymOp B+SymOp C+SymOp)','calc',' obs','esd','delt/sig']1308 colLabels = ['O+SymOp A+SymOp B+SymOp C+SymOp)','calc','target','esd','delt/sig'] 1287 1309 for i,[indx,ops,obs,esd] in enumerate(volumeList): 1288 1310 try: … … 1326 1348 Size = mainSizer.Fit(G2frame.dataFrame) 1327 1349 Size[0] = 600 1328 Size[1] += 50 #make room for tab1350 Size[1] = min(Size[1]+50,500) #make room for tab, but not too big 1329 1351 ChiralRestr.SetSize(Size) 1330 1352 ChiralRestr.SetScrollbars(10,10,Size[0]/104,Size[1]/101) … … 1346 1368 1347 1369 def OnDeleteRestraint(event): 1348 rows = Torsions.GetSelectedRows()1370 rows = GetSelectedRows(Torsions) 1349 1371 if not rows: 1350 1372 return … … 1356 1378 1357 1379 def OnChangeEsd(event): 1358 rows = Torsions.GetSelectedRows()1380 rows = GetSelectedRows(Torsions) 1359 1381 if not rows: 1360 1382 return … … 1369 1391 wx.CallAfter(UpdateTorsionRestr,torsionRestData) 1370 1392 1371 TorsionRestr.DestroyChildren() 1393 #TorsionRestr.DestroyChildren() 1394 if TorsionRestr.GetSizer(): 1395 TorsionRestr.GetSizer().Clear(True) 1372 1396 dataDisplay = wx.Panel(TorsionRestr) 1373 1397 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 1445 1469 Size = mainSizer.Fit(G2frame.dataFrame) 1446 1470 Size[0] = 600 1447 Size[1] += 50 #make room for tab1471 Size[1] = min(Size[1]+50,500) #make room for tab, but not too big 1448 1472 TorsionRestr.SetSize(Size) 1449 1473 TorsionRestr.SetScrollbars(10,10,Size[0]/104,Size[1]/101) … … 1465 1489 1466 1490 def OnDeleteRestraint(event): 1467 rows = Ramas.GetSelectedRows()1491 rows = GetSelectedRows(Ramas) 1468 1492 if not rows: 1469 1493 return … … 1475 1499 1476 1500 def OnChangeEsd(event): 1477 rows = Ramas.GetSelectedRows()1501 rows = GetSelectedRows(Ramas) 1478 1502 if not rows: 1479 1503 return … … 1488 1512 UpdateRamaRestr(ramaRestData) 1489 1513 1490 RamaRestr.DestroyChildren() 1514 #RamaRestr.DestroyChildren() 1515 if RamaRestr.GetSizer(): 1516 RamaRestr.GetSizer().Clear(True) 1491 1517 dataDisplay = wx.Panel(RamaRestr) 1492 1518 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 1566 1592 Size = mainSizer.Fit(G2frame.dataFrame) 1567 1593 Size[0] = 600 1568 Size[1] += 50 #make room for tab1594 Size[1] = min(Size[1]+50,500) #make room for tab, but not too big 1569 1595 RamaRestr.SetSize(Size) 1570 1596 RamaRestr.SetScrollbars(10,10,Size[0]/104,Size[1]/101) … … 1593 1619 1594 1620 def OnDeleteRestraint(event): 1595 rows = ChemComps.GetSelectedRows()[0] 1621 #rows = GetSelectedRows() 1622 rows = ChemComps.GetSelectedRows()[0] # why is this indexed as [0]? 1596 1623 if not rows: 1597 1624 return … … 1607 1634 1608 1635 def OnChangeValue(event): 1609 rows = ChemComps.GetSelectedRows()1636 rows = GetSelectedRows(ChemComps) 1610 1637 if not rows: 1611 1638 return … … 1623 1650 UpdateChemcompRestr(chemcompRestData) 1624 1651 1625 ChemCompRestr.DestroyChildren() 1652 #ChemCompRestr.DestroyChildren() 1653 if ChemCompRestr.GetSizer(): 1654 ChemCompRestr.GetSizer().Clear(True) 1626 1655 dataDisplay = wx.Panel(ChemCompRestr) 1627 1656 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 1639 1668 chisq = 0. 1640 1669 Types = [wg.GRID_VALUE_STRING,]+5*[wg.GRID_VALUE_FLOAT+':10,2',] 1641 colLabels = ['Atoms','mul*frac','factor','calc',' obs','esd']1670 colLabels = ['Atoms','mul*frac','factor','calc','target','esd'] 1642 1671 for i,[indx,factors,obs,esd] in enumerate(chemcompList): 1643 1672 try: … … 1695 1724 Size = mainSizer.Fit(G2frame.dataFrame) 1696 1725 Size[0] = 600 1697 Size[1] += 50 #make room for tab1726 Size[1] = min(Size[1]+50,500) #make room for tab, but not too big 1698 1727 ChemCompRestr.SetSize(Size) 1699 1728 ChemCompRestr.SetScrollbars(10,10,Size[0]/104,Size[1]/101) … … 1704 1733 1705 1734 def OnDeleteRestraint(event): 1706 rows = Textures.GetSelectedRows()1735 rows = GetSelectedRows(Textures) 1707 1736 if not rows: 1708 1737 return … … 1732 1761 wx.CallAfter(UpdateTextureRestr,textureRestData) 1733 1762 1734 TextureRestr.DestroyChildren() 1763 #TextureRestr.DestroyChildren() 1764 if TextureRestr.GetSizer(): 1765 TextureRestr.GetSizer().Clear(True) 1735 1766 dataDisplay = wx.Panel(TextureRestr) 1736 1767 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 1773 1804 Size = mainSizer.Fit(G2frame.dataFrame) 1774 1805 Size[0] = 600 1775 Size[1] += 50 #make room for tab1806 Size[1] = min(Size[1]+50,500) #make room for tab, but not too big 1776 1807 TextureRestr.SetSize(Size) 1777 1808 TextureRestr.SetScrollbars(10,10,Size[0]/104,Size[1]/101)
Note: See TracChangeset
for help on using the changeset viewer.