Changeset 2707
- Timestamp:
- Feb 15, 2017 12:49:18 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIconstrGUI.py
r2691 r2707 651 651 if not varList: 652 652 G2frame.ErrorDialog('No variables','There are no variables of type '+vartype, 653 653 parent=G2frame.dataFrame) 654 654 return 655 655 l2 = l1 = 1 … … 684 684 if not varList: 685 685 G2frame.ErrorDialog('No variables','There are no variables of type '+vartype, 686 686 parent=G2frame.dataFrame) 687 687 return 688 688 # legend = "Select variables to make equivalent (only one of the variables will be varied when all are set to be varied)" … … 697 697 if not varList: 698 698 G2frame.ErrorDialog('No variables','There are no variables of type '+vartype, 699 699 parent=G2frame.dataFrame) 700 700 return 701 701 # legend = "Select atoms to make equivalent (only one of the atom variables will be varied when all are set to be varied)" … … 710 710 if not varList: 711 711 G2frame.ErrorDialog('No variables','There are no variables of type '+vartype, 712 712 parent=G2frame.dataFrame) 713 713 return 714 714 # legend = "Select atoms to ride (only one of the atom variables will be varied when all are set to be varied)" … … 723 723 if not varList: 724 724 G2frame.ErrorDialog('No variables','There are no variables of type '+vartype, 725 725 parent=G2frame.dataFrame) 726 726 return 727 727 # legend = "Select variables to include in a new variable (the new variable will be varied when all included variables are varied)" … … 736 736 if not varList: 737 737 G2frame.ErrorDialog('No variables','There are no variables of type '+vartype, 738 738 parent=G2frame.dataFrame) 739 739 return 740 740 # legend = "Select variables to include in a constraint equation (the values will be constrainted to equal a specified constant)" … … 754 754 varListlbl = [fmt.format(i,*G2obj.VarDescr(i)) for i in varList] 755 755 dlg = G2G.G2SingleChoiceDialog(G2frame.dataFrame,'Select 1st variable:', 756 title1,varListlbl, 757 monoFont=True,size=(625,400)) 756 title1,varListlbl,monoFont=True,size=(625,400)) 758 757 dlg.CenterOnParent() 759 758 if dlg.ShowModal() == wx.ID_OK: … … 804 803 AtNames.sort() 805 804 dlg = G2G.G2SingleChoiceDialog(G2frame.dataFrame,'Select 1st atom:', 806 title1,AtNames, 807 monoFont=True,size=(625,400)) 805 title1,AtNames,monoFont=True,size=(625,400)) 808 806 dlg.CenterOnParent() 809 807 FrstAtom = '' … … 878 876 :returns: wx.Sizer created by method 879 877 ''' 878 #TODO: show symmetry generated constraints - no clue how to do this. 880 879 constSizer = wx.FlexGridSizer(0,6,0,0) 881 880 maxlen = 70 # characters before wrapping a constraint -
trunk/GSASIIgrid.py
r2698 r2707 1482 1482 def __init__(self,parent,title,parmDict,varyList,fullVaryList, 1483 1483 size=(300,430)): 1484 1484 1485 wx.Dialog.__init__(self,parent,wx.ID_ANY,title,size=size, 1485 1486 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) 1487 self.panel = wxscroll.ScrolledPanel(self) #just a dummy - gets destroyed in DrawPanel! 1488 self.parmChoice = 'Phase' 1489 self.parmDict = parmDict 1490 self.varyList = varyList 1491 self.fullVaryList = fullVaryList 1492 1493 self.parmNames = parmDict.keys() 1494 self.parmNames.sort() 1495 splitNames = [item.split(':') for item in self.parmNames if len(item) > 3 and not isinstance(self.parmDict[item],basestring)] 1496 self.globNames = [':'.join(item) for item in splitNames if not item[0] and not item[1]] 1497 self.globVars = list(set([' ',]+[item[2] for item in splitNames if not item[0] and not item[1]])) 1498 self.globVars.sort() 1499 self.hisNames = [':'.join(item) for item in splitNames if not item[0]] 1500 self.hisNums = [' ',]+list(set([item.split(':')[1] for item in self.hisNames])) 1501 if '' in self.hisNums: self.hisNums.remove('') 1502 self.hisVars = list(set([' ',]+[item[2] for item in splitNames if not item[0]])) 1503 self.hisVars.sort() 1504 self.hisNums.sort() 1505 self.phasNames = [':'.join(item) for item in splitNames if not item[1] and 'is' not in item[2]] 1506 self.phasNums = [' ',]+list(set([item.split(':')[0] for item in self.phasNames])) 1507 if '' in self.phasNums: self.phasNums.remove('') 1508 self.phasVars = list(set([' ',]+[item[2] for item in splitNames if not item[1] and 'is' not in item[2]])) 1509 self.phasVars.sort() 1510 self.phasNums.sort() 1511 self.hapNames = [':'.join(item) for item in splitNames if item[0] and item[1]] 1512 self.hapVars = list(set([' ',]+[item[2] for item in splitNames if item[0] and item[1]])) 1513 self.hapVars.sort() 1514 self.hisNum = '0' 1515 self.phasNum = '0' 1516 self.varName = ' ' 1517 self.listSel = 'Refined' 1518 self.DrawPanel() 1519 1520 1521 def DrawPanel(self): 1522 1523 def _OnParmSel(event): 1524 self.parmChoice = parmSel.GetStringSelection() 1525 self.varName = ' ' 1526 wx.CallAfter(self.DrawPanel) 1527 1528 def OnPhasSel(event): 1529 event.Skip() 1530 self.phasNum = phasSel.GetValue() 1531 self.varName = ' ' 1532 wx.CallAfter(self.DrawPanel) 1533 1534 def OnHistSel(event): 1535 event.Skip() 1536 self.hisNum = histSel.GetValue() 1537 self.varName = ' ' 1538 wx.CallAfter(self.DrawPanel) 1539 1540 def OnVarSel(event): 1541 self.varName = varSel.GetValue() 1542 self.phasNum = ' ' 1543 self.hisNum = ' ' 1544 wx.CallAfter(self.DrawPanel) 1545 1546 def OnListSel(event): 1547 self.listSel = listSel.GetStringSelection() 1548 wx.CallAfter(self.DrawPanel) 1549 1550 if self.panel: 1551 self.panel.DestroyChildren() 1486 1552 mainSizer = wx.BoxSizer(wx.VERTICAL) 1487 1488 panel = wxscroll.ScrolledPanel( 1489 self, wx.ID_ANY, 1490 #size=size, 1491 style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER) 1492 num = len(varyList) 1493 mainSizer.Add(wx.StaticText(self,wx.ID_ANY,'Number of refined variables: '+str(num))) 1494 if len(varyList) != len(fullVaryList): 1495 num = len(fullVaryList) - len(varyList) 1496 mainSizer.Add(wx.StaticText(self,wx.ID_ANY,' + '+str(num)+' parameters are varied via constraints')) 1553 num = len(self.varyList) 1554 mainSizer.Add(wx.StaticText(self.panel,label=' Number of refined variables: '+str(num)),0) 1555 if len(self.varyList) != len(self.fullVaryList): 1556 num = len(self.fullVaryList) - len(self.varyList) 1557 mainSizer.Add(wx.StaticText(self.panel,label=' + '+str(num)+' parameters are varied via constraints')) 1558 choiceDict = {'Global':self.globNames,'Phase':self.phasNames,'Phase/Histo':self.hapNames,'Histogram':self.hisNames} 1559 choice = ['Phase','Phase/Histo','Histogram'] 1560 if len(self.globNames): 1561 choice += ['Global',] 1562 parmSizer = wx.FlexGridSizer(0,3,5,5) 1563 parmSel = wx.RadioBox(self.panel,wx.ID_ANY,'Parameter type:',choices=choice, 1564 majorDimension=1,style=wx.RA_SPECIFY_COLS) 1565 parmSel.Bind(wx.EVT_RADIOBOX,_OnParmSel) 1566 parmSel.SetStringSelection(self.parmChoice) 1567 parmSizer.Add(parmSel,0) 1568 numSizer = wx.BoxSizer(wx.VERTICAL) 1569 numSizer.Add((5,25),0) 1570 if self.parmChoice in ['Phase','Phase/Histo'] and len(self.phasNums) > 1: 1571 numSizer.Add(wx.StaticText(self.panel,label='Phase'),0) 1572 phasSel = wx.ComboBox(self.panel,choices=self.phasNums,value=self.phasNum, 1573 style=wx.CB_READONLY|wx.CB_DROPDOWN) 1574 phasSel.Bind(wx.EVT_COMBOBOX,OnPhasSel) 1575 numSizer.Add(phasSel,0) 1576 if self.parmChoice in ['Histogram','Phase/Histo'] and len(self.hisNums) > 1: 1577 numSizer.Add(wx.StaticText(self.panel,label='Histogram'),0) 1578 histSel = wx.ComboBox(self.panel,choices=self.hisNums,value=self.hisNum, 1579 style=wx.CB_READONLY|wx.CB_DROPDOWN) 1580 histSel.Bind(wx.EVT_COMBOBOX,OnHistSel) 1581 # histSel = wx.TextCtrl(self.panel,size=(50,25),value='0',style=wx.TE_PROCESS_ENTER) 1582 # histSel.Bind(wx.EVT_TEXT_ENTER,OnHistSel) 1583 # histSel.Bind(wx.EVT_KILL_FOCUS,OnHistSel) 1584 numSizer.Add(histSel,0) 1585 parmSizer.Add(numSizer) 1586 varSizer = wx.BoxSizer(wx.VERTICAL) 1587 varSizer.Add(wx.StaticText(self.panel,label='Parameter')) 1588 if self.parmChoice in ['Phase',]: 1589 varSel = wx.ComboBox(self.panel,choices=self.phasVars,value=self.varName, 1590 style=wx.CB_READONLY|wx.CB_DROPDOWN) 1591 varSel.Bind(wx.EVT_COMBOBOX,OnVarSel) 1592 elif self.parmChoice in ['Histogram',]: 1593 varSel = wx.ComboBox(self.panel,choices=self.hisVars,value=self.varName, 1594 style=wx.CB_READONLY|wx.CB_DROPDOWN) 1595 varSel.Bind(wx.EVT_COMBOBOX,OnVarSel) 1596 elif self.parmChoice in ['Phase/Histo',]: 1597 varSel = wx.ComboBox(self.panel,choices=self.hapVars,value=self.varName, 1598 style=wx.CB_READONLY|wx.CB_DROPDOWN) 1599 varSel.Bind(wx.EVT_COMBOBOX,OnVarSel) 1600 if self.parmChoice != 'Global': 1601 varSizer.Add(varSel,0) 1602 parmSizer.Add(varSizer,0) 1603 mainSizer.Add(parmSizer,0) 1604 listChoice = ['All','Refined'] 1605 listSel = wx.RadioBox(self.panel,wx.ID_ANY,'Parameter type:',choices=listChoice, 1606 majorDimension=0,style=wx.RA_SPECIFY_COLS) 1607 listSel.SetStringSelection(self.listSel) 1608 listSel.Bind(wx.EVT_RADIOBOX,OnListSel) 1609 mainSizer.Add(listSel,0) 1497 1610 subSizer = wx.FlexGridSizer(cols=4,hgap=2,vgap=2) 1498 parmNames = parmDict.keys()1499 parmNames.sort()1500 1611 subSizer.Add((-1,-1)) 1501 subSizer.Add(wx.StaticText( panel,wx.ID_ANY,'Parameter name '))1502 subSizer.Add(wx.StaticText( panel,wx.ID_ANY,'refine?'))1503 subSizer.Add(wx.StaticText( panel,wx.ID_ANY,'value'),0,wx.ALIGN_RIGHT)1612 subSizer.Add(wx.StaticText(self.panel,wx.ID_ANY,'Parameter name ')) 1613 subSizer.Add(wx.StaticText(self.panel,wx.ID_ANY,'refine?')) 1614 subSizer.Add(wx.StaticText(self.panel,wx.ID_ANY,'value'),0,wx.ALIGN_RIGHT) 1504 1615 explainRefine = False 1505 for name in parmNames: 1616 time0 = time.time() 1617 for name in choiceDict[self.parmChoice]: 1506 1618 # skip entries without numerical values 1507 if isinstance(parmDict[name],basestring): continue 1619 if isinstance(self.parmDict[name],basestring): continue 1620 if 'Refined' in self.listSel and (name not in self.fullVaryList): continue 1621 if 'Phase' in self.parmChoice: 1622 if self.phasNum != ' ' and name.split(':')[0] != self.phasNum: continue 1623 if 'Histo' in self.parmChoice: 1624 if self.hisNum != ' ' and name.split(':')[1] != self.hisNum: continue 1625 if (self.varName != ' ') and (self.varName not in name): continue 1508 1626 try: 1509 value = G2py3.FormatSigFigs( parmDict[name])1627 value = G2py3.FormatSigFigs(self.parmDict[name]) 1510 1628 except TypeError: 1511 value = str( parmDict[name])+' -?' # unexpected1629 value = str(self.parmDict[name])+' -?' # unexpected 1512 1630 #continue 1513 1631 v = G2obj.getVarDescr(name) … … 1515 1633 subSizer.Add((-1,-1)) 1516 1634 else: 1517 ch = G2G.HelpButton( panel,G2obj.fmtVarDescr(name))1635 ch = G2G.HelpButton(self.panel,G2obj.fmtVarDescr(name)) 1518 1636 subSizer.Add(ch,0,wx.LEFT|wx.RIGHT|WACV|wx.ALIGN_CENTER,1) 1519 subSizer.Add(wx.StaticText( panel,wx.ID_ANY,str(name)))1520 if name in varyList:1521 subSizer.Add(wx.StaticText( panel,wx.ID_ANY,'R'))1522 elif name in fullVaryList:1523 subSizer.Add(wx.StaticText( panel,wx.ID_ANY,'C'))1637 subSizer.Add(wx.StaticText(self.panel,wx.ID_ANY,str(name))) 1638 if name in self.varyList: 1639 subSizer.Add(wx.StaticText(self.panel,wx.ID_ANY,'R')) 1640 elif name in self.fullVaryList: 1641 subSizer.Add(wx.StaticText(self.panel,wx.ID_ANY,'C')) 1524 1642 explainRefine = True 1525 1643 else: 1526 1644 subSizer.Add((-1,-1)) 1527 subSizer.Add(wx.StaticText(panel,wx.ID_ANY,value),0,wx.ALIGN_RIGHT) 1528 1529 # finish up ScrolledPanel 1530 panel.SetSizer(subSizer) 1531 panel.SetAutoLayout(1) 1532 panel.SetupScrolling() 1533 mainSizer.Add(panel,1, wx.ALL|wx.EXPAND,1) 1534 1645 subSizer.Add(wx.StaticText(self.panel,wx.ID_ANY,value),0,wx.ALIGN_RIGHT) 1646 1647 print time.time()-time0 1648 mainSizer.Add(subSizer,0) 1535 1649 if explainRefine: 1536 1650 mainSizer.Add( 1537 wx.StaticText(self,wx.ID_ANY, 1538 '"R" indicates a refined variable\n'+ 1539 '"C" indicates generated from a constraint' 1540 ), 1541 0, wx.ALL,0) 1651 wx.StaticText(self.panel,label='"R" indicates a refined variable\n'+ 1652 '"C" indicates generated from a constraint'),0, wx.ALL,0) 1542 1653 # make OK button 1543 1654 btnsizer = wx.BoxSizer(wx.HORIZONTAL) 1544 btn = wx.Button(self , wx.ID_CLOSE,"Close")1655 btn = wx.Button(self.panel, wx.ID_CLOSE,"Close") 1545 1656 btn.Bind(wx.EVT_BUTTON,self._onClose) 1546 1657 btnsizer.Add(btn) 1547 1658 mainSizer.Add(btnsizer, 0, wx.ALIGN_CENTER|wx.ALL, 5) 1548 1659 # Allow window to be enlarged but not made smaller 1549 self.SetSizer(mainSizer) 1550 self.SetMinSize(self.GetSize()) 1660 self.panel.SetSizer(mainSizer) 1661 self.panel.SetAutoLayout(1) 1662 self.panel.SetupScrolling() 1663 self.panel.SetMinSize(self.GetSize()) 1551 1664 1552 1665 def _onClose(self,event):
Note: See TracChangeset
for help on using the changeset viewer.