source: trunk/GSASIIElemGUI.py @ 528

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

small fix to periodic table display
fix to PKS type instrument parms GUI

File size: 3.6 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,oneOnly):
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 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,oneOnly=oneOnly)
35            i+=1
36
37    def __init__(self, parent,oneOnly=False):
38        self._init_ctrls(parent,oneOnly)
39       
40    def ElButton(self, name, pos, tip, color, oneOnly):
41        Black = wx.Colour(0,0,0)
42        if oneOnly:
43            El = wscs.ColourSelect(label=name[0], parent=self,colour=color,
44                pos=pos, size=wx.Size(self.butWid,23), style=wx.RAISED_BORDER)
45#            El.SetLabel(name)
46            El.Bind(wx.EVT_BUTTON, self.OnElButton)
47        else:
48            El = wx.ComboBox(choices=name, parent=self, pos=pos, size=wx.Size(self.butWid,23),
49                style=wx.CB_READONLY, value=name[0])
50            El.Bind(wx.EVT_COMBOBOX,self.OnElButton)
51       
52        El.SetBackgroundColour(color)
53        El.SetToolTipString(tip)
54
55    def OnElButton(self, event):
56        El = event.GetEventObject().GetValue()
57        self.Elem = El
58        self.EndModal(wx.ID_OK)       
59       
60class DeleteElement(wx.Dialog):
61    "Delete element from selected set widget"
62    def _init_ctrls(self, parent,choice):
63        l = len(choice)-1
64        wx.Dialog.__init__(self, id=-1, name='Delete', parent=parent, 
65              pos=wx.DefaultPosition, size=wx.Size(max(128,64+l*24), 87),
66              style=wx.DEFAULT_DIALOG_STYLE, title='Delete Element')
67        self.Show(True)
68        self.SetAutoLayout(True)
69        self.SetHelpText('Select element to delete')
70        self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
71
72        i = 0
73        Elem = []
74        for Elem in choice:
75            self.ElButton(id=-1,name=Elem,pos=wx.Point(16+i*24, 16))
76            i+=1
77             
78    def __init__(self, parent,choice):
79        DeleteElement.El = ' '
80        self._init_ctrls(parent,choice)
81
82    def ElButton(self, id, name, pos):
83        White = wx.Colour(255, 255, 255)
84        El = wscs.ColourSelect(label=name, parent=self, colour = White,
85            pos=pos, size=wx.Size(24, 23), style=wx.RAISED_BORDER)
86        El.Bind(wx.EVT_BUTTON, self.OnDeleteButton)
87   
88    def OnDeleteButton(self, event):
89        DeleteElement.El=event.GetEventObject().GetLabel()
90        self.EndModal(wx.ID_OK)
91       
92    def GetDeleteElement(self):
93        return DeleteElement.El
94       
95
Note: See TracBrowser for help on using the repository browser.