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

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

File:
1 moved

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.