Changeset 3418 for trunk/GSASIIctrlGUI.py
- Timestamp:
- Jun 2, 2018 7:42:33 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIctrlGUI.py
r3417 r3418 140 140 import copy 141 141 import webbrowser # could postpone this for quicker startup 142 import numpy as np 142 143 143 144 import GSASIIpath … … 145 146 import GSASIIdataGUI as G2gd 146 147 import GSASIIpwdGUI as G2pdG 148 import GSASIIspc as G2spc 147 149 import GSASIIpy3 as G2py3 148 150 import GSASIIlog as log 149 151 import GSASIIobj as G2obj 152 150 153 151 154 # Define a short names for convenience … … 3145 3148 parent.Raise() 3146 3149 self.EndModal(wx.ID_OK) 3150 3151 ################################################################################ 3152 class SGMagSpinBox(wx.Dialog): 3153 ''' Special version of MessageBox that displays magnetic spin text 3154 ''' 3155 def __init__(self,parent,title,text,table,Cents,names,spins,ifGray): 3156 wx.Dialog.__init__(self,parent,wx.ID_ANY,title,pos=wx.DefaultPosition, 3157 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,size=wx.Size(420,350)) 3158 self.text = text 3159 self.table = table 3160 self.names = names 3161 Nnames = len(self.names) 3162 self.spins = spins 3163 self.ifGray = ifGray 3164 self.PrintTable = [' Magnetic symmetry operations for %s:'%self.text[0].split(':')[1],] 3165 self.panel = wxscroll.ScrolledPanel(self) 3166 mainSizer = wx.BoxSizer(wx.VERTICAL) 3167 mainSizer.Add((0,10)) 3168 cents = [0,] 3169 if len(Cents) > 1: 3170 cents = self.text[-1].split(';') 3171 lentable = len(self.table) 3172 for line in self.text: 3173 mainSizer.Add(wx.StaticText(self.panel,label=' %s '%(line)),0,WACV) 3174 if 'equivalent' in line: 3175 break 3176 ncol = self.table[0].count(',')+2 3177 nBlk = 0 3178 nG = 1 3179 if self.ifGray: 3180 nG = 2 3181 for ng in range(nG): 3182 for ic,cent in enumerate(cents): 3183 Cent = np.array(Cents[ic]) 3184 if ic: 3185 if cent: cent = cent.strip(' (').strip(')+\n') 3186 label = ' for (%s)+'%(cent) 3187 if ng or self.spins[nBlk*lentable] < 0: #test for gray operators 3188 label += "1'" 3189 mainSizer.Add(wx.StaticText(self.panel,label=label),0,WACV) 3190 tableSizer = wx.FlexGridSizer(0,2*ncol+3,0,0) 3191 j = 0 3192 for item in self.table: 3193 flds = item.split(')')[1] 3194 tableSizer.Add(wx.StaticText(self.panel,label=' (%2d) '%(j+1)),0,WACV) 3195 flds = flds.replace(' ','').split(',') 3196 for i,fld in enumerate(flds): 3197 if i < ncol-1: 3198 text = wx.StaticText(self.panel,label='%s, '%(fld)) 3199 tableSizer.Add(text,0,WACV) 3200 else: 3201 text = wx.StaticText(self.panel,label='%s '%(fld)) 3202 tableSizer.Add(text,0,WACV) 3203 text = wx.StaticText(self.panel,label=' (%s) '%(self.names[j%Nnames])) 3204 try: 3205 if self.spins[j+nBlk*lentable] < 0: 3206 text.SetForegroundColour('Red') 3207 item += ',-1' 3208 else: 3209 item += ',+1' 3210 except IndexError: 3211 print(self.spins,j,ic,lentable,self.names[j%Nnames]) 3212 item += ',+1' 3213 M,T,S = G2spc.MagText2MTS(item.split(')')[1].replace(' ',''),CIF=False) 3214 T = (T+Cent)%1. 3215 item = G2spc.MT2text([M,T],reverse=True) 3216 if S > 0: 3217 item += ',+1' 3218 else: 3219 item += ',-1' 3220 self.PrintTable.append(item.replace(' ','').lower()) 3221 tableSizer.Add(text,0,WACV) 3222 if not j%2: 3223 tableSizer.Add((20,0)) 3224 j += 1 3225 nBlk += 1 3226 mainSizer.Add(tableSizer,0,WACV) 3227 3228 3229 def OnPrintOps(event): 3230 for item in self.PrintTable: 3231 print(item) 3232 3233 btnsizer = wx.StdDialogButtonSizer() 3234 printBtn = wx.Button(self.panel,label='Print Ops') 3235 printBtn.Bind(wx.EVT_BUTTON, OnPrintOps) 3236 btnsizer.Add(printBtn) 3237 OKbtn = wx.Button(self.panel, wx.ID_OK) 3238 OKbtn.SetDefault() 3239 btnsizer.AddButton(OKbtn) 3240 btnsizer.Realize() 3241 OKbtn.SetFocus() 3242 mainSizer.Add((0,10)) 3243 mainSizer.Add(btnsizer,0) 3244 3245 self.panel.SetSizer(mainSizer) 3246 self.panel.SetAutoLayout(True) 3247 self.panel.SetScrollRate(10,10) 3248 self.panel.SendSizeEvent() 3249 3250 3251 def Show(self): 3252 '''Use this method after creating the dialog to post it 3253 ''' 3254 self.ShowModal() 3255 return 3256 3147 3257 3148 3258 ################################################################################
Note: See TracChangeset
for help on using the changeset viewer.