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 | |
---|
15 | File GSASII.py is the script to start the GSAS-II graphical user |
---|
16 | interface (GUI). |
---|
17 | This script imports GSASIIpath, which does some minor initialization |
---|
18 | and then (before any wxPython calls can be made) creates a wx.App application. |
---|
19 | A this point :func:`GSASIIpath.SetBinaryPath` is called to establish |
---|
20 | the directory where GSAS-II binaries are found. If the binaries |
---|
21 | are not installed or are incompatible with the OS/Python packages, |
---|
22 | the user is asked if they should be updated from the subversion site. |
---|
23 | The wxPython app is then passed to :func:`GSASIIdataGUI.GSASIImain`, |
---|
24 | which creates the GSAS-II GUI and finally the event loop is started. |
---|
25 | ''' |
---|
26 | |
---|
27 | import sys |
---|
28 | #import os |
---|
29 | import platform |
---|
30 | import wx |
---|
31 | import GSASIIpath |
---|
32 | GSASIIpath.SetVersionNumber("$Revision: 4800 $") |
---|
33 | |
---|
34 | __version__ = '1.0.0' |
---|
35 | |
---|
36 | class 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 | |
---|
53 | if __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() |
---|