source: trunk/GSASIIElemGUI.py @ 484

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

change authorship
split GSASIIelem into a GUI & non-GUI parts
replace MsgDialogs? in GSASIIElem.py with simple prints
cleanup & refactor distance/angle/torsion calcs.

File size: 3.4 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 wx.lib.colourselect as wscs
13class PickElement(wx.Dialog):
14    "Makes periodic table widget for picking element - caller maintains element list"
15    Elem=None
16    def _init_ctrls(self, prnt,oneOnly):
17        wx.Dialog.__init__(self, id=-1, name='PickElement',
18              parent=prnt, pos=wx.DefaultPosition, 
19              style=wx.DEFAULT_DIALOG_STYLE, title='Pick Element')
20        import ElementTable as ET
21        self.SetClientSize(wx.Size(770, 250))
22       
23        i=0
24        for E in ET.ElTable:
25            if oneOnly:
26                color=E[4]
27            else:
28                color=E[6]
29            PickElement.ElButton(self,name=E[0],
30               pos=wx.Point(E[1]*40+25,E[2]*24+24),tip=E[3],color=color,oneOnly=oneOnly)
31            i+=1
32
33    def __init__(self, parent,oneOnly=False):
34        self._init_ctrls(parent,oneOnly)
35       
36    def ElButton(self, name, pos, tip, color, oneOnly):
37        Black = wx.Colour(0,0,0)
38        if oneOnly:
39            El = wscs.ColourSelect(label=name[0], parent=self,colour=color,
40                pos=pos, size=wx.Size(40,23), style=wx.RAISED_BORDER)
41#            El.SetLabel(name)
42            El.Bind(wx.EVT_BUTTON, self.OnElButton)
43        else:
44            El = wx.ComboBox(choices=name, parent=self, pos=pos, size=wx.Size(40,23),
45                style=wx.CB_READONLY, value=name[0])
46            El.Bind(wx.EVT_COMBOBOX,self.OnElButton)
47       
48        El.SetBackgroundColour(color)
49        El.SetToolTipString(tip)
50
51    def OnElButton(self, event):
52        El = event.GetEventObject().GetLabel()
53        self.Elem = El
54        self.EndModal(wx.ID_OK)       
55       
56class DeleteElement(wx.Dialog):
57    "Delete element from selected set widget"
58    def _init_ctrls(self, parent,choice):
59        l = len(choice)-1
60        wx.Dialog.__init__(self, id=-1, name='Delete', parent=parent, 
61              pos=wx.DefaultPosition, size=wx.Size(max(128,64+l*24), 87),
62              style=wx.DEFAULT_DIALOG_STYLE, title='Delete Element')
63        self.Show(True)
64        self.SetAutoLayout(True)
65        self.SetHelpText('Select element to delete')
66        self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
67
68        i = 0
69        Elem = []
70        for Elem in choice:
71            self.ElButton(id=-1,name=Elem,pos=wx.Point(16+i*24, 16))
72            i+=1
73             
74    def __init__(self, parent,choice):
75        DeleteElement.El = ' '
76        self._init_ctrls(parent,choice)
77
78    def ElButton(self, id, name, pos):
79        White = wx.Colour(255, 255, 255)
80        El = wscs.ColourSelect(label=name, parent=self, colour = White,
81            pos=pos, size=wx.Size(24, 23), style=wx.RAISED_BORDER)
82        El.Bind(wx.EVT_BUTTON, self.OnDeleteButton)
83   
84    def OnDeleteButton(self, event):
85        DeleteElement.El=event.GetEventObject().GetLabel()
86        self.EndModal(wx.ID_OK)
87       
88    def GetDeleteElement(self):
89        return DeleteElement.El
90       
91
Note: See TracBrowser for help on using the repository browser.