Changeset 3733 for trunk/GSASIIphsGUI.py


Ignore:
Timestamp:
Nov 15, 2018 6:06:47 PM (7 years ago)
Author:
toby
Message:

change modulated sp grp widget to button

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIIphsGUI.py

    r3729 r3733  
    19941994        def ModulatedSizer(name):
    19951995           
    1996             def showSSG(General,msg,text,table,refresh):
    1997                 'Show the symmetry information, redraw window if needed'
     1996            def showSSG(msg,text,table):
     1997                'Show the symmetry information, redraw window after'
    19981998                dlg = G2G.SGMessageBox(General,msg,text,table)
     1999                dlg.CenterOnParent()
    19992000                dlg.ShowModal()
    20002001                dlg.Destroy()
    2001                 if refresh: UpdateGeneral()
     2002                UpdateGeneral()
    20022003               
     2004            def OnSuperEnter(event):
     2005                'Close dialog after enter is pressed'
     2006                event.GetEventObject().Parent.EndModal(wx.ID_OK)
     2007           
    20032008            def OnSuperGp(event):   #for HKLF needs to reject SSgps not agreeing with modVec!
    20042009                'Respond to selection of a modulation group'
    2005                 event.Skip()
    2006                 refresh = True
     2010                Choice = []
     2011                if not SGData['SGFixed']:
     2012                    Choice = G2spc.SSChoice(SGData)
     2013                    if SGData['SGGray']:
     2014                        Choice = [G2spc.fixGray(SGData,item) for item in Choice]
     2015                if len(Choice) == 0: return
     2016                #parent = event.GetEventObject().GetTopLevelParent()
     2017                parent = General
     2018                dlg = wx.Dialog(parent,style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
     2019                sizer = wx.BoxSizer(wx.VERTICAL)
     2020                sizer.Add(wx.StaticText(dlg,wx.ID_OK,
     2021                            'Select or enter a modulation group'
     2022                                            ),0,wx.ALIGN_CENTER)
     2023               
     2024                sizer.Add((10,10))
     2025                superGp = wx.ComboBox(dlg,value=generalData['SuperSg'],choices=Choice,style=wx.CB_DROPDOWN|wx.TE_PROCESS_ENTER)
     2026                superGp.Bind(wx.EVT_TEXT_ENTER,OnSuperEnter)
     2027                sizer.Add(superGp)
     2028                sizer.Add((10,10))
     2029                btnsizer = wx.StdDialogButtonSizer()
     2030                btn = wx.Button(dlg, wx.ID_OK)
     2031                btn.SetDefault()
     2032                btnsizer.AddButton(btn)
     2033                btn = wx.Button(dlg, wx.ID_CANCEL)
     2034                btnsizer.AddButton(btn)
     2035                btnsizer.Realize()
     2036                sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND|wx.ALL, 5)
     2037                dlg.SetSizer(sizer)
     2038                sizer.Fit(dlg)
     2039                dlg.CenterOnParent()
     2040                if dlg.ShowModal() == wx.ID_OK:
     2041                    try:
     2042                        SSymbol = superGp.GetValue().strip()
     2043                    except AttributeError: # not sure why needed
     2044                        SSymbol = superGp.GetLabel().strip()
     2045                else:
     2046                    dlg.Destroy()
     2047                    return
     2048                dlg.Destroy()
    20072049                try:
    2008                     SSymbol = superGp.GetValue()
    2009                 except AttributeError:
    2010                     SSymbol = superGp.GetLabel()
    2011                     refresh = False
    2012                 SSGData = generalData['SSGData']
    2013                 if not generalData['SGData']['SGFixed']:
    20142050                    E,SSGData = G2spc.SSpcGroup(generalData['SGData'],SSymbol)
     2051                except:
     2052                    E = 'Invalid modulation group'
     2053                    SSGData = None
    20152054                if SSGData:
    20162055                    Vec = generalData['SuperVec'][0]     #(3+1) only
     
    20212060                    generalData['SuperSg'] = SSymbol
    20222061                    msg = 'Superspace Group Information'
    2023                     wx.CallLater(100,showSSG,General,msg,text,table,refresh)
     2062                    wx.CallAfter(showSSG,msg,text,table)
     2063                    # N.B. showSSG calls UpdateGeneral
    20242064                else:
    20252065                    # needed in case someone manually enters an invalid SSG?
    2026                     text = [E+'\nSuperspace Group set to previous']
    2027                     superGp.SetValue(generalData['SuperSg'])
    2028                     msg = 'Superspace Group Error'
    2029                     Style = wx.ICON_EXCLAMATION
    2030                     Text = '\n'.join(text)
    2031                     wx.MessageBox(Text,caption=msg,style=Style)
    2032                     if refresh: wx.CallAfter(UpdateGeneral)               
    2033                            
     2066                    Text = '\n'.join([E+'\nSuperspace Group entry ignored'])
     2067                    G2G.G2MessageBox(parent,Text,'Superspace Group Error')
     2068                    wx.CallAfter(UpdateGeneral)
     2069                   
    20342070            def OnVecRef(event):
    20352071                generalData['SuperVec'][1] = Ref.GetValue()
     
    20532089                    Choice = [G2spc.fixGray(SGData,item) for item in Choice]
    20542090            if len(Choice):
    2055                 i,j= wx.__version__.split('.')[0:2]
    2056                 if int(i)+int(j)/10. > 2.8 and 'wxOSX' in wx.PlatformInfo:      #since this seems to fail on a Mac!
    2057                     superGp = wx.ComboBox(General,value=generalData['SuperSg'],choices=Choice,style=wx.CB_DROPDOWN|wx.CB_READONLY)
    2058                     superGp.Bind(wx.EVT_COMBOBOX,OnSuperGp)
    2059                 else:
    2060                     superGp = wx.ComboBox(General,value=generalData['SuperSg'],choices=Choice,style=wx.CB_DROPDOWN|wx.TE_PROCESS_ENTER)
    2061                     superGp.Bind(wx.EVT_COMBOBOX,OnSuperGp)
    2062                     superGp.Bind(wx.EVT_TEXT_ENTER,OnSuperGp)
     2091                val = generalData['SuperSg']
     2092                if val.strip() == "": val = Choice[0]
     2093                superGp = wx.Button(General,wx.ID_ANY,val,size=(100,-1))
     2094                superGp.Bind(wx.EVT_BUTTON,OnSuperGp)
    20632095            else:
    20642096                superGp = wx.StaticText(General,label=generalData['SuperSg'])
Note: See TracChangeset for help on using the changeset viewer.