Changeset 484 for trunk/GSASIIElem.py


Ignore:
Timestamp:
Feb 15, 2012 2:36:53 PM (10 years ago)
Author:
vondreele
Message:

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:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIElem.py

    r456 r484  
    11"""Element: functions for element types
    2    Copyright: 2008, Robert B. Von Dreele (Argonne National Laboratory)
     2   Copyright: 2008, Robert B. Von Dreele & Brian H. Toby (Argonne National Laboratory)
    33"""
    44########### SVN repository information ###################
     
    1010########### SVN repository information ###################
    1111
    12 import wx
    1312import math
    14 import sys
    1513import os.path
    16 import wx.lib.colourselect as wscs
    1714import GSASIIpath
    1815import numpy as np
     
    3936        FFdata = open(filename,'Ur')
    4037    except:
    41         wx.MessageBox(message="File atmdata.dat not found in directory %s" % sys.path[0],
    42             caption="No atmdata.dat file",style=wx.OK | wx.ICON_EXCLAMATION | wx.STAY_ON_TOP)
     38        print "**** ERROR - File atmdata.dat not found in directory %s" % sys.path[0]
    4339        sys.exit()
    4440    S = '1'
     
    8985        FFdata = open(filename,'Ur')
    9086    except:
    91         wx.MessageBox(message="File atmdata.dat not found in directory %s" % sys.path[0],
    92             caption="No atmdata.dat file",style=wx.OK | wx.ICON_EXCLAMATION | wx.STAY_ON_TOP)
     87        print '**** ERROR - File atmdata.dat not found in directory %s' % sys.path[0]
    9388        sys.exit()
    9489    S = '1'
     
    151146        xsec = open(filename,'Ur')
    152147    except:
    153         wx.MessageBox(message="File Xsect.dat not found in directory %s" % sys.path[0],
    154             caption="No Xsect.dat file",style=wx.OK | wx.ICON_EXCLAMATION |wx.STAY_ON_TOP)
     148        print '**** ERROR - File Xsect.dat not found in directory %s' % sys.path[0]
    155149        sys.exit()
    156150    S = '1'
     
    226220        FFdata = open(filename,'Ur')
    227221    except:
    228         wx.MessageBox(message="File atmdata.dat not found in directory %s" % sys.path[0],
    229             caption="No atmdata.dat file",style=wx.OK | wx.ICON_EXCLAMATION |wx.STAY_ON_TOP)
     222        print '**** ERROR - File atmdata.dat not found in directory %s' % sys.path[0]
    230223        sys.exit()
    231224    S = '1'
     
    387380   
    388381
    389 class PickElement(wx.Dialog):
    390     "Makes periodic table widget for picking element - caller maintains element list"
    391     Elem=None
    392     def _init_ctrls(self, prnt,oneOnly):
    393         wx.Dialog.__init__(self, id=-1, name='PickElement',
    394               parent=prnt, pos=wx.DefaultPosition,
    395               style=wx.DEFAULT_DIALOG_STYLE, title='Pick Element')
    396         import ElementTable as ET
    397         self.SetClientSize(wx.Size(770, 250))
    398        
    399         i=0
    400         for E in ET.ElTable:
    401             if oneOnly:
    402                 color=E[4]
    403             else:
    404                 color=E[6]
    405             PickElement.ElButton(self,name=E[0],
    406                pos=wx.Point(E[1]*40+25,E[2]*24+24),tip=E[3],color=color,oneOnly=oneOnly)
    407             i+=1
    408 
    409     def __init__(self, parent,oneOnly=False):
    410         self._init_ctrls(parent,oneOnly)
    411        
    412     def ElButton(self, name, pos, tip, color, oneOnly):
    413         Black = wx.Colour(0,0,0)
    414         if oneOnly:
    415             El = wscs.ColourSelect(label=name[0], parent=self,colour=color,
    416                 pos=pos, size=wx.Size(40,23), style=wx.RAISED_BORDER)
    417 #            El.SetLabel(name)
    418             El.Bind(wx.EVT_BUTTON, self.OnElButton)
    419         else:
    420             El = wx.ComboBox(choices=name, parent=self, pos=pos, size=wx.Size(40,23),
    421                 style=wx.CB_READONLY, value=name[0])
    422             El.Bind(wx.EVT_COMBOBOX,self.OnElButton)
    423        
    424         El.SetBackgroundColour(color)
    425         El.SetToolTipString(tip)
    426 
    427     def OnElButton(self, event):
    428         El = event.GetEventObject().GetLabel()
    429         self.Elem = El
    430         self.EndModal(wx.ID_OK)       
    431        
    432 class DeleteElement(wx.Dialog):
    433     "Delete element from selected set widget"
    434     def _init_ctrls(self, parent,choice):
    435         l = len(choice)-1
    436         wx.Dialog.__init__(self, id=-1, name='Delete', parent=parent,
    437               pos=wx.DefaultPosition, size=wx.Size(max(128,64+l*24), 87),
    438               style=wx.DEFAULT_DIALOG_STYLE, title='Delete Element')
    439         self.Show(True)
    440         self.SetAutoLayout(True)
    441         self.SetHelpText('Select element to delete')
    442         self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
    443 
    444         i = 0
    445         Elem = []
    446         for Elem in choice:
    447             self.ElButton(id=-1,name=Elem,pos=wx.Point(16+i*24, 16))
    448             i+=1
    449              
    450     def __init__(self, parent,choice):
    451         DeleteElement.El = ' '
    452         self._init_ctrls(parent,choice)
    453 
    454     def ElButton(self, id, name, pos):
    455         White = wx.Colour(255, 255, 255)
    456         El = wscs.ColourSelect(label=name, parent=self, colour = White,
    457             pos=pos, size=wx.Size(24, 23), style=wx.RAISED_BORDER)
    458         El.Bind(wx.EVT_BUTTON, self.OnDeleteButton)
    459    
    460     def OnDeleteButton(self, event):
    461         DeleteElement.El=event.GetEventObject().GetLabel()
    462         self.EndModal(wx.ID_OK)
    463        
    464     def GetDeleteElement(self):
    465         return DeleteElement.El
    466        
    467 
Note: See TracChangeset for help on using the changeset viewer.