Ignore:
Timestamp:
Mar 6, 2020 3:05:22 PM (23 months ago)
Author:
toby
Message:

Add more image settings to preferences; prevent save of config.py after "no save"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrlGUI.py

    r4330 r4345  
    10701070    :param wx.Panel parent: the parent to the :class:`~wxpython.ComboBox` (usually a
    10711071      frame or panel)
    1072     :param dict dct: a dict (or list) to contain the value set
     1072    :param dct: a dict or list to contain the value set
    10731073      for the :class:`~wxpython.ComboBox`.
    10741074    :param item: the dict key (or list index) where ``dct[item]`` will
     
    10941094      The default for :data:`values` is to use the same list as
    10951095      specified for :data:`choices`.
     1096    :param function onChange: an optional routine that will be called
     1097      when the 
     1098      :class:`~wxpython.ComboBox` can be specified.
    10961099    :param (other): additional keyword arguments accepted by
    10971100      :class:`~wxpython.ComboBox` can be specified.
    10981101    '''
    1099     def __init__(self,parent,dct,item,choices,values=None,**kw):
     1102    def __init__(self,parent,dct,item,choices,values=None,OnChange=None,**kw):
    11001103        if values is None:
    11011104            values = choices
     
    11131116        self.dct = dct
    11141117        self.item = item
     1118        self.OnChange = OnChange
    11151119        self.Bind(wx.EVT_COMBOBOX, self.onSelection)
    11161120    def onSelection(self,event):
     
    11201124        else:
    11211125            self.dct[self.item] = self.values[0] # unknown
     1126        if self.OnChange: self.OnChange(event)
    11221127
    11231128################################################################################
     
    47074712    return d
    47084713
     4714inhibitSave = False
    47094715def SaveConfigVars(vars,parent=None):
    47104716    '''Write the current config variable values to config.py
     
    47164722    :returns: True if unable to write the file, None otherwise
    47174723    '''
     4724    if inhibitSave:
     4725        if GSASIIpath.GetConfigValue('debug'):
     4726            print('inhibitSave prevents saving configuration')
     4727        return
     4728
    47184729    # try to write to where an old config file is located
    47194730    try:
     
    48784889        GSASIIpath.SetConfigValue(self.vars)
    48794890        self.EndModal(wx.ID_OK)
     4891        global inhibitSave
     4892        if event is not None: inhibitSave = True
    48804893        import GSASIImpsubs as G2mp
    48814894        G2mp.ResetMP()
     
    48854898        as the current settings
    48864899        '''
     4900        global inhibitSave
     4901        inhibitSave = False
    48874902        if not SaveConfigVars(self.vars,parent=self):
    48884903            self.OnApplyChanges() # force a reload of the config settings
     
    49634978                    style=wx.CB_READONLY|wx.CB_DROPDOWN)
    49644979                self.colSel.Bind(wx.EVT_COMBOBOX, OnNewColorBar)
     4980                self.varsizer.Add(self.colSel, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     4981            elif var == 'Image_calibrant':
     4982                import ImageCalibrants as calFile
     4983                calList = sorted([m for m in calFile.Calibrants.keys()],
     4984                                     key=lambda s: s.lower())
     4985                self.colSel = EnumSelector(self,self.vars[var],1,calList,
     4986                                               OnChange=self.OnChange)       
    49654987                self.varsizer.Add(self.colSel, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
    49664988            else:
Note: See TracChangeset for help on using the changeset viewer.