Changeset 4856 for trunk


Ignore:
Timestamp:
Mar 18, 2021 7:32:55 PM (2 years ago)
Author:
toby
Message:

full CIF fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exports/G2export_CIF.py

    r4783 r4856  
    19771977            dlg.ShowModal()
    19781978
    1979 #=================================================================================
    1980 #===== end of function definitions for _Exporter =================================
    1981 #=================================================================================
     1979#==============================================================================
     1980####  _Exporter code starts here         ======================================
     1981#==============================================================================
    19821982        # make sure required information is present
    19831983        self.CIFdate = dt.datetime.strftime(dt.datetime.now(),"%Y-%m-%dT%H:%M")
     
    20752075        # create a dict with refined values and their uncertainties
    20762076        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
    20772083        if self.ExportSelect('ask'): return
    20782084        if not self.filename:
     
    20882094        #        print j
    20892095
    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            return
    20962096        self.quickmode = False # full CIF
    20972097        phasenam = None # include all phases
     
    21712171                wx.OK|wx.CANCEL)
    21722172            ret = dlg.ShowModal()
     2173            dlg.CenterOnParent()
    21732174            dlg.Destroy()
    21742175            if ret != wx.ID_OK: return
     
    21942195            self.G2frame,
    21952196            style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
     2197        self.cifdefs.G2frame = self.G2frame
     2198        self.cifdefs.CenterOnParent()
    21962199        EditCIFDefaults()
    2197         self.cifdefs.CenterOnParent()
    21982200        if self.cifdefs.ShowModal() != wx.ID_OK:
    21992201            self.cifdefs.Destroy()
     
    26182620    try:
    26192621        fil = os.path.splitext(fil)[0]+'.cpickle'
    2620         fp = open(fil,'w')
     2622        fp = open(fil,'wb')
    26212623        pickle.dump(cifdic,fp)
    26222624        fp.close()
     
    26412643            fil = os.path.join(loc,ftyp+".cpickle")
    26422644            if not os.path.exists(fil): continue
    2643             fp = open(fil,'r')
     2645            fp = open(fil,'rb')
    26442646            try:
    26452647                cifdic.update(pickle.load(fp))
     
    27002702    '''
    27012703    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?
    27032708    dblk = {}
    27042709    for item in cf[blk].keys(): # make a copy of all the items in the block
     
    27842789        self.newfile = None
    27852790        self.defaultname = defaultname
     2791        self.G2frame = parent.G2frame
    27862792        global CIFdic  # once this is loaded, keep it around
    27872793        if CIFdic is None:
     
    28762882        self.parentOKbuttons = OKbuttons
    28772883        self.ValidatedControlsList = []
     2884        self.G2frame = parent.G2frame
    28782885        self._fill()
    28792886    def _fill(self):
     
    29282935                    df = self.cifdic[item].get('_definition')
    29292936                    if df:
    2930                         txt.SetToolTipString(G2IO.trim(df))
     2937                        try:
     2938                            txt.SetToolTip(G2IO.trim(df))
     2939                        except:
     2940                            txt.SetToolTipString(G2IO.trim(df))
    29312941                        but = CIFdefHelp(self,
    29322942                                         "Definition for "+item+":\n\n"+G2IO.trim(df),
     
    29532963                    df = self.cifdic[item].get('_definition')
    29542964                    if df:
    2955                         txt.SetToolTipString(G2IO.trim(df))
     2965                        try:
     2966                            txt.SetToolTip(G2IO.trim(df))
     2967                        except:
     2968                            txt.SetToolTipString(G2IO.trim(df))
    29562969                        but = CIFdefHelp(self,
    29572970                                         "Definition for "+item+":\n\n"+G2IO.trim(df),
     
    30413054                    if rng[1]: mx = hint(rng[1])
    30423055                    ent = G2G.ValidatedTxtCtrl(
    3043                         self,dct,item,typeHint=hint,min=mn,max=mx,
     3056                        self,dct,item,typeHint=hint,xmin=mn,xmax=mx,
    30443057                        CIFinput=True,ASCIIonly=True,
    30453058                        OKcontrol=self.ControlOKButton)
     
    30773090        self.dict = G2dict
    30783091        self.repaint = repaint
     3092        self.G2frame = frame.G2frame
    30793093        templateDefName = 'template_'+tmplate+'.cif'
    30803094        self.CIF = G2dict.get("CIF_template")
     
    31463160            defaultFile=self.defaultname,
    31473161            wildcard="CIF (*.cif)|*.cif",
    3148             style=wx.OPEN)
     3162            style=wx.FD_OPEN)
    31493163        ret = dlg.ShowModal()
    31503164        fil = dlg.GetPath()
Note: See TracChangeset for help on using the changeset viewer.