source: trunk/GSASIIElemGUI.py @ 923

Last change on this file since 923 was 923, checked in by toby, 8 years ago

more doc updates

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