Changeset 2900 for branch


Ignore:
Timestamp:
Jul 4, 2017 9:37:13 AM (4 years ago)
Author:
toby
Message:

reorg for GUI separation pretty much complete (GSASIIIO.py still needs some thought)

Location:
branch/2frame
Files:
17 edited
2 moved

Legend:

Unmodified
Added
Removed
  • branch/2frame/GSASII.py

    r2899 r2900  
    1818import os
    1919import sys
     20import GSASIIpath
     21GSASIIpath.SetVersionNumber("$Revision$")
     22GSASIIpath.InvokeDebugOpts()
    2023
    2124__version__ = '0.3.0'
    2225
    23 # PATCH: for Mavericks (OS X 10.9.x), wx produces an annoying warning about LucidaGrandeUI.
    24 # In case stderr has been suppressed there, redirect python error output to stdout. Nobody
    25 # else should care much about this.
    26 sys.stderr = sys.stdout
    2726
    28 #def create(parent):
    29 #    return GSASII(parent)
    30 
    31 # class GSASIIsplit(wx.SplitterWindow):
    32 #     def __init__(self,parent,ID):
    33 #         wx.SplitterWindow.__init__(self, parent, ID,style = wx.SP_BORDER|wx.SP_LIVE_UPDATE)
    34 #         self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnSashChanged)
    35 #         self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGING, self.OnSashChanging)
    36 
    37 #     def OnSashChanged(self, evt):
    38 #         evt.Skip()
    39 # #        print "sash changed to %s\n" % str(evt.GetSashPosition())
    40 
    41 #     def OnSashChanging(self, evt):
    42 #         evt.Skip()
    43 # #        print "sash changing to %s\n" % str(evt.GetSashPosition())
    44    
    4527if __name__ == '__main__':
    46     import numpy as np
    47     import scipy as sp
    48     import wx
    49     import wx.lib.scrolledpanel as wxscroll
    50     try:  # patch for LANG environment var problem on occasional OSX machines
    51         import locale
    52         locale.getdefaultlocale()
    53     except ValueError:
    54         print('Fixing location (see https://github.com/matplotlib/matplotlib/issues/5420.)')
    55         os.environ['LC_ALL'] = 'en_US.UTF-8'
    56         locale.getdefaultlocale()
    57     import matplotlib as mpl
    58     try:
    59         import OpenGL as ogl
    60     except ImportError:
    61         print('*******************************************************')
    62         print('PyOpenGL is missing from your python installation')
    63         print('     - we will try to install it')
    64         print('*******************************************************')
    65         def install_with_easyinstall(package):
    66             try:
    67                 print "trying a system-wide PyOpenGl install"
    68                 easy_install.main(['-f',os.path.split(__file__)[0],package])
    69                 return
    70             except:
    71                 pass
    72             try:
    73                 print "trying a user level PyOpenGl install"
    74                 easy_install.main(['-f',os.path.split(__file__)[0],'--user',package])
    75                 return
    76             except:
    77                 print "Install of '+package+' failed. Please report this information:"
    78                 import traceback
    79                 print traceback.format_exc()
    80                 sys.exit()
    81         from setuptools.command import easy_install
    82         install_with_easyinstall('PyOpenGl')
    83         print('*******************************************************')         
    84         print('OpenGL has been installed. Restarting GSAS-II')
    85         print('*******************************************************')         
    86         loc = os.path.dirname(__file__)
    87         import subprocess
    88         subprocess.Popen([sys.executable,os.path.join(loc,'GSASII.py')])
    89         sys.exit()
    90 
    91     # load the GSAS routines
    92     import GSASIIpath
    93     GSASIIpath.SetVersionNumber("$Revision$")
    94     import GSASIIIO as G2IO
    95     import GSASIIElem as G2elem
    96     import GSASIIgrid as G2gd
    97     import GSASIIctrls as G2G
    98     import GSASIIplot as G2plt
    99     import GSASIIpwd as G2pwd
    100     import GSASIIpwdGUI as G2pdG
    101     import GSASIIspc as G2spc
    102     import GSASIIstrMain as G2stMn
    103     import GSASIIstrIO as G2stIO
    104     import GSASIImath as G2mth
    105     import GSASIImapvars as G2mv
    106     import GSASIIobj as G2obj
    107     import GSASIIlattice as G2lat
    108     import GSASIIlog as log
    109 #                GSASIIpath.IPyBreak()
    110     # print versions
    111     print "Python module versions loaded:"
    112     print "  Python:     ",sys.version.split()[0]
    113     print "  wx:         ",wx.__version__
    114     print "  matplotlib: ",mpl.__version__
    115     print "  numpy:      ",np.__version__
    116     print "  scipy:      ",sp.__version__
    117     print "  OpenGL:     ",ogl.__version__
    118     try:
    119         from PIL import Image
    120         try:
    121             from PIL import PILLOW_VERSION
    122             version = PILLOW_VERSION
    123         except:
    124             version = Image.VERSION
    125         print "  PIL.Image:  ",version
    126     except ImportError:
    127         try:
    128             import Image
    129             print "Image (PIL):",Image.VERSION
    130         except ImportError:
    131             print "Image module not present; Note that PIL (Python Imaging Library) or pillow is needed for some image operations"
    132     import platform
    133     print "  Platform:   ",sys.platform,platform.architecture()[0],platform.machine()
    134     try:
    135         import mkl
    136         print "  Max threads:",mkl.get_max_threads()
    137     except:
    138         pass
    139     #print "wxPython description",wx.PlatformInfo
    140     print "This is GSAS-II revision "+str(GSASIIpath.GetVersionNumber())+'\n'
    141     GSASIIpath.InvokeDebugOpts()
     28    import GSASIIdataGUI as G2gd   
    14229    G2gd.GSASIImain() # start the GUI
  • branch/2frame/GSASIIIO.py

    r2871 r2900  
    1818Also includes base classes for data import routines.
    1919
     20This module needs some work to separate wx from non-wx routines
    2021'''
    2122"""GSASIIIO: functions for IO of data
     
    3233import GSASIIpath
    3334GSASIIpath.SetVersionNumber("$Revision$")
    34 import GSASIIgrid as G2gd
     35import GSASIIdataGUI as G2gd
    3536import GSASIIobj as G2obj
    3637import GSASIIlattice as G2lat
     
    4243import GSASIIstrIO as G2stIO
    4344import GSASIImapvars as G2mv
    44 import GSASIIctrls as G2G
     45import GSASIIctrlGUI as G2G
    4546import os
    4647import os.path as ospath
     
    956957    selections are placed in self.chosen when OK is pressed
    957958
    958     Also see GSASIIctrls
     959    Also see GSASIIctrlGUI
    959960    '''
    960961    def __init__(self,choicelist,headinglist,
  • branch/2frame/GSASIIconstrGUI.py

    r2893 r2900  
    3131import GSASIImath as G2mth
    3232import GSASIIlattice as G2lat
    33 import GSASIIgrid as G2gd
    34 import GSASIIctrls as G2G
     33import GSASIIdataGUI as G2gd
     34import GSASIIctrlGUI as G2G
    3535import GSASIIplot as G2plt
    3636import GSASIIobj as G2obj
  • branch/2frame/GSASIIctrlGUI.py

    r2899 r2900  
    11# -*- coding: utf-8 -*-
    2 #GSASIIctrls - Custom GSAS-II GUI controls
     2#GSASIIctrlGUI - Custom GSAS-II GUI controls
    33########### SVN repository information ###################
    44# $Date$
     
    99########### SVN repository information ###################
    1010'''
    11 *GSASIIctrls: Custom GUI controls*
    12 -------------------------------------------
     11*GSASIIctrlGUI: Custom GUI controls*
     12---------------------------------------------
    1313
    1414A library of GUI controls for reuse throughout GSAS-II
    15 
    16 (at present many are still in GSASIIgrid, but with time will be moved here)
    1715
    1816'''
     
    3230import GSASIIpath
    3331GSASIIpath.SetVersionNumber("$Revision$")
    34 import GSASIIgrid as G2gd
     32import GSASIIdataGUI as G2gd
    3533import GSASIIpwdGUI as G2pdG
    3634import GSASIIpy3 as G2py3
     
    24692467    :returns: the selection index or None or a selection list if multiple is true
    24702468
    2471     Called by GSASIIgrid.OnReOrgSelSeq() which is not fully implemented.
     2469    Called by GSASIIdataGUI.OnReOrgSelSeq() Which is not fully implemented.
    24722470    '''
    24732471    if multiple:
  • branch/2frame/GSASIIdataGUI.py

    r2899 r2900  
    11# -*- coding: utf-8 -*-
    2 #GSASIIgrid - data display routines
     2#GSASIIdataGUI - Main GUI routines
    33########### SVN repository information ###################
    44# $Date$
     
    99########### SVN repository information ###################
    1010'''
    11 *GSASIIgrid: Basic GUI routines*
    12 --------------------------------
    13 
     11*GSASIIdataGUI: Main GSAS-II GUI*
     12------------------------------------
     13
     14Module that defines GUI routines and classes for the main GUI Frame (window)
     15and the main routines that define the GSAS-II tree panel and much of the
     16data editing panel.
    1417'''
    1518import time
     
    5255import GSASIIexprGUI as G2exG
    5356import GSASIIlog as log
    54 import GSASIIctrls as G2G
     57import GSASIIctrlGUI as G2G
    5558
    5659# trig functions in degrees
     
    155158Define_wxId('wxID_MCRON', 'wxID_MCRLIST', 'wxID_MCRSAVE', 'wxID_MCRPLAY',)
    156159
     160# these data definitions probably should be moved
    157161commonTrans = {'abc':np.eye(3),'a-cb':np.array([[1.,0.,0.],[0.,0.,-1.],[0.,1.,0.]]),
    158162    'ba-c':np.array([[0.,1.,0.],[1.,0.,0.],[0.,0.,-1.]]),'-cba':np.array([[0.,0.,-1.],[0.,1.,0.],[1.,0.,0.]]),
     
    329333        parent.Raise()
    330334        self.EndModal(wx.ID_CANCEL)
     335       
     336# class GSASIIsplit(wx.SplitterWindow):
     337#     def __init__(self,parent,ID):
     338#         wx.SplitterWindow.__init__(self, parent, ID,style = wx.SP_BORDER|wx.SP_LIVE_UPDATE)
     339#         self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnSashChanged)
     340#         self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGING, self.OnSashChanging)
     341
     342#     def OnSashChanged(self, evt):
     343#         evt.Skip()
     344# #        print "sash changed to %s\n" % str(evt.GetSashPosition())
     345
     346#     def OnSashChanging(self, evt):
     347#         evt.Skip()
     348# #        print "sash changing to %s\n" % str(evt.GetSashPosition())
     349
     350def GUIpatches():
     351    'Misc fixes that only needs to be done when running a GUI'
     352    try:  # patch for LANG environment var problem on occasional OSX machines
     353        import locale
     354        locale.getdefaultlocale()
     355    except ValueError:
     356        print('Fixing location (see https://github.com/matplotlib/matplotlib/issues/5420.)')
     357        os.environ['LC_ALL'] = 'en_US.UTF-8'
     358        locale.getdefaultlocale()
     359    try:
     360        import OpenGL as ogl
     361    except ImportError:
     362        print('*******************************************************')
     363        print('PyOpenGL is missing from your python installation')
     364        print('     - we will try to install it')
     365        print('*******************************************************')
     366        def install_with_easyinstall(package):
     367            try:
     368                print "trying a system-wide PyOpenGl install"
     369                easy_install.main(['-f',os.path.split(__file__)[0],package])
     370                return
     371            except:
     372                pass
     373            try:
     374                print "trying a user level PyOpenGl install"
     375                easy_install.main(['-f',os.path.split(__file__)[0],'--user',package])
     376                return
     377            except:
     378                print "Install of '+package+' failed. Please report this information:"
     379                import traceback
     380                print traceback.format_exc()
     381                sys.exit()
     382        from setuptools.command import easy_install
     383        install_with_easyinstall('PyOpenGl')
     384        print('*******************************************************')         
     385        print('OpenGL has been installed. Restarting GSAS-II')
     386        print('*******************************************************')         
     387        loc = os.path.dirname(__file__)
     388        import subprocess
     389        subprocess.Popen([sys.executable,os.path.join(loc,'GSASII.py')])
     390        sys.exit()
     391    # PATCH: for Mavericks (OS X 10.9.x), wx produces an annoying warning about LucidaGrandeUI.
     392    # In case stderr has been suppressed there, redirect python error output to stdout. Nobody
     393    # else should care much about this.
     394    sys.stderr = sys.stdout
     395
     396def ShowVersions():
     397    '''Show the versions all of required Python packages, etc.
     398    '''
     399    import numpy as np
     400    import scipy as sp
     401    import wx
     402    #import wx.lib.scrolledpanel as wxscroll
     403    import matplotlib as mpl
     404    import OpenGL as ogl
     405    # load the GSAS routines to update versions with GSASIIpath.SetVersionNumber
     406    import GSASIIpath
     407    import GSASIIIO as G2IO
     408    import GSASIIElem as G2elem
     409    import GSASIIctrlGUI as G2G
     410    import GSASIIplot as G2plt
     411    import GSASIIpwd as G2pwd
     412    import GSASIIpwdGUI as G2pdG
     413    import GSASIIspc as G2spc
     414    import GSASIIstrMain as G2stMn
     415    import GSASIIstrIO as G2stIO
     416    import GSASIImath as G2mth
     417    import GSASIImapvars as G2mv
     418    import GSASIIobj as G2obj
     419    import GSASIIlattice as G2lat
     420    import GSASIIlog as log
     421#                GSASIIpath.IPyBreak()
     422    # print versions
     423    print "Python module versions loaded:"
     424    print "  Python:     ",sys.version.split()[0]
     425    print "  wx:         ",wx.__version__
     426    print "  matplotlib: ",mpl.__version__
     427    print "  numpy:      ",np.__version__
     428    print "  scipy:      ",sp.__version__
     429    print "  OpenGL:     ",ogl.__version__
     430    try:
     431        from PIL import Image
     432        try:
     433            from PIL import PILLOW_VERSION
     434            version = PILLOW_VERSION
     435        except:
     436            version = Image.VERSION
     437        print "  PIL.Image:  ",version
     438    except ImportError:
     439        try:
     440            import Image
     441            print "Image (PIL):",Image.VERSION
     442        except ImportError:
     443            print "Image module not present; Note that PIL (Python Imaging Library) or pillow is needed for some image operations"
     444    import platform
     445    print "  Platform:   ",sys.platform,platform.architecture()[0],platform.machine()
     446    try:
     447        import mkl
     448        print "  Max threads:",mkl.get_max_threads()
     449    except:
     450        pass
     451    #print "wxPython description",wx.PlatformInfo
     452    print "This is GSAS-II revision "+str(GSASIIpath.GetVersionNumber())+'\n'
     453   
    331454###############################################################################
    332455# Main application
     
    334457def GSASIImain():
    335458    '''Start up the GSAS-II application'''
     459    ShowVersions()
     460    GUIpatches()
     461    #GSASIIpath.InvokeDebugOpts()
    336462    #application = GSASIImain() # don't redirect output, someday we
    337463    # may want to do this if we can
  • branch/2frame/GSASIIddataGUI.py

    r2892 r2900  
    2323import GSASIIspc as G2spc
    2424import GSASIIplot as G2plt
    25 import GSASIIgrid as G2gd
     25import GSASIIdataGUI as G2gd
    2626import GSASIIpwd as G2pwd
    2727import GSASIIphsGUI as G2phsGUI
    28 import GSASIIctrls as G2G
     28import GSASIIctrlGUI as G2G
    2929import numpy as np
    3030
  • branch/2frame/GSASIIexprGUI.py

    r2899 r2900  
    3030import GSASIIpath
    3131GSASIIpath.SetVersionNumber("$Revision$")
    32 import GSASIIgrid as G2gd
    33 import GSASIIctrls as G2G
     32import GSASIIdataGUI as G2gd
     33import GSASIIctrlGUI as G2G
    3434import GSASIIpy3 as G2py3
    3535import GSASIIobj as G2obj
  • branch/2frame/GSASIIimgGUI.py

    r2893 r2900  
    3333import GSASIIplot as G2plt
    3434import GSASIIIO as G2IO
    35 import GSASIIgrid as G2gd
    36 import GSASIIctrls as G2G
     35import GSASIIdataGUI as G2gd
     36import GSASIIctrlGUI as G2G
    3737import GSASIIobj as G2obj
    3838import GSASIIpy3 as G2py3
  • branch/2frame/GSASIIlog.py

    r2509 r2900  
    1616'''
    1717import wx
    18 import GSASIIgrid as G2gd
     18import GSASIIdataGUI as G2gd
    1919import GSASIIpath
    2020# Global variables
  • branch/2frame/GSASIIphsGUI.py

    r2899 r2900  
    3939import GSASIIddataGUI as G2ddG
    4040import GSASIIplot as G2plt
    41 import GSASIIgrid as G2gd
     41import GSASIIdataGUI as G2gd
    4242import GSASIIIO as G2IO
    4343import GSASIIstrMain as G2stMn
     
    4747import GSASIIpy3 as G2py3
    4848import GSASIIobj as G2obj
    49 import GSASIIctrls as G2G
     49import GSASIIctrlGUI as G2G
    5050import GSASIIconstrGUI as G2cnstG
    5151import numpy as np
     
    10651065    '''Create the data display window contents when a phase is clicked on
    10661066    in the main (data tree) window.
    1067     Called only from :meth:`GSASIIgrid.SelectDataTreeItem`,
     1067    Called only from :meth:`GSASIIdataGUI.SelectDataTreeItem`,
    10681068    which in turn is called from :meth:`GSASII.GSASII.OnDataTreeSelChanged`
    10691069    when a Phase tree item is selected. This creates all tabs on the page and fills
  • branch/2frame/GSASIIplot.py

    r2895 r2900  
    2727Clip_on = GSASIIpath.GetConfigValue('Clip_on')
    2828GSASIIpath.SetVersionNumber("$Revision$")
    29 import GSASIIgrid as G2gd
     29import GSASIIdataGUI as G2gd
    3030import GSASIIimage as G2img
    3131import GSASIIpwd as G2pwd
     
    3737import GSASIIspc as G2spc
    3838import GSASIImath as G2mth
    39 import GSASIIctrls as G2G
     39import GSASIIctrlGUI as G2G
     40import GSASIIobj as G2obj
    4041import pytexture as ptx
    4142#from  OpenGL.GL import *
     
    39533954    xvar = np.outer(sig,np.ones_like(sig))
    39543955    covArray = np.divide(np.divide(covMatrix,xvar),xvar.T)
    3955     title = ' for\n'+Data['title']
     3956    title = G2obj.StripUnicode(' for\n'+Data['title'],'') # matplotlib 1.x does not like unicode
    39563957    newAtomDict = Data.get('newAtomDict',{})
    39573958    G2frame.G2plotNB.status.DestroyChildren()
  • branch/2frame/GSASIIpwdGUI.py

    r2893 r2900  
    3737import GSASIIindex as G2indx
    3838import GSASIIplot as G2plt
    39 import GSASIIgrid as G2gd
    40 import GSASIIctrls as G2G
     39import GSASIIdataGUI as G2gd
     40import GSASIIctrlGUI as G2G
    4141import GSASIIElemGUI as G2elemGUI
    4242import GSASIIElem as G2elem
  • branch/2frame/GSASIIrestrGUI.py

    r2893 r2900  
    2525import GSASIIlattice as G2lat
    2626import GSASIIspc as G2spc
    27 import GSASIIgrid as G2gd
     27import GSASIIdataGUI as G2gd
    2828import GSASIIplot as G2plt
    2929import GSASIIdata as G2data
    30 import GSASIIctrls as G2G
     30import GSASIIctrlGUI as G2G
    3131
    3232VERY_LIGHT_GREY = wx.Colour(235,235,235)
  • branch/2frame/GSASIIstrMain.py

    r2899 r2900  
    468468
    469469    :param dict DisAglCtls: contains distance/angle radii usually defined using
    470        :func:`GSASIIctrls.DisAglDialog`
     470       :func:`GSASIIctrlGUI.DisAglDialog`
    471471    :param dict DisAglData: contains phase data:
    472472       Items 'OrigAtoms' and 'TargAtoms' contain the atoms to be used
     
    585585
    586586    :param dict DisAglCtls: contains distance/angle radii usually defined using
    587        :func:`GSASIIctrls.DisAglDialog`
     587       :func:`GSASIIctrlGUI.DisAglDialog`
    588588    :param dict DisAglData: contains phase data:
    589589       Items 'OrigAtoms' and 'TargAtoms' contain the atoms to be used
  • branch/2frame/exports/G2export_CIF.py

    r2899 r2900  
    3333GSASIIpath.SetVersionNumber("$Revision$")
    3434import GSASIIIO as G2IO
    35 import GSASIIgrid as G2gd
    36 import GSASIIctrls as G2G
     35import GSASIIdataGUI as G2gd
     36import GSASIIctrlGUI as G2G
    3737import GSASIImath as G2mth
    3838import GSASIIspc as G2spc
  • branch/2frame/exports/G2export_PDB.py

    r2819 r2900  
    2121GSASIIpath.SetVersionNumber("$Revision$")
    2222import GSASIIIO as G2IO
    23 #import GSASIIgrid as G2gd
    2423import GSASIIstrIO as G2stIO
    2524#import GSASIImath as G2mth
  • branch/2frame/exports/G2export_examples.py

    r2819 r2900  
    2626import GSASIIIO as G2IO
    2727import GSASIIpy3 as G2py3
    28 #import GSASIIgrid as G2gd
    2928#import GSASIIstrIO as G2stIO
    3029import GSASIImath as G2mth
  • branch/2frame/exports/G2export_map.py

    r2819 r2900  
    2323GSASIIpath.SetVersionNumber("$Revision$")
    2424import GSASIIIO as G2IO
    25 #import GSASIIgrid as G2gd
    2625#import GSASIIstrIO as G2stIO
    2726#import GSASIImath as G2mth
  • branch/2frame/testSSymbols.py

    r2895 r2900  
    33import wx
    44import GSASIIspc as G2spc
    5 import GSASIIgrid as G2gd
    6 import GSASIIctrls as G2G
     5import GSASIIdataGUI as G2gd
     6import GSASIIctrlGUI as G2G
    77import numpy as np
    88import copy
Note: See TracChangeset for help on using the changeset viewer.