source: trunk/GSASIIElemGUI.py @ 903

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

Fix problem with large constraints; Change binding of data item menus so they can be used from any window (Mac only); Start on AUI notebook (not in use); fix periodic table on Mac; capture error if argument file is not found; start on sphinx documentation formatting

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