Changeset 4868 for trunk


Ignore:
Timestamp:
Mar 30, 2021 5:45:34 PM (2 years ago)
Author:
toby
Message:

fix back print issue + some CIF fixes

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrlGUI.py

    r4852 r4868  
    183183    pass
    184184
     185if 'phoenix' in wx.version():
     186    wxValidator = wx.Validator
     187else:
     188    wxValidator = wx.pyValidator
     189
    185190#### Fixed definitions for wx Ids ################################################################################
    186191def Define_wxId(*args):
     
    542547        val = loc[key]
    543548        if 'style' in kw: # add a "Process Enter" to style
    544             kw['style'] += kw['style'] | wx.TE_PROCESS_ENTER
     549            kw['style'] |= wx.TE_PROCESS_ENTER
    545550        else:
    546551            kw['style'] = wx.TE_PROCESS_ENTER
     
    646651                s = ''
    647652                for c in val:
    648                     if ord(c) < 128: s += c
     653                    if ord(c) < 128:
     654                        s += c
     655                    else:
     656                        s += '!'
    649657                if val != s:
    650658                    val = s
     
    715723            self.OKcontrol(True)
    716724        # always store the result
    717         if self.CIFinput: # for CIF make results ASCII
     725        if self.CIFinput and '2' in platform.python_version_tuple()[0]: # CIF/Py2 make results ASCII
    718726            self.result[self.key] = val.encode('ascii','replace')
    719727        else:
     
    730738        val = self.GetValue().strip()
    731739        # always store the result
    732         if self.CIFinput: # for CIF make results ASCII
     740        if self.CIFinput and '2' in platform.python_version_tuple()[0]: # Py2/CIF make results ASCII
    733741            self.result[self.key] = val.encode('ascii','replace')
    734742        else:
     
    777785                pass
    778786################################################################################
    779 class NumberValidator(wx.PyValidator):
     787class NumberValidator(wxValidator):
    780788    '''A validator to be used with a TextCtrl to prevent
    781789    entering characters other than digits, signs, and for float
     
    816824        result=None, key=None, OKcontrol=None, CIFinput=False):
    817825        'Create the validator'
    818         if 'phoenix' in wx.version():
    819             wx.Validator.__init__(self)
    820         else:
    821             wx.PyValidator.__init__(self)
     826        wxValidator.__init__(self)
    822827        # save passed parameters
    823828        self.typ = typ
     
    978983
    979984################################################################################
    980 class ASCIIValidator(wx.PyValidator):
     985class ASCIIValidator(wxValidator):
    981986    '''A validator to be used with a TextCtrl to prevent
    982987    entering characters other than ASCII characters.
     
    994999        'Create the validator'
    9951000        import string
    996         wx.PyValidator.__init__(self)
     1001        wxValidator.__init__(self)
    9971002        # save passed parameters
    9981003        self.result = result
     
    10201025          is associated with.
    10211026        '''
    1022         self.result[self.key] = tc.GetValue().encode('ascii','replace')
     1027        if '2' in platform.python_version_tuple()[0]:
     1028            self.result[self.key] = tc.GetValue().encode('ascii','replace')
     1029        else:
     1030            self.result[self.key] = tc.GetValue()
    10231031        log.LogVarChange(self.result,self.key)
    10241032
  • trunk/GSASIIstrIO.py

    r4862 r4868  
    35513551                        ptstr += 12*' '
    35523552                pFile.write(ptstr+'\n')
    3553         if 'background PWDR' in DebyePeaks and DebyePeaks['background PWDR'][2]:
     3553        if ('background PWDR' in DebyePeaks and
     3554                len(DebyePeaks['background PWDR']) >= 3 and
     3555                DebyePeaks['background PWDR'][2]):
    35543556            pFile.write(' Fixed background scale: %.3f(%d)\n'%(DebyePeaks['background PWDR'][1],int(1000*backSig[-1])))
    35553557        sumBk = np.array(Histogram['sumBk'])
  • trunk/exports/G2export_CIF.py

    r4856 r4868  
    26782678        self.msg=msg
    26792679        self.parent = parent
    2680         #self.helpwin = self.parent.helpwin
    26812680        self.helpwin = helpwin
    26822681        self.helptxt = helptxt
     
    26842683        'Respond to a button press by displaying the requested text'
    26852684        try:
    2686             #helptxt = self.helptxt
     2685            ww,wh = self.helpwin.GetSize()
    26872686            ow,oh = self.helptxt.GetSize()
    26882687            self.helptxt.SetLabel(self.msg)
     2688            self.helptxt.Wrap(ww-10)
    26892689            w,h = self.helptxt.GetSize()
    2690             if h > oh:
     2690            if h > oh: # resize the help area if needed, but avoid changing width
     2691                self.helptxt.SetMinSize((ww,h))
    26912692                self.helpwin.GetSizer().Fit(self.helpwin)
    26922693        except: # error posting help, ignore
     
    28012802        savebtn.Bind(wx.EVT_BUTTON,self._onSave)
    28022803        OKbtn = wx.Button(self, wx.ID_OK, "Use")
     2804        OKbtn.Bind(wx.EVT_BUTTON, lambda x: self.EndModal(wx.ID_OK))
    28032805        OKbtn.SetDefault()
    28042806        OKbuttons.append(OKbtn)
     
    28332835            defaultFile=self.defaultname,
    28342836            wildcard="CIF (*.cif)|*.cif",
    2835             style=wx.SAVE)
     2837            style=wx.FD_SAVE)
    28362838        val = (dlg.ShowModal() == wx.ID_OK)
    28372839        fil = dlg.GetPath()
     
    29192921                txt = wx.StaticText(self,wx.ID_ANY,item+"  ")
    29202922                fbox.Add(txt,(0,i+1))
    2921                 # if self.cifdic.get(item):
    2922                 #     df = self.cifdic[item].get('_definition')
    2923                 #     if df:
    2924                 #         txt.SetToolTipString(G2IO.trim(df))
    2925                 #         but = CIFdefHelp(self,
    2926                 #                          "Definition for "+item+":\n\n"+G2IO.trim(df),
    2927                 #                          self.parent,
    2928                 #                          self.parent.helptxt)
    2929                 #         fbox.Add(but,(1,i+1),flag=wx.ALIGN_CENTER)
    29302923                for j,val in enumerate(self.cifblk[item]):
    29312924                    ent = self.CIFEntryWidget(self.cifblk[item],j,item)
     
    29472940            for i in range(rows):
    29482941                txt = wx.StaticText(self,wx.ID_ANY,str(i+1))
    2949                 fbox.Add(txt,(i+2,0))
     2942                fbox.Add(txt,(i+1,0))
    29502943            line = wx.StaticLine(self,wx.ID_ANY, size=(-1,3), style=wx.LI_HORIZONTAL)
    29512944            vbox.Add(line, 0, wx.EXPAND|wx.ALL, 10)
Note: See TracChangeset for help on using the changeset viewer.