source: trunk/GSASIIElemGUI.py @ 563

Last change on this file since 563 was 563, checked in by vondreele, 10 years ago

add "None" element to table - used for charge flipping
mods to charge flipping
fix PickElement? errors in pdf controls, etc.

File size: 3.8 KB
Line 
1"""ElementGUI: class defn. for element GUIs
2   Copyright: 2008, Robert B. Von Dreele & Brian H. Toby (Argonne National Laboratory)
3"""
4########### SVN repository information ###################
5# $Date: 2012-01-24 14:31:27 -0600 (Tue, 24 Jan 2012) $
6# $Author: vondreele & toby $
7# $Revision: 456 $
8# $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/GSASIIElemGUI.py $
9# $Id: GSASIIElemGUI.py 456 2012-01-24 20:31:27Z toby $
10########### SVN repository information ###################
11import wx
12import os
13import wx.lib.colourselect as wscs
14class PickElement(wx.Dialog):
15    "Makes periodic table widget for picking element - caller maintains element list"
16    Elem=None
17    def _init_ctrls(self, prnt):
18        wx.Dialog.__init__(self, id=-1, name='PickElement',
19              parent=prnt, pos=wx.DefaultPosition, 
20              style=wx.DEFAULT_DIALOG_STYLE, title='Pick Element')
21        import ElementTable as ET
22        self.butWid = 55
23        if 'nt' in os.name:
24            self.butWid = 40
25        self.SetClientSize(wx.Size(50+18*self.butWid, 250))
26       
27        i=0
28        for E in ET.ElTable:
29            if self.oneOnly:
30                color=E[4]
31            else:
32                color=E[6]
33            PickElement.ElButton(self,name=E[0],
34               pos=wx.Point(E[1]*self.butWid+25,E[2]*24+24),tip=E[3],color=color)
35            i+=1
36
37    def __init__(self, parent,oneOnly=False,ifNone=False):
38        self.oneOnly = oneOnly
39        self.ifNone = ifNone
40        self._init_ctrls(parent)
41       
42    def ElButton(self, name, pos, tip, color):
43        Black = wx.Colour(0,0,0)
44        if not self.ifNone and name[0] == 'None':
45            return
46        if self.oneOnly:
47            El = wscs.ColourSelect(label=name[0], parent=self,colour=color,
48                pos=pos, size=wx.Size(self.butWid,23), style=wx.RAISED_BORDER)
49            El.Bind(wx.EVT_BUTTON, self.OnElButton)
50        else:
51            butWid = self.butWid
52            if name[0] == 'None':
53                butWid *= 2
54            El = wx.ComboBox(choices=name, parent=self, pos=pos, size=wx.Size(butWid,23),
55                style=wx.CB_READONLY, value=name[0])
56            El.Bind(wx.EVT_COMBOBOX,self.OnElButton)
57       
58        El.SetBackgroundColour(color)
59        El.SetToolTipString(tip)
60
61    def OnElButton(self, event):
62        if self.oneOnly:
63            El = event.GetEventObject().GetLabel()
64        else:
65            El = event.GetEventObject().GetValue()
66        self.Elem = El
67        self.EndModal(wx.ID_OK)       
68       
69class DeleteElement(wx.Dialog):
70    "Delete element from selected set widget"
71    def _init_ctrls(self, parent,choice):
72        l = len(choice)-1
73        wx.Dialog.__init__(self, id=-1, name='Delete', parent=parent, 
74              pos=wx.DefaultPosition, size=wx.Size(max(128,64+l*24), 87),
75              style=wx.DEFAULT_DIALOG_STYLE, title='Delete Element')
76        self.Show(True)
77        self.SetAutoLayout(True)
78        self.SetHelpText('Select element to delete')
79        self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
80
81        i = 0
82        Elem = []
83        for Elem in choice:
84            self.ElButton(id=-1,name=Elem,pos=wx.Point(16+i*24, 16))
85            i+=1
86             
87    def __init__(self, parent,choice):
88        DeleteElement.El = ' '
89        self._init_ctrls(parent,choice)
90
91    def ElButton(self, id, name, pos):
92        White = wx.Colour(255, 255, 255)
93        El = wscs.ColourSelect(label=name, parent=self, colour = White,
94            pos=pos, size=wx.Size(24, 23), style=wx.RAISED_BORDER)
95        El.Bind(wx.EVT_BUTTON, self.OnDeleteButton)
96   
97    def OnDeleteButton(self, event):
98        DeleteElement.El=event.GetEventObject().GetLabel()
99        self.EndModal(wx.ID_OK)
100       
101    def GetDeleteElement(self):
102        return DeleteElement.El
103       
104
Note: See TracBrowser for help on using the repository browser.