source: trunk/GSASII.py @ 4800

Last change on this file since 4800 was 4800, checked in by toby, 2 years ago

finish up docs cleanups

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Date Author Revision URL Id
File size: 2.7 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#GSASII
4########### SVN repository information ###################
5# $Date: 2021-02-03 17:50:38 +0000 (Wed, 03 Feb 2021) $
6# $Author: toby $
7# $Revision: 4800 $
8# $URL: trunk/GSASII.py $
9# $Id: GSASII.py 4800 2021-02-03 17:50:38Z toby $
10########### SVN repository information ###################
11'''
12*GSASII: GSAS-II GUI*
13=====================
14
15File GSASII.py is the script to start the GSAS-II graphical user
16interface (GUI).
17This script imports GSASIIpath, which does some minor initialization
18and then (before any wxPython calls can be made) creates a wx.App application.
19A this point :func:`GSASIIpath.SetBinaryPath` is called to establish
20the directory where GSAS-II binaries are found. If the binaries
21are not installed or are incompatible with the OS/Python packages,
22the user is asked if they should be updated from the subversion site.
23The wxPython app is then passed to :func:`GSASIIdataGUI.GSASIImain`,
24which creates the GSAS-II GUI and finally the event loop is started.
25'''
26
27import sys
28#import os
29import platform
30import wx
31import GSASIIpath
32GSASIIpath.SetVersionNumber("$Revision: 4800 $")
33
34__version__ = '1.0.0'
35
36class G2App(wx.App):
37    '''Used to create a wx python application for the GUI for Mac.
38    Customized to implement drop of GPX files onto app.
39    '''
40    startupMode = True
41    def ClearStartup(self):
42        '''Call this after app startup complete because a Drop event is posted
43        when GSAS-II is initially started.
44        '''
45        self.startupMode = False       
46    def MacOpenFiles(self, filenames):
47        if self.startupMode:
48            return
49        for project in filenames:
50            #print("Start GSAS-II with project file "+str(project))
51            GSASIIpath.MacStartGSASII(__file__,project)
52
53if __name__ == '__main__':
54    if sys.platform == "darwin": 
55        application = G2App(0) # create the GUI framework
56    else:
57        application = wx.App(0) # create the GUI framework
58    try:
59        GSASIIpath.SetBinaryPath(True)
60    except:
61        print('Unable to run with current setup, do you want to update to the')
62        try:
63            if '2' in platform.python_version_tuple()[0]:           
64                ans = raw_input("latest GSAS-II version? Update ([Yes]/no): ")
65            else:
66                ans = input("latest GSAS-II version? Update ([Yes]/no): ")               
67        except:
68            ans = 'no'
69        if ans.strip().lower() == "no":
70            import sys
71            print('Exiting')
72            sys.exit()
73        print('Updating...')
74        GSASIIpath.svnUpdateProcess()
75    import GSASIIdataGUI as G2gd   
76    G2gd.GSASIImain(application) # start the GUI
77    if sys.platform == "darwin": 
78        wx.CallLater(100,application.ClearStartup)
79    GSASIIpath.InvokeDebugOpts()
80    application.MainLoop()
Note: See TracBrowser for help on using the repository browser.