source: trunk/GSASIIElem.py @ 83

Last change on this file since 83 was 83, checked in by vondreel, 13 years ago

further splits of G2gd --> GSASIIphsGUI.py & GSASIIimgGUI.py
Modify GSASIIpath.py to reverse order of 1st two path entries. G2elem couldn't find atmdata!

File size: 21.8 KB
Line 
1"""Element: functions for element types
2   Copyright: 2008, Robert B. Von Dreele (Argonne National Laboratory)
3"""
4
5import wx
6import math
7import sys
8import os.path
9import  wx.lib.colourselect as wscs
10import GSASIIpath
11
12def GetFormFactorCoeff(El):
13    """Read form factor coefficients from atomdata.asc file
14    @param El: element 1-2 character symbol case irrevelant
15    @return: FormFactors: list of form factor dictionaries
16    each dictionary is:
17    'Symbol':4 character element symbol with valence (e.g. 'NI+2')
18    'Z': atomic number
19    'fa': 4 A coefficients
20    'fb':4 B coefficients
21    'fc': C coefficient
22    """
23    ElS = El.upper()
24    ElS = ElS.rjust(2)
25    filename = os.path.join(sys.path[0],'atmdata.dat')
26    try:
27        FFdata = open(filename,'Ur')
28    except:
29        wx.MessageBox(message="File atmdata.dat not found in directory %s" % sys.path[0],
30            caption="No atmdata.dat file",style=wx.OK | wx.ICON_EXCLAMATION | wx.STAY_ON_TOP)
31        sys.exit()
32    S = '1'
33    FormFactors = []
34    while S:
35        S = FFdata.readline()
36        if S[3:5] == ElS:
37            if S[5:6] != '_':
38                Z=int(S[:2])
39                Symbol = S[3:7].strip()
40                S = S[12:]
41                fa = (float(S[:7]),float(S[14:21]),float(S[28:35]),float(S[42:49]))
42                fb = (float(S[7:14]),float(S[21:28]),float(S[35:42]),float(S[49:56]))
43                FormFac = {'Symbol':Symbol,'Z':Z,'fa':fa,'fb':fb,'fc':float(S[56:63])}
44                FormFactors.append(FormFac)               
45    FFdata.close()
46    return FormFactors
47   
48def GetAtomInfo(El):
49    ElS = El.upper().rjust(2)
50    filename = os.path.join(sys.path[0],'atmdata.dat')
51    try:
52        FFdata = open(filename,'Ur')
53    except:
54        wx.MessageBox(message="File atmdata.dat not found in directory %s" % sys.path[0],
55            caption="No atmdata.dat file",style=wx.OK | wx.ICON_EXCLAMATION | wx.STAY_ON_TOP)
56        sys.exit()
57    S = '1'
58    AtomInfo = {}
59    Mass = []
60    while S:
61        S = FFdata.readline()
62        if S[3:5] == ElS:
63            if S[5:6] == '_':
64                if not Mass:                                 #picks 1st one; natural abundance or 1st isotope
65                    Mass = float(S[10:19])
66                if S[5:9] == '_SIZ':
67                    Z=int(S[:2])
68                    Symbol = S[3:5].strip()
69                    Drad = float(S[12:22])
70                    Arad = float(S[22:32])
71    FFdata.close()
72    AtomInfo={'Symbol':Symbol,'Mass':Mass,'Z':Z,'Drad':Drad,'Arad':Arad}   
73    return AtomInfo
74     
75def GetXsectionCoeff(El):
76    """Read atom orbital scattering cross sections for fprime calculations via Cromer-Lieberman algorithm
77    @param El: 2 character element symbol
78    @return: Orbs: list of orbitals each a dictionary with detailed orbital information used by FPcalc
79    each dictionary is:
80    'OrbName': Orbital name read from file
81    'IfBe' 0/2 depending on orbital
82    'BindEn': binding energy
83    'BB': BindEn/0.02721
84    'XSectIP': 5 cross section inflection points
85    'ElEterm': energy correction term
86    'SEdge': absorption edge for orbital
87    'Nval': 10/11 depending on IfBe
88    'LEner': 10/11 values of log(energy)
89    'LXSect': 10/11 values of log(cross section)
90    """
91    AU = 2.80022e+7
92    C1 = 0.02721
93    ElS = El.upper()
94    ElS = ElS.ljust(2)
95    filename = os.path.join(sys.path[0],'Xsect.dat')
96    try:
97        xsec = open(filename,'Ur')
98    except:
99        wx.MessageBox(message="File Xsect.dat not found in directory %s" % sys.path[0],
100            caption="No Xsect.dat file",style=wx.OK | wx.ICON_EXCLAMATION |wx.STAY_ON_TOP)
101        sys.exit()
102    S = '1'
103    Orbs = []
104    while S:
105        S = xsec.readline()
106        if S[:2] == ElS:
107            S = S[:-1]+xsec.readline()[:-1]+xsec.readline()
108            OrbName = S[9:14]
109            S = S[14:]
110            IfBe = int(S[0])
111            S = S[1:]
112            val = S.split()
113            BindEn = float(val[0])
114            BB = BindEn/C1
115            Orb = {'OrbName':OrbName,'IfBe':IfBe,'BindEn':BindEn,'BB':BB}
116            Energy = []
117            XSect = []
118            for i in range(11):
119                Energy.append(float(val[2*i+1]))
120                XSect.append(float(val[2*i+2]))
121            XSecIP = []
122            for i in range(5): XSecIP.append(XSect[i+5]/AU)
123            Orb['XSecIP'] = XSecIP
124            if IfBe == 0:
125                Orb['SEdge'] = XSect[10]/AU
126                Nval = 11
127            else:
128                Orb['ElEterm'] = XSect[10]
129                del Energy[10]
130                del XSect[10]
131                Nval = 10
132                Orb['SEdge'] = 0.0
133            Orb['Nval'] = Nval
134            D = dict(zip(Energy,XSect))
135            Energy.sort()
136            X = []
137            for key in Energy:
138                X.append(D[key])
139            XSect = X
140            LEner = []
141            LXSect = []
142            for i in range(Nval):
143                LEner.append(math.log(Energy[i]))
144                if XSect[i] > 0.0:
145                    LXSect.append(math.log(XSect[i]))
146                else:
147                    LXSect.append(0.0)
148            Orb['LEner'] = LEner
149            Orb['LXSect'] = LXSect
150            Orbs.append(Orb)
151    xsec.close()
152    return Orbs
153   
154def GetMagFormFacCoeff(El):
155    """Read magnetic form factor data from atomdata.asc file
156    @param El: 2 character element symbol
157    @return: MagFormFactors: list of all magnetic form factors dictionaries for element El.
158    each dictionary contains:
159    'Symbol':Symbol
160    'Z':Z
161    'mfa': 4 MA coefficients
162    'nfa': 4 NA coefficients
163    'mfb': 4 MB coefficients
164    'nfb': 4 NB coefficients
165    'mfc': MC coefficient
166    'nfc': NC coefficient
167    """
168    ElS = El.upper()
169    ElS = ElS.rjust(2)
170    filename = os.path.join(sys.path[0],'atmdata.dat')
171    try:
172        FFdata = open(filename,'Ur')
173    except:
174        wx.MessageBox(message="File atmdata.dat not found in directory %s" % sys.path[0],
175            caption="No atmdata.dat file",style=wx.OK | wx.ICON_EXCLAMATION |wx.STAY_ON_TOP)
176        sys.exit()
177    S = '1'
178    MagFormFactors = []
179    while S:
180        S = FFdata.readline()
181        if S[3:5] == ElS:
182            if S[8:9] == 'M':
183                SN = FFdata.readline()               #'N' is assumed to follow 'M' in Atomdata.asc
184                Z=int(S[:2])
185                Symbol = S[3:7]
186                S = S[12:]
187                SN = SN[12:]
188                mfa = (float(S[:7]),float(S[14:21]),float(S[28:35]),float(S[42:49]))
189                mfb = (float(S[7:14]),float(S[21:28]),float(S[35:42]),float(S[49:56]))
190                nfa = (float(SN[:7]),float(SN[14:21]),float(SN[28:35]),float(SN[42:49]))
191                nfb = (float(SN[7:14]),float(SN[21:28]),float(SN[35:42]),float(SN[49:56]))
192                FormFac = {'Symbol':Symbol,'Z':Z,'mfa':mfa,'nfa':nfa,'mfb':mfb,'nfb':nfb,
193                    'mfc':float(S[56:63]),'nfc':float(SN[56:63])}
194                MagFormFactors.append(FormFac)
195    FFdata.close()
196    return MagFormFactors
197
198def ScatFac(FormFac, SThL):
199    """compute value of form factor
200    @param FormFac: dictionary  defined in GetFormFactorCoeff
201    @param SThL: sin-theta/lambda
202    @return: f: real part of form factor
203    """
204    f = FormFac['fc']
205    fa = FormFac['fa']
206    fb = FormFac['fb']
207    for i in range(4):
208        t = -fb[i]*SThL*SThL
209        if t > -35.0: f += fa[i]*math.exp(t)
210    return f
211           
212def FPcalc(Orbs, KEv):
213    """Compute real & imaginary resonant X-ray scattering factors
214    @param Orbs: list of orbital dictionaries as defined in GetXsectionCoeff
215    @param KEv: x-ray energy in keV
216    @return: C: (f',f",mu): real, imaginary parts of resonant scattering & atomic absorption coeff.
217    """
218    def Aitken(Orb, LKev):
219        Nval = Orb['Nval']
220        j = Nval-1
221        LEner = Orb['LEner']
222        for i in range(Nval):
223            if LEner[i] <= LKev: j = i
224        if j > Nval-3: j= Nval-3
225        T = [0,0,0,0,0,0]
226        LXSect = Orb['LXSect']
227        for i in range(3):
228           T[i] = LXSect[i+j]
229           T[i+3] = LEner[i+j]-LKev
230        T[1] = (T[0]*T[4]-T[1]*T[3])/(LEner[j+1]-LEner[j])
231        T[2] = (T[0]*T[5]-T[2]*T[3])/(LEner[j+2]-LEner[j])
232        T[2] = (T[1]*T[5]-T[2]*T[4])/(LEner[j+2]-LEner[j+1])
233        C = T[2]
234        return C
235   
236    def DGauss(Orb,CX,RX,ISig):
237        ALG = (0.11846344252810,0.23931433524968,0.284444444444,
238        0.23931433524968,0.11846344252810)
239        XLG = (0.04691007703067,0.23076534494716,0.5,
240        0.76923465505284,0.95308992296933)
241       
242        D = 0.0
243        B2 = Orb['BB']**2
244        R2 = RX**2
245        XSecIP = Orb['XSecIP']
246        for i in range(5):
247            X = XLG[i]
248            X2 = X**2
249            XS = XSecIP[i]
250            if ISig == 0:
251                S = BB*(XS*(B2/X2)-CX*R2)/(R2*X2-B2)
252            elif ISig == 1:
253                S = 0.5*BB*B2*XS/(math.sqrt(X)*(R2*X2-X*B2))
254            elif ISig == 2:
255                T = X*X2*R2-B2/X
256                S = 2.0*BB*(XS*B2/(T*X2**2)-(CX*R2/T))
257            else:
258                S = BB*B2*(XS-Orb['SEdge']*X2)/(R2*X2**2-X2*B2)
259            A = ALG[i]
260            D += A*S
261        return D
262   
263    AU = 2.80022e+7
264    C1 = 0.02721
265    C = 137.0367
266    FP = 0.0
267    FPP = 0.0
268    Mu = 0.0
269    LKev = math.log(KEv)
270    RX = KEv/C1
271    if Orbs:
272        for Orb in Orbs:
273            CX = 0.0
274            BB = Orb['BB']
275            BindEn = Orb['BindEn']
276            if Orb['IfBe'] != 0: ElEterm = Orb['ElEterm']
277            if BindEn <= KEv:
278                CX = math.exp(Aitken(Orb,LKev))
279                Mu += CX
280                CX /= AU
281            Corr = 0.0
282            if Orb['IfBe'] == 0 and BindEn >= KEv:
283                CX = 0.0
284                FPI = DGauss(Orb,CX,RX,3)
285                Corr = 0.5*Orb['SEdge']*BB**2*math.log((RX-BB)/(-RX-BB))/RX
286            else:
287                FPI = DGauss(Orb,CX,RX,Orb['IfBe'])
288                if CX != 0.0: Corr = -0.5*CX*RX*math.log((RX+BB)/(RX-BB))
289            FPI = (FPI+Corr)*C/(2.0*math.pi**2)
290            FPPI = C*CX*RX/(4.0*math.pi)
291            FP += FPI
292            FPP += FPPI
293        FP -= ElEterm
294   
295    return (FP, FPP, Mu)
296   
297
298class PickElement(wx.Dialog):
299    "Makes periodic table widget for picking element - caller maintains element list"
300    Elem=None
301    def _init_ctrls(self, prnt):
302        wx.Dialog.__init__(self, id=-1, name='PickElement',
303              parent=prnt, pos=wx.DefaultPosition, 
304              style=wx.DEFAULT_DIALOG_STYLE, title='Pick Element')
305        self.SetClientSize(wx.Size(770, 250))
306       
307        REcolor = wx.Colour(128, 128, 255)
308        Metcolor = wx.Colour(192, 192, 192)
309        Noblecolor = wx.Colour(255, 128, 255)
310        Alkcolor = wx.Colour(255, 255, 128)
311        AlkEcolor = wx.Colour(255, 128, 0)
312        SemMetcolor = wx.Colour(128, 255, 0)
313        NonMetcolor = wx.Colour(0, 255, 255)
314        White = wx.Colour(255, 255, 255)
315
316        ElTable = [
317            (["H","H-1"],                  0,0, "Hydrogen",    White,           0.0000),
318            (["He",],                     17,0, "Helium",      Noblecolor,      0.0000),
319            (["Li","Li+1"],                0,1, "Lithium",     Alkcolor,        0.0004),
320            (["Be","Be+2"],                1,1, "Beryllium",   AlkEcolor,       0.0006),
321            (["B",],                       2,1, "Boron",       NonMetcolor,     0.0012),
322            (["C",],                      13,1, "Carbon",      NonMetcolor,     0.0018),
323            (["N",],                      14,1, "Nitrogen",    NonMetcolor,     0.0030),
324            (["O","O-","O-2"],            15,1, "Oxygen",      NonMetcolor,     0.0042),
325            (["F","F-"],                  16,1, "Fluorine",    NonMetcolor,     0.0054),
326            (["Ne",],                     17,1, "Neon",        Noblecolor,      0.0066),
327            (["Na","Na+"],                 0,2, "Sodium",      Alkcolor,        0.0084),
328            (["Mg","Mg+2"],                1,2, "Magnesium",   AlkEcolor,       0.0110),
329            (["Al","Al+3"],                2,2, "Aluminum",    SemMetcolor,     0.0125),
330            (["Si","Si+4"],               13,2, "Silicon",     NonMetcolor,     0.0158),
331            (["P",],                      14,2, "Phosphorus",  NonMetcolor,     0.0180),
332            (["S",],                      15,2, "Sulphur",     NonMetcolor,     0.0210),
333            (["Cl","Cl-1"],               16,2, "Chlorine",    NonMetcolor,     0.0250),
334            (["Ar",],                     17,2, "Argon",       Noblecolor,      0.0285),
335            (["K","K+1"],                  0,3, "Potassium",   Alkcolor,        0.0320),
336            (["Ca","Ca+2"],                1,3, "Calcium",     AlkEcolor,       0.0362),
337            (["Sc","Sc+3"],                2,3, "Scandium",    Metcolor,        0.0410),
338            (["Ti","Ti+2","Ti+3","Ti+4"],  3,3, "Titanium",    Metcolor,        0.0460),
339            (["V","V+2","V+3","V+5"],      4,3, "Vanadium",    Metcolor,        0.0510),
340            (["Cr","Cr+2","Cr+3"],         5,3, "Chromium",    Metcolor,        0.0560),
341            (["Mn","Mn+2","Mn+3","Mn+4"],  6,3, "Manganese",   Metcolor,        0.0616),
342            (["Fe","Fe+2","Fe3"],          7,3, "Iron",        Metcolor,        0.0680),
343            (["Co","Co+2","Co+3"],         8,3, "Cobalt",      Metcolor,        0.0740),
344            (["Ni","Ni+2","Ni+3"],         9,3, "Nickel",      Metcolor,        0.0815),
345            (["Cu","Cu+1","Cu+2"],        10,3, "Copper",      Metcolor,        0.0878),
346            (["Zn","Zn+2"],               11,3, "Zinc",        Metcolor,        0.0960),
347            (["Ga","Ga+3"],               12,3, "Gallium",     SemMetcolor,      0.104),
348            (["Ge","Ge+4"],               13,3, "Germanium",   SemMetcolor,      0.114),
349            (["As",],                     14,3, "Arsenic",     NonMetcolor,      0.120),
350            (["Se",],                     15,3, "Selenium",    NonMetcolor,      0.132),
351            (["Br","Br-1"],               16,3, "Bromine",     NonMetcolor,      0.141),
352            (["Kr",],                     17,3, "Krypton",     Noblecolor,       0.150),
353            (["Rb","Rb+1"],                0,4, "Rubidium",    Alkcolor,         0.159),
354            (["Sr","Sr+2"],                1,4, "Strontium",   AlkEcolor,        0.171),
355            (["Y","Y+3"],                  2,4, "Yittrium",    Metcolor,         0.180),
356            (["Zr","Zr+4"],                3,4, "Zirconium",   Metcolor,         0.192),
357            (["Nb","Nb+3","Nb+5"],         4,4, "Niobium",     Metcolor,         0.204),
358            (["Mo","Mo+3","Mo+5","Mo+6"],  5,4, "Molybdenium", Metcolor,         0.216),
359            (["Tc",],                      6,4, "Technetium",  Metcolor,         0.228),
360            (["Ru","Ru+3","Ru+4"],         7,4, "Ruthenium",   Metcolor,         0.246),
361            (["Rh","Rh+3","Rh+4"],         8,4, "Rhodium",     Metcolor,         0.258),
362            (["Pd","Pd+2","Pd+4"],         9,4, "Palladium",   Metcolor,         0.270),
363            (["Ag","Ag+1","Ag+2"],        10,4, "Silver",      Metcolor,         0.285),
364            (["Cd","Cd+2"],               11,4, "Cadmium",     Metcolor,         0.300),
365            (["In","In+3"],               12,4, "Indium",      SemMetcolor,      0.318),
366            (["Sn","Sn+2","Sn+4"],        13,4, "Tin",         SemMetcolor,      0.330),
367            (["Sb","Sb+3","Sb+5"],        14,4, "Antimony",    SemMetcolor,      0.348),
368            (["Te",],                     15,4, "Tellurium",   NonMetcolor,      0.363),
369            (["I","I-1"],                 16,4, "Iodine",      NonMetcolor,      0.384),
370            (["Xe",],                     17,4, "Xenon",       Noblecolor,       0.396),
371            (["Cs","Cs+1"],                0,5, "Caesium",     Alkcolor,         0.414),
372            (["Ba","Ba+2"],                1,5, "Barium",      AlkEcolor,        0.438),
373            (["La","La+3"],                2,5, "Lanthanium",  Metcolor,         0.456),
374            (["Ce","Ce+3","Ce+4"],     3.5,6.5, "Cerium",      REcolor,      0.474),
375            (["Pr","Pr+3","Pr+4"],     4.5,6.5, "Praseodymium",REcolor,      0.492),
376            (["Nd","Nd+3"],            5.5,6.5, "Neodymium",   REcolor,      0.516),
377            (["Pm","Pm+3"],            6.5,6.5, "Promethium",  REcolor,      0.534),
378            (["Sm","Sm+3"],            7.5,6.5, "Samarium",    REcolor,      0.558),
379            (["Eu","Eu+2","Eu+3"],     8.5,6.5, "Europium",    REcolor,      0.582),
380            (["Gd","Gd+3"],            9.5,6.5, "Gadolinium",  REcolor,      0.610),
381            (["Tb","Tb+3"],           10.5,6.5, "Terbium",     REcolor,      0.624),
382            (["Dy","Dy+3"],           11.5,6.5, "Dysprosium",  REcolor,      0.648),
383            (["Ho","Ho+3"],           12.5,6.5, "Holmium",     REcolor,      0.672),
384            (["Er","Er+3"],           13.5,6.5, "Erbium",      REcolor,      0.696),
385            (["Tm","Tm+3"],           14.5,6.5, "Thulium",     REcolor,      0.723),
386            (["Yb","Yb+2","Yb+3"],    15.5,6.5, "Ytterbium",   REcolor,      0.750),
387            (["Lu","Lu+3"],           16.5,6.5, "Lutetium",    REcolor,      0.780),
388            (["Hf","Hf+4"],                3,5, "Hafnium",     Metcolor,         0.804),
389            (["Ta","Ta+5"],                4,5, "Tantalum",    Metcolor,         0.834),
390            (["W","W+6"],                  5,5, "Tungsten",    Metcolor,         0.864),
391            (["Re",],                      6,5, "Rhenium",     Metcolor,         0.900),
392            (["Os","Os+4"],                7,5, "Osmium",      Metcolor,         0.919),
393            (["Ir","Ir+3","Ir+4"],         8,5, "Iridium",     Metcolor,         0.948),
394            (["Pt","Pt+2","Pt+4"],         9,5, "Platinium",   Metcolor,         0.984),
395            (["Au","Au+1","Au+3"],        10,5, "Gold",        Metcolor,         1.014),
396            (["Hg","Hg+1","Hg+2"],        11,5, "Mercury",     Metcolor,         1.046),
397            (["Tl","Tl+1","Tl+3"],        12,5, "Thallium",    SemMetcolor,      1.080),
398            (["Pb","Pb+2","Pb+4"],        13,5, "Lead",        SemMetcolor,      1.116),
399            (["Bi","Bi+3","Bi+5"],        14,5, "Bismuth",     SemMetcolor,      1.149),
400            (["Po",],                     15,5, "Polonium",    SemMetcolor,      1.189),
401            (["At",],                     16,5, "Astatine",    NonMetcolor,      1.224),
402            (["Rn",],                     17,5, "Radon",       Noblecolor,       1.260),
403            (["Fr",],                      0,6, "Francium",    Alkcolor,         1.296),
404            (["Ra","Ra+2"],                1,6, "Radium",      AlkEcolor,        1.332),
405            (["Ac","Ac+3"],                2,6, "Actinium",    Metcolor,         1.374),
406            (["Th","Th+4"],            3.5,7.5, "Thorium",     REcolor,      1.416),
407            (["Pa",],                  4.5,7.5, "Protactinium",REcolor,      1.458),
408            (["U","U+3","U+4","U+6"],  5.5,7.5, "Uranium",     REcolor,      1.470),
409            (["Np","Np+3","Np+4","Np+6"], 6.5,7.5, "Neptunium",   REcolor,      1.536),
410            (["Pu","Pu+3","Pu+4","Pu+6"], 7.5,7.5, "Plutonium",   REcolor,      1.584),
411            (["Am",],                  8.5,7.5, "Americium",   REcolor,      1.626),
412            (["Cm",],                  9.5,7.5, "Curium",      REcolor,      1.669),
413            (["Bk",],                 10.5,7.5, "Berkelium",   REcolor,      1.716),
414            (["Cf",],                 11.5,7.5, "Californium", REcolor,      1.764),
415            (["Q","QA","QB","QC","QD"],  14.5,7.5, "Special form factor", REcolor,  0.000),
416            ]
417           
418           
419        i=0
420        for E in ElTable:
421            PickElement.ElButton(self,name=E[0],
422            pos=wx.Point(E[1]*40+25,E[2]*24+24),tip=E[3],color=E[4])
423            i+=1
424
425    def __init__(self, parent):
426        self._init_ctrls(parent)
427       
428    def ElButton(self, name, pos, tip, color):
429        Black = wx.Colour(0,0,0)
430        El = wx.ComboBox(choices=name, parent=self, pos=pos, size=wx.Size(40,23),
431            style=wx.CB_READONLY, value=name[0])
432        El.SetBackgroundColour(color)
433        El.SetToolTipString(tip)
434        El.Bind(wx.EVT_COMBOBOX, self.OnElButton)
435
436    def OnElButton(self, event):
437        El = event.GetEventObject().GetLabel()
438        self.Elem = (El)
439        self.EndModal(wx.ID_OK)       
440       
441class DeleteElement(wx.Dialog):
442    "Delete element from selected set widget"
443    def _init_ctrls(self, parent):
444        l = len(DeleteElement.Elems)-1
445        wx.Dialog.__init__(self, id=-1, name='Delete', parent=parent,
446              pos=wx.DefaultPosition, size=wx.Size(max(128,64+l*24), 87),
447              style=wx.DEFAULT_DIALOG_STYLE, title='Delete Element')
448        self.Show(True)
449        self.SetAutoLayout(True)
450        self.SetHelpText('Select element to delete')
451        self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
452
453        i = 0
454        Elem = []
455        for Elem in DeleteElement.Elems:
456            name = Elem[0].lower().capitalize()
457            self.ElButton(id=-1,name=name,pos=wx.Point(16+i*24, 16))
458            i+=1
459             
460    def __init__(self, parent):
461        DeleteElement.Elems = parent.Elems
462        DeleteElement.El = ' '
463        self._init_ctrls(parent)
464
465    def ElButton(self, id, name, pos):
466        White = wx.Colour(255, 255, 255)
467        El = wscs.ColourSelect(label=name, parent=self, colour = White,
468            pos=pos, size=wx.Size(24, 23), style=wx.RAISED_BORDER)
469        El.Bind(wx.EVT_BUTTON, self.OnDeleteButton)
470   
471    def OnDeleteButton(self, event):
472        DeleteElement.El=event.GetEventObject().GetLabel()
473        self.EndModal(wx.ID_OK)
474       
475    def GetDeleteElement(self):
476        return DeleteElement.El
477       
478
Note: See TracBrowser for help on using the repository browser.