- Timestamp:
- Mar 18, 2021 7:32:55 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/exports/G2export_CIF.py
r4783 r4856 1977 1977 dlg.ShowModal() 1978 1978 1979 #============================================================================== ===1980 # ===== end of function definitions for _Exporter=================================1981 #============================================================================== ===1979 #============================================================================== 1980 #### _Exporter code starts here ====================================== 1981 #============================================================================== 1982 1982 # make sure required information is present 1983 1983 self.CIFdate = dt.datetime.strftime(dt.datetime.now(),"%Y-%m-%dT%H:%M") … … 2075 2075 # create a dict with refined values and their uncertainties 2076 2076 self.loadParmDict() 2077 # is there anything to export? 2078 if len(self.Phases) == len(self.powderDict) == len(self.xtalDict) == 0: 2079 self.G2frame.ErrorDialog( 2080 'Empty project', 2081 'Project does not contain any data or phases. Are they interconnected?') 2082 return 2077 2083 if self.ExportSelect('ask'): return 2078 2084 if not self.filename: … … 2088 2094 # print j 2089 2095 2090 # is there anything to export?2091 if len(self.Phases) == len(self.powderDict) == len(self.xtalDict) == 0:2092 self.G2frame.ErrorDialog(2093 'Empty project',2094 'Project does not contain any data or phases. Are they interconnected?')2095 return2096 2096 self.quickmode = False # full CIF 2097 2097 phasenam = None # include all phases … … 2171 2171 wx.OK|wx.CANCEL) 2172 2172 ret = dlg.ShowModal() 2173 dlg.CenterOnParent() 2173 2174 dlg.Destroy() 2174 2175 if ret != wx.ID_OK: return … … 2194 2195 self.G2frame, 2195 2196 style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) 2197 self.cifdefs.G2frame = self.G2frame 2198 self.cifdefs.CenterOnParent() 2196 2199 EditCIFDefaults() 2197 self.cifdefs.CenterOnParent()2198 2200 if self.cifdefs.ShowModal() != wx.ID_OK: 2199 2201 self.cifdefs.Destroy() … … 2618 2620 try: 2619 2621 fil = os.path.splitext(fil)[0]+'.cpickle' 2620 fp = open(fil,'w ')2622 fp = open(fil,'wb') 2621 2623 pickle.dump(cifdic,fp) 2622 2624 fp.close() … … 2641 2643 fil = os.path.join(loc,ftyp+".cpickle") 2642 2644 if not os.path.exists(fil): continue 2643 fp = open(fil,'r ')2645 fp = open(fil,'rb') 2644 2646 try: 2645 2647 cifdic.update(pickle.load(fp)) … … 2700 2702 ''' 2701 2703 blk = cf.keys()[0] # assume templates are a single CIF block, use the 1st 2702 loopstructure = cf[blk].loopnames()[:] # copy over the list of loop contents 2704 try: 2705 loopstructure = cf[blk].loopnames()[:] # copy over the list of loop contents 2706 except AttributeError: 2707 loopstructure = [j[:] for j in cf[blk].loops.values()] # method replaced? 2703 2708 dblk = {} 2704 2709 for item in cf[blk].keys(): # make a copy of all the items in the block … … 2784 2789 self.newfile = None 2785 2790 self.defaultname = defaultname 2791 self.G2frame = parent.G2frame 2786 2792 global CIFdic # once this is loaded, keep it around 2787 2793 if CIFdic is None: … … 2876 2882 self.parentOKbuttons = OKbuttons 2877 2883 self.ValidatedControlsList = [] 2884 self.G2frame = parent.G2frame 2878 2885 self._fill() 2879 2886 def _fill(self): … … 2928 2935 df = self.cifdic[item].get('_definition') 2929 2936 if df: 2930 txt.SetToolTipString(G2IO.trim(df)) 2937 try: 2938 txt.SetToolTip(G2IO.trim(df)) 2939 except: 2940 txt.SetToolTipString(G2IO.trim(df)) 2931 2941 but = CIFdefHelp(self, 2932 2942 "Definition for "+item+":\n\n"+G2IO.trim(df), … … 2953 2963 df = self.cifdic[item].get('_definition') 2954 2964 if df: 2955 txt.SetToolTipString(G2IO.trim(df)) 2965 try: 2966 txt.SetToolTip(G2IO.trim(df)) 2967 except: 2968 txt.SetToolTipString(G2IO.trim(df)) 2956 2969 but = CIFdefHelp(self, 2957 2970 "Definition for "+item+":\n\n"+G2IO.trim(df), … … 3041 3054 if rng[1]: mx = hint(rng[1]) 3042 3055 ent = G2G.ValidatedTxtCtrl( 3043 self,dct,item,typeHint=hint, min=mn,max=mx,3056 self,dct,item,typeHint=hint,xmin=mn,xmax=mx, 3044 3057 CIFinput=True,ASCIIonly=True, 3045 3058 OKcontrol=self.ControlOKButton) … … 3077 3090 self.dict = G2dict 3078 3091 self.repaint = repaint 3092 self.G2frame = frame.G2frame 3079 3093 templateDefName = 'template_'+tmplate+'.cif' 3080 3094 self.CIF = G2dict.get("CIF_template") … … 3146 3160 defaultFile=self.defaultname, 3147 3161 wildcard="CIF (*.cif)|*.cif", 3148 style=wx. OPEN)3162 style=wx.FD_OPEN) 3149 3163 ret = dlg.ShowModal() 3150 3164 fil = dlg.GetPath()
Note: See TracChangeset
for help on using the changeset viewer.