- Timestamp:
- Jul 6, 2017 3:09:41 PM (6 years ago)
- Location:
- branch/2frame
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branch/2frame/GSASIIconstrGUI.py
r2911 r2913 1061 1061 notebook tab. Called in :func:`OnPageChanged` 1062 1062 ''' 1063 # if panel.GetSizer(): panel.GetSizer().Clear(True) # N.B. don't use panel.DestroyChildren() 1064 # because it deletes scrollbars on Mac 1063 if panel.GetSizer(): panel.GetSizer().Clear(True) 1065 1064 Siz = wx.BoxSizer(wx.VERTICAL) 1066 1065 Siz.Add((5,5),0) … … 1776 1775 refChoice[rbId][i].sort() 1777 1776 1778 #VectorRB.DestroyChildren() # bad, deletes scrollbars on Mac! 1779 if VectorRB.GetSizer(): 1780 VectorRB.GetSizer().Clear(True) 1777 if VectorRB.GetSizer(): VectorRB.GetSizer().Clear(True) 1781 1778 VectorRBDisplay = wx.Panel(VectorRB) 1782 1779 VectorRBSizer = wx.BoxSizer(wx.VERTICAL) … … 2054 2051 refChoice[rbId][i].sort() 2055 2052 2053 if ResidueRB.GetSizer(): ResidueRB.GetSizer().Clear(True) 2056 2054 ResidueRBDisplay = wx.Panel(ResidueRB) 2057 2055 ResidueRBSizer = wx.BoxSizer(wx.VERTICAL) -
branch/2frame/GSASIIctrlGUI.py
r2911 r2913 1831 1831 wx.Dialog.__init__(self,parent,-1,title, 1832 1832 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) 1833 self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw!1833 self.panel = None 1834 1834 self.colnames = colnames 1835 1835 self.rownames = rownames … … 1846 1846 self.newflags[name][ia] = Obj.GetValue() 1847 1847 1848 self.panel.DestroyChildren() 1849 self.panel.Destroy() 1848 if self.panel: 1849 self.panel.DestroyChildren() #safe: wx.Panel 1850 self.panel.Destroy() 1850 1851 self.panel = wx.Panel(self) 1851 1852 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 1908 1909 wx.Dialog.__init__(self,parent,-1,title, 1909 1910 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) 1910 self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw!1911 self.panel = None 1911 1912 self.prompt = prompt 1912 1913 self.choices = choices … … 1923 1924 self.Draw() 1924 1925 1925 self.panel.DestroyChildren() 1926 self.panel.Destroy() 1926 if self.panel: 1927 self.panel.DestroyChildren() #safe: wx.Panel 1928 self.panel.Destroy() 1927 1929 self.panel = wx.Panel(self) 1928 1930 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 1974 1976 wx.Dialog.__init__(self,parent,-1,title, 1975 1977 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) 1976 self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw!1978 self.panel = None 1977 1979 self.limits = limits 1978 1980 self.value = value … … 1994 1996 valItem.SetValue(self.format%(self.value)) 1995 1997 1996 self.panel.Destroy()1998 if self.panel: self.panel.Destroy() 1997 1999 self.panel = wx.Panel(self) 1998 2000 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 2035 2037 wx.Dialog.__init__(self,parent,-1,title, 2036 2038 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) 2037 self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw!2039 self.panel = None 2038 2040 self.limits = limits 2039 2041 self.values = values … … 2058 2060 2059 2061 Indx = {} 2060 self.panel.Destroy()2062 if self.panel: self.panel.Destroy() 2061 2063 self.panel = wx.Panel(self) 2062 2064 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 2807 2809 self.Reset = Reset 2808 2810 self.Angle = Angle 2809 self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw!2811 self.panel = None 2810 2812 self._default(data,self.default) 2811 2813 self.Draw(self.data) … … 2829 2831 by :meth:`__init__`. 2830 2832 ''' 2831 self.panel.Destroy()2833 if self.panel: self.panel.Destroy() 2832 2834 self.panel = wx.Panel(self) 2833 2835 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 2902 2904 wx.Dialog.__init__(self,parent,wx.ID_ANY,title,size=size, 2903 2905 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) 2904 self.panel = wxscroll.ScrolledPanel(self) #just a dummy - gets destroyed in DrawPanel!2906 self.panel = wxscroll.ScrolledPanel(self) 2905 2907 self.parmChoice = 'Phase' 2906 2908 self.parmDict = parmDict … … 2965 2967 wx.CallLater(100,self.DrawPanel) 2966 2968 2967 if self.panel: 2968 #self.panel.DestroyChildren() # Bad on Mac: deletes scroll bars 2969 sizer = self.panel.GetSizer() 2970 if sizer: sizer.DeleteWindows() 2971 2972 mainSizer = wx.BoxSizer(wx.VERTICAL) 2969 if self.panel.GetSizer(): self.panel.GetSizer().Clear(True) 2970 mainSizer = self.panel.GetSizer() 2973 2971 num = len(self.varyList) 2974 2972 mainSizer.Add(wx.StaticText(self.panel,label=' Number of refined variables: '+str(num)),0) -
branch/2frame/GSASIIdataGUI.py
r2911 r2913 2918 2918 self.ExportCIF = [] 2919 2919 # 2920 self.GSASIIMenu = wx.MenuBar()2921 # create a list of all menus (appended in PrefillDataMenu)2922 self.dataMenuBars = [self.GSASIIMenu]2923 self.MacroStatusList = []2924 self.FillMainMenu(self.GSASIIMenu)2925 self. SetMenuBar(self.GSASIIMenu)2920 # Main menu now done in DataWindow._initMenus for consistency 2921 #self.GSASIIMenu = wx.MenuBar() 2922 #self.dataMenuBars = [self.GSASIIMenu] # list of all menus (added to in PrefillDataMenu) 2923 #self.FillMainMenu(self.GSASIIMenu) 2924 #self.SetMenuBar(self.GSASIIMenu) 2925 self.MacroStatusList = [] # logging 2926 2926 self.Status = self.CreateStatusBar() 2927 2927 # Bob: note different ways to display the SplitterWindow. I like the 3d effect on the Mac … … 2965 2965 self.root = self.GPXtree.root 2966 2966 2967 # debug code to fill initial window and check scroll bar works2968 #def FillWindow(panel,size=1.):2969 # sizer = panel.GetSizer()2970 # sizer.Add(wx.StaticText(panel, wx.ID_ANY, "Panel Two: long line "+int(size*40)*'*', (5,5)))2971 # for i in range(int(size*15)): sizer.Add(wx.StaticText(panel, wx.ID_ANY, "Line "+str(2+i), (5,5)))2972 # panel.Layout()2973 # panel.SendSizeEvent()2974 #FillWindow(self.dataWindow)2975 2976 2967 self.dataWindow.SetupScrolling() 2977 2968 … … 4742 4733 where the functions to be called are defined. 4743 4734 ''' 4735 # TODO: debug code ###################################################################### 4744 4736 def Bind(self,eventtype,handler,*args,**kwargs): # PATCH: debug code: catch when a menu is bind'ed to 4745 # the dataWindow this should not be done in the 2 frame version. Remove this routine eventually.4737 # the dataWindow as this should not be done in the 2 frame version. 4746 4738 if eventtype == wx.wx.EVT_MENU: 4747 4739 print 'wx.EVT_MENU Bind to dataWindow' … … 4750 4742 else: 4751 4743 wxscroll.ScrolledPanel.Bind(self,eventtype,handler,*args,**kwargs) 4752 # def Bind(self,eventtype,handler,*args,**kwargs):4753 # '''Override the Bind() function: on the Mac the binding is to4754 # the main window, so that menus operate with any window on top.4755 # For other platforms, either wrap calls that will be logged4756 # or call the default wx.Frame Bind() to bind to the menu item directly.4757 #4758 # Note that bindings can be made to objects by Id or by direct reference to the4759 # object. As a convention, when bindings are to objects, they are not logged4760 # but when bindings are by Id, they are logged.4761 # '''4762 # if sys.platform == "darwin": # mac4763 # self.Bind(eventtype,handler,*args,**kwargs)4764 # return4765 # if eventtype == wx.EVT_MENU and 'id' in kwargs:4766 ## menulabels = log.SaveMenuCommand(kwargs['id'],self,handler)4767 ## if menulabels:4768 ## #print 'intercepting bind for',handler,menulabels,kwargs['id']4769 ## wx.Window.Bind(self,eventtype,self.MenuBinding,*args,**kwargs)4770 ## return4771 # self.Bind(self,eventtype,handler,*args,**kwargs)4772 4773 4744 def DestroyChildren(self): 4774 print 'Fix this: DestroyChildren called'4745 print 'Fix this: dataWindow.DestroyChildren called' 4775 4746 G2obj.HowDidIgetHere() 4776 4747 def SetTitle(self,*args): 4748 print('Warning: attempt to label dataWindow') 4749 G2obj.HowDidIgetHere(True) 4750 self.G2frame.SetTitle(*args) 4751 def SetLabel(self,*args): 4752 print('Warning: attempt to label dataWindow') 4753 G2obj.HowDidIgetHere(True) 4754 self.G2frame.SetTitle(*args) 4755 # end TODO: remove this later ############################################################ 4756 4757 def __init__(self,parent): 4758 wxscroll.ScrolledPanel.__init__(self,parent,wx.ID_ANY,size=parent.GetSize()) 4759 self.parent = parent 4760 self._initMenus() 4761 self.currentGrids = [] 4762 self.helpKey = '' # defines help entry for current item selected in data tree 4763 4764 def ClearData(self): 4765 '''Initializes the contents of the dataWindow panel 4766 ''' 4767 #self.SetBackgroundColour(wx.WHITE) 4768 self.SetBackgroundColour(VERY_LIGHT_GREY) # BHT: I prefer a gray background. Makes TextCtrls stand out, but 4769 # a bit lighter than the splitter bar 4770 Sizer = self.GetSizer() 4771 if Sizer: 4772 Sizer.Clear(True) 4773 else: 4774 print 'No sizer in dataWindow' 4775 if GSASIIpath.GetConfigValue('debug'): raise Exception 4776 4777 def SetDataSize(self): 4778 '''Sizes the contents of the dataWindow panel 4779 ''' 4780 Sizer = self.GetSizer() 4781 if GSASIIpath.GetConfigValue('debug') and not Sizer: 4782 print 'No sizer in dataWindow' 4783 raise Exception 4784 self.Layout() 4785 self.SendSizeEvent() 4786 4777 4787 def PrefillDataMenu(self,menu,empty=False): 4778 4788 '''Create the "standard" part of data frame menus & add the dataWindow menu headings … … 4796 4806 menu.Append(menu=HelpMenu,title='&Help') 4797 4807 4798 def _initMenus _(self):4808 def _initMenus(self): 4799 4809 'define all GSAS-II data window menus' 4800 4801 # for use where no menu or data frame help is provided 4802 self.BlankMenu = wx.MenuBar() 4803 4810 4811 # Main menu 4812 G2frame = self.GetTopLevelParent() 4813 G2frame.GSASIIMenu = wx.MenuBar() 4814 G2frame.dataMenuBars = [G2frame.GSASIIMenu] # list of all menus (added to in PrefillDataMenu) 4815 G2frame.FillMainMenu(G2frame.GSASIIMenu) 4816 G2frame.SetMenuBar(G2frame.GSASIIMenu) 4817 4804 4818 # Controls 4805 4819 self.ControlsMenu = wx.MenuBar() … … 5100 5114 self.InstEdit.Append(id=wxID_INST1VAL, kind=wx.ITEM_NORMAL,text='Set one value', 5101 5115 help='Set one instrument parameter value across multiple histograms') 5102 5103 5116 self.PostfillDataMenu() 5104 5117 … … 5732 5745 # end of GSAS-II menu definitions 5733 5746 5734 def __init__(self,parent):5735 wxscroll.ScrolledPanel.__init__(self,parent,wx.ID_ANY,size=parent.GetSize())5736 self.parent = parent5737 self._initMenus_()5738 self.currentGrids = []5739 self.helpKey = '' # defines help entry for current item selected in data tree5740 5741 def ClearData(self):5742 '''Initializes the contents of the dataWindow panel5743 '''5744 #self.SetBackgroundColour(wx.WHITE) # BHT: I prefer a gray background. Makes TextCtrls stand out5745 self.SetBackgroundColour(VERY_LIGHT_GREY) # BHT: I prefer a gray background. Makes TextCtrls stand out, but5746 # a bit lighter than the splitter bar5747 5748 Sizer = self.GetSizer()5749 if Sizer:5750 Sizer.Clear(True)5751 else:5752 print 'No sizer in dataWindow'5753 if GSASIIpath.GetConfigValue('debug'): raise Exception5754 5755 def SetDataSize(self):5756 '''Sizes the contents of the dataWindow panel5757 '''5758 Sizer = self.GetSizer()5759 if GSASIIpath.GetConfigValue('debug') and not Sizer:5760 print 'No sizer in dataWindow'5761 raise Exception5762 self.Layout()5763 self.SendSizeEvent()5764 5765 # TODO: remove this later5766 def SetTitle(self,*args):5767 print('Warning: attempt to label dataWindow')5768 G2obj.HowDidIgetHere()5769 self.G2frame.SetTitle(*args)5770 def SetTitle(self,*args):5771 print('Warning: attempt to label dataWindow')5772 G2obj.HowDidIgetHere()5773 self.G2frame.SetTitle(*args)5774 5775 5747 5776 5748 #TODO - remove … … 7742 7714 if G2frame.dataDisplay: 7743 7715 oldPage = G2frame.dataDisplay.GetSelection() 7744 #G2frame.SetLabel(G2frame.GetLabel().split('||')[0]+' || '+'')7745 7716 G2frame.SetLabel('') 7746 7717 -
branch/2frame/GSASIIphsGUI.py
r2912 r2913 1244 1244 """ 1245 1245 # UpdateGeneral execution starts here 1246 #General.DestroyChildren() # bad, deletes scrollbars on Mac! 1247 if General.GetSizer(): 1248 General.GetSizer().Clear(True) 1246 if General.GetSizer(): General.GetSizer().Clear(True) 1249 1247 phaseTypes = ['nuclear','magnetic','macromolecular','faulted'] 1250 1248 SetupGeneral() … … 6345 6343 6346 6344 # UpdateTexture executable starts here 6347 #Texture.DestroyChildren() # bad, deletes scrollbars on Mac! 6348 if Texture.GetSizer(): 6349 Texture.GetSizer().Clear(True) 6345 if Texture.GetSizer(): Texture.GetSizer().Clear(True) 6350 6346 G2frame.GetStatusBar().SetStatusText('') 6351 6347 generalData = data['General'] … … 7097 7093 # FillRigidBodyGrid executable code starts here 7098 7094 if refresh: 7099 #RigidBodies.DestroyChildren() # bad, deletes scrollbars on Mac! 7100 if RigidBodies.GetSizer(): 7101 RigidBodies.GetSizer().Clear(True) 7095 if RigidBodies.GetSizer(): RigidBodies.GetSizer().Clear(True) 7102 7096 general = data['General'] 7103 7097 cx,ct,cs,cia = general['AtomPtrs'] … … 7373 7367 G2plt.PlotStructure(G2frame,data) 7374 7368 7375 #RigidBodies.DestroyChildren() # bad, deletes scrollbars on Mac! 7376 if RigidBodies.GetSizer(): 7377 RigidBodies.GetSizer().Clear(True) 7369 if RigidBodies.GetSizer(): RigidBodies.GetSizer().Clear(True) 7378 7370 mainSizer = wx.BoxSizer(wx.VERTICAL) 7379 7371 mainSizer.Add((5,5),0) … … 7993 7985 7994 7986 # UpdateMCSA executable code starts here 7995 #G2frame.MCSA.DestroyChildren() # bad, deletes scrollbars on Mac! 7996 if G2frame.MCSA.GetSizer(): 7997 G2frame.MCSA.GetSizer().Clear(True) 7987 if G2frame.MCSA.GetSizer(): G2frame.MCSA.GetSizer().Clear(True) 7998 7988 if not data['Drawing']: #if new drawing - no drawing data! 7999 7989 SetupDrawingData() … … 9171 9161 G2frame.phaseDisplay.gridList = [] # list of all grids in notebook 9172 9162 Pages = [] 9173 G2frame.phaseDisplay.gridList = []9174 9163 General = wx.ScrolledWindow(G2frame.phaseDisplay) 9175 9164 G2frame.phaseDisplay.AddPage(General,'General') -
branch/2frame/GSASIIplot.py
r2911 r2913 320 320 self.plotList = [] 321 321 self.panelList = [] 322 self.status.DestroyChildren() 322 self.status.DestroyChildren() #get rid of special stuff on status bar 323 323 324 324 def Rename(self,oldName,newName): … … 1862 1862 (G2frame,newPlot,plotType),kwargs) 1863 1863 # now start plotting 1864 G2frame.G2plotNB.status.DestroyChildren() 1864 G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar 1865 1865 Page.tickDict = {} 1866 1866 DifLine = [''] … … 2357 2357 if ref[6+im] > 0.: 2358 2358 DS.append((ref[5+im]-ref[7+im])/ref[6+im]) 2359 G2frame.G2plotNB.status.DestroyChildren() 2359 G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar 2360 2360 DS.sort() 2361 2361 EDS = np.zeros_like(DS) … … 2579 2579 Page.Offset = [0,0] 2580 2580 2581 G2frame.G2plotNB.status.DestroyChildren() 2581 G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar 2582 2582 if Peaks == None: 2583 2583 if G2frame.Contour: … … 2799 2799 2800 2800 Page.Choice = None 2801 G2frame.G2plotNB.status.DestroyChildren() 2801 G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar 2802 2802 Plot.set_title(Title) 2803 2803 Plot.set_xlabel(r'd-spacing',fontsize=14) … … 3047 3047 Page.keyPress = OnKeyPress 3048 3048 Page.SetFocus() 3049 G2frame.G2plotNB.status.DestroyChildren() 3049 G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar 3050 3050 Nxy = Z.shape 3051 3051 Zmax = np.max(Z) … … 3105 3105 3106 3106 Page.Choice = None 3107 G2frame.G2plotNB.status.DestroyChildren() 3107 G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar 3108 3108 Plot.set_title('Strain') 3109 3109 Plot.set_ylabel(r'd-spacing',fontsize=14) … … 3870 3870 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 3871 3871 Page.canvas.mpl_connect('key_press_event', OnPlotKeyPress) 3872 G2frame.G2plotNB.status.DestroyChildren() 3872 G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar 3873 3873 General = data['General'] 3874 3874 cx,ct,cs,cia = General['AtomPtrs'] … … 3956 3956 title = G2obj.StripUnicode(' for\n'+Data['title'],'') # matplotlib 1.x does not like unicode 3957 3957 newAtomDict = Data.get('newAtomDict',{}) 3958 G2frame.G2plotNB.status.DestroyChildren() 3958 G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar 3959 3959 3960 3960 def OnPlotKeyPress(event): … … 5079 5079 Page.Choice = None 5080 5080 Title = G2frame.GPXtree.GetItemText(G2frame.Image)[4:] 5081 G2frame.G2plotNB.status.DestroyChildren() 5081 G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar 5082 5082 if G2frame.logPlot: 5083 5083 Title = 'log('+Title+')' -
branch/2frame/GSASIIpwdGUI.py
r2912 r2913 1344 1344 mainSizer.Add(ExclSizer()) 1345 1345 1346 #if G2frame.dataWindow:1347 # G2frame.dataWindow.DestroyChildren()1348 1346 G2frame.ifGetExclude = False 1349 1347 G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.LimitMenu) -
branch/2frame/GSASIIrestrGUI.py
r2912 r2913 32 32 33 33 VERY_LIGHT_GREY = wx.Colour(235,235,235) 34 TabSelectionIdDict = {} 34 35 35 36 ################################################################################ … … 54 55 data tree 55 56 ''' 56 if not Phases:57 print 'There are no phases to form restraints'58 return59 if not len(Phases):60 print 'There are no phases to form restraints'61 return62 phasedata = Phases[phaseName]63 if phaseName not in data:64 data[phaseName] = {}65 restrData = data[phaseName]66 if 'Bond' not in restrData:67 restrData['Bond'] = {'wtFactor':1.0,'Range':1.1,'Bonds':[],'Use':True}68 if 'Angle' not in restrData:69 restrData['Angle'] = {'wtFactor':1.0,'Range':0.85,'Angles':[],'Use':True}70 if 'Plane' not in restrData:71 restrData['Plane'] = {'wtFactor':1.0,'Planes':[],'Use':True}72 if 'Chiral' not in restrData:73 restrData['Chiral'] = {'wtFactor':1.0,'Volumes':[],'Use':True}74 if 'Torsion' not in restrData:75 restrData['Torsion'] = {'wtFactor':1.0,'Coeff':{},'Torsions':[],'Use':True}76 if 'Rama' not in restrData:77 restrData['Rama'] = {'wtFactor':1.0,'Coeff':{},'Ramas':[],'Use':True}78 if 'Texture' not in restrData:79 restrData['Texture'] = {'wtFactor':1.0,'HKLs':[],'Use':True}80 if 'ChemComp' not in restrData:81 restrData['ChemComp'] = {'wtFactor':1.0,'Sites':[],'Use':True}82 General = phasedata['General']83 Cell = General['Cell'][1:7] #skip flag & volume84 Amat,Bmat = G2lat.cell2AB(Cell)85 SGData = General['SGData']86 cx,ct,cs,cia = General['AtomPtrs']87 Atoms = phasedata['Atoms']88 AtLookUp = G2mth.FillAtomLookUp(Atoms,cia+8)89 if 'macro' in General['Type']:90 Names = [atom[0]+':'+atom[1]+atom[2]+' '+atom[3] for atom in Atoms]91 Ids = []92 Coords = []93 Types = []94 else:95 Names = ['all '+ name for name in General['AtomTypes']]96 iBeg = len(Names)97 Types = [name for name in General['AtomTypes']]98 Coords = [ [] for type in Types]99 Ids = [ 0 for type in Types]100 Names += [atom[ct-1] for atom in Atoms]101 Types += [atom[ct] for atom in Atoms]102 Coords += [atom[cx:cx+3] for atom in Atoms]103 Ids += [atom[cia+8] for atom in Atoms]104 rama = G2data.ramachandranDist['All']105 ramaName = 'All'106 57 107 58 def OnSelectPhase(event): … … 858 809 UpdateBondRestr(bondRestData) 859 810 860 BondRestr.DestroyChildren() 861 # if BondRestr.GetSizer(): 862 # BondRestr.GetSizer().Clear(True) 811 if BondRestr.GetSizer(): BondRestr.GetSizer().Clear(True) 863 812 mainSizer = wx.BoxSizer(wx.VERTICAL) 864 813 mainSizer.Add((5,5),0) … … 994 943 UpdateAngleRestr(angleRestData) 995 944 996 AngleRestr.DestroyChildren() 997 # if AngleRestr.GetSizer(): 998 # AngleRestr.GetSizer().Clear(True) 945 if AngleRestr.GetSizer(): 946 AngleRestr.GetSizer().Clear(True) 999 947 mainSizer = wx.BoxSizer(wx.VERTICAL) 1000 948 mainSizer.Add((5,5),0) … … 1116 1064 UpdatePlaneRestr(planeRestData) 1117 1065 1118 PlaneRestr.DestroyChildren() 1119 # if PlaneRestr.GetSizer(): 1120 # PlaneRestr.GetSizer().Clear(True) 1066 if PlaneRestr.GetSizer(): 1067 PlaneRestr.GetSizer().Clear(True) 1121 1068 mainSizer = wx.BoxSizer(wx.VERTICAL) 1122 1069 mainSizer.Add((5,5),0) … … 1252 1199 UpdateChiralRestr(chiralRestData) 1253 1200 1254 ChiralRestr.DestroyChildren() 1255 # if ChiralRestr.GetSizer(): 1256 # ChiralRestr.GetSizer().Clear(True) 1201 if ChiralRestr.GetSizer(): ChiralRestr.GetSizer().Clear(True) 1257 1202 mainSizer = wx.BoxSizer(wx.VERTICAL) 1258 1203 mainSizer.Add((5,5),0) … … 1369 1314 wx.CallAfter(UpdateTorsionRestr,torsionRestData) 1370 1315 1371 TorsionRestr.DestroyChildren() 1372 # if TorsionRestr.GetSizer(): 1373 # TorsionRestr.GetSizer().Clear(True) 1316 if TorsionRestr.GetSizer(): TorsionRestr.GetSizer().Clear(True) 1374 1317 mainSizer = wx.BoxSizer(wx.VERTICAL) 1375 1318 mainSizer.Add((5,5),0) … … 1490 1433 UpdateRamaRestr(ramaRestData) 1491 1434 1492 RamaRestr.DestroyChildren() 1493 # if RamaRestr.GetSizer(): 1494 # RamaRestr.GetSizer().Clear(True) 1435 if RamaRestr.GetSizer(): RamaRestr.GetSizer().Clear(True) 1495 1436 mainSizer = wx.BoxSizer(wx.VERTICAL) 1496 1437 mainSizer.Add((5,5),0) … … 1629 1570 UpdateChemcompRestr(chemcompRestData) 1630 1571 1631 ChemCompRestr.DestroyChildren() 1632 # if ChemCompRestr.GetSizer(): 1633 # ChemCompRestr.GetSizer().Clear(True) 1572 if ChemCompRestr.GetSizer(): ChemCompRestr.GetSizer().Clear(True) 1634 1573 mainSizer = wx.BoxSizer(wx.VERTICAL) 1635 1574 mainSizer.Add((5,5),0) … … 1739 1678 wx.CallAfter(UpdateTextureRestr,textureRestData) 1740 1679 1741 TextureRestr.DestroyChildren()1680 if TextureRestr.GetSizer(): TextureRestr.GetSizer().Clear(True) 1742 1681 mainSizer = wx.BoxSizer(wx.VERTICAL) 1743 1682 mainSizer.Add((5,5),0) … … 1783 1722 1784 1723 def OnPageChanged(event): 1785 #print 'OnPageChanged'1786 1724 page = event.GetSelection() 1787 1725 #G2frame.restrBook.SetSize(G2frame.dataWindow.GetClientSize()) #TODO -almost right … … 1855 1793 # except ValueError: 1856 1794 # print('Unexpected event in RaisePage') 1857 # 1858 G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.RestraintMenu) 1859 #G2frame.SetLabel(G2frame.GetLabel().split('||')[0]+' || '+'restraints for '+phaseName) 1860 G2frame.SetTitle('restraints for '+phaseName) 1861 #G2frame.restrBook = G2G.GSNoteBook(parent=G2frame.dataWindow,size=G2frame.dataWindow.GetClientSize()) 1862 G2frame.restrBook = G2G.GSNoteBook(parent=G2frame.dataWindow) 1863 G2frame.dataWindow.GetSizer().Add(G2frame.restrBook,1,wx.ALL|wx.EXPAND,1) 1864 1795 # 1796 def OnSelectPage(event): 1797 'Called when an item is selected from the Select page menu' 1798 # lookup the menu item that called us and get its text 1799 tabname = TabSelectionIdDict.get(event.GetId()) 1800 if not tabname: 1801 print 'Warning: menu item not in dict! id=',event.GetId() 1802 return 1803 # find the matching tab 1804 for PageNum in range(G2frame.restrBook.GetPageCount()): 1805 if tabname == G2frame.restrBook.GetPageText(PageNum): 1806 G2frame.restrBook.SetSelection(PageNum) 1807 return 1808 else: 1809 print "Warning: tab "+tabname+" was not found" 1810 1811 # UpdateRestraints execution starts here 1812 if not Phases: 1813 print 'There are no phases to form restraints' 1814 return 1815 if not len(Phases): 1816 print 'There are no phases to form restraints' 1817 return 1818 phasedata = Phases[phaseName] 1819 if phaseName not in data: 1820 data[phaseName] = {} 1821 restrData = data[phaseName] 1822 if 'Bond' not in restrData: 1823 restrData['Bond'] = {'wtFactor':1.0,'Range':1.1,'Bonds':[],'Use':True} 1824 if 'Angle' not in restrData: 1825 restrData['Angle'] = {'wtFactor':1.0,'Range':0.85,'Angles':[],'Use':True} 1826 if 'Plane' not in restrData: 1827 restrData['Plane'] = {'wtFactor':1.0,'Planes':[],'Use':True} 1828 if 'Chiral' not in restrData: 1829 restrData['Chiral'] = {'wtFactor':1.0,'Volumes':[],'Use':True} 1830 if 'Torsion' not in restrData: 1831 restrData['Torsion'] = {'wtFactor':1.0,'Coeff':{},'Torsions':[],'Use':True} 1832 if 'Rama' not in restrData: 1833 restrData['Rama'] = {'wtFactor':1.0,'Coeff':{},'Ramas':[],'Use':True} 1834 if 'Texture' not in restrData: 1835 restrData['Texture'] = {'wtFactor':1.0,'HKLs':[],'Use':True} 1836 if 'ChemComp' not in restrData: 1837 restrData['ChemComp'] = {'wtFactor':1.0,'Sites':[],'Use':True} 1838 General = phasedata['General'] 1839 Cell = General['Cell'][1:7] #skip flag & volume 1840 Amat,Bmat = G2lat.cell2AB(Cell) 1841 SGData = General['SGData'] 1842 cx,ct,cs,cia = General['AtomPtrs'] 1843 Atoms = phasedata['Atoms'] 1844 AtLookUp = G2mth.FillAtomLookUp(Atoms,cia+8) 1845 if 'macro' in General['Type']: 1846 Names = [atom[0]+':'+atom[1]+atom[2]+' '+atom[3] for atom in Atoms] 1847 Ids = [] 1848 Coords = [] 1849 Types = [] 1850 else: 1851 Names = ['all '+ name for name in General['AtomTypes']] 1852 iBeg = len(Names) 1853 Types = [name for name in General['AtomTypes']] 1854 Coords = [ [] for type in Types] 1855 Ids = [ 0 for type in Types] 1856 Names += [atom[ct-1] for atom in Atoms] 1857 Types += [atom[ct] for atom in Atoms] 1858 Coords += [atom[cx:cx+3] for atom in Atoms] 1859 Ids += [atom[cia+8] for atom in Atoms] 1860 rama = G2data.ramachandranDist['All'] 1861 ramaName = 'All' 1862 G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.RestraintMenu) 1865 1863 G2frame.dataWindow.RestraintEdit.Enable(G2gd.wxID_RESTSELPHASE,False) 1866 1864 if len(Phases) > 1: … … 1873 1871 G2frame.Bind(wx.EVT_MENU, OnPlotAARestraint, id=G2gd.wxID_AARESTRAINTPLOT) 1874 1872 1873 # GUI defined here 1874 G2frame.SetTitle('restraints for '+phaseName) 1875 #G2frame.restrBook = G2G.GSNoteBook(parent=G2frame.dataWindow,size=G2frame.dataWindow.GetClientSize()) 1876 G2frame.restrBook = G2G.GSNoteBook(parent=G2frame.dataWindow) 1877 G2frame.dataWindow.GetSizer().Add(G2frame.restrBook,1,wx.ALL|wx.EXPAND,1) 1875 1878 # clear menu and menu pointers 1879 Pages = [] 1876 1880 1877 1881 txt = 'Bond' 1878 1882 BondRestr = wx.ScrolledWindow(G2frame.restrBook) 1879 1883 G2frame.restrBook.AddPage(BondRestr,txt) 1884 Pages.append(txt) 1880 1885 1881 1886 txt = 'Angle' 1882 1887 AngleRestr = wx.ScrolledWindow(G2frame.restrBook) 1883 1888 G2frame.restrBook.AddPage(AngleRestr,txt) 1889 Pages.append(txt) 1884 1890 1885 1891 txt = 'Plane' 1886 1892 PlaneRestr = wx.ScrolledWindow(G2frame.restrBook) 1887 1893 G2frame.restrBook.AddPage(PlaneRestr,txt) 1894 Pages.append(txt) 1888 1895 1889 1896 txt = 'Chiral' 1890 1897 ChiralRestr = wx.ScrolledWindow(G2frame.restrBook) 1891 1898 G2frame.restrBook.AddPage(ChiralRestr,txt) 1899 Pages.append(txt) 1892 1900 1893 1901 if 'macro' in General['Type']: … … 1895 1903 TorsionRestr = wx.ScrolledWindow(G2frame.restrBook) 1896 1904 G2frame.restrBook.AddPage(TorsionRestr,txt) 1905 Pages.append(txt) 1897 1906 1898 1907 txt = 'Ramachandran' 1899 1908 RamaRestr = wx.ScrolledWindow(G2frame.restrBook) 1900 1909 G2frame.restrBook.AddPage(RamaRestr,txt) 1910 Pages.append(txt) 1901 1911 1902 1912 txt = 'Chem. comp.' 1903 1913 ChemCompRestr = wx.ScrolledWindow(G2frame.restrBook) 1904 1914 G2frame.restrBook.AddPage(ChemCompRestr,txt) 1915 Pages.append(txt) 1905 1916 1906 1917 if General['SH Texture']['Order']: … … 1908 1919 TextureRestr = wx.ScrolledWindow(G2frame.restrBook) 1909 1920 G2frame.restrBook.AddPage(TextureRestr,txt) 1910 1921 Pages.append(txt) 1922 1911 1923 UpdateBondRestr(restrData['Bond']) 1912 1924 1913 1925 G2frame.restrBook.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, OnPageChanged) 1926 1927 # fill page selection menu 1928 menu = G2frame.dataWindow.RestraintTab 1929 for page in Pages: 1930 if menu.FindItem(page) >= 0: continue # is tab already in menu? 1931 Id = wx.NewId() 1932 TabSelectionIdDict[Id] = page 1933 menu.Append(id=Id,kind=wx.ITEM_NORMAL,text=page) 1934 G2frame.Bind(wx.EVT_MENU, OnSelectPage, id=Id)
Note: See TracChangeset
for help on using the changeset viewer.