22# -*- coding: utf-8 -*-
33#GSASII
44'''
5- A single class, :class:`G2App`, is defined here to create
6- an wxPython application. This is only used on
7- MacOS. For other platforms ``wx.App()`` is called directly.
5+ A single class, :class:`G2App`, is defined here to create
6+ an wxPython application. This is only used on
7+ MacOS. For other platforms ``wx.App()`` is called directly.
88'''
99
1010import sys
11- #import platform
12- import scipy .optimize # loading here addresses problem with build for wx on Pi
11+
12+ from . import GSASIIpath
13+
14+ __version__ = '2.0.0'
1315try :
16+ from . import git_verinfo
17+ __version__ = git_verinfo .git_tags [0 ]
18+ except ImportError :
19+ pass
20+
21+
22+ def main ():
23+ import scipy .optimize # loading here addresses problem with build for wx on Pi
1424 import wx
1525 # the next line removes the need for pythonw. Thanks to Matt Newville!
1626 # appears unneeded from wx 4.2.1 on
17- if sys .platform .lower () == 'darwin' : wx .PyApp .IsDisplayAvailable = lambda _ : True
18- # importing the following wx modules at the same time as wx seems to eliminate
19- # the "Debug: Adding duplicate image handler for 'Windows bitmap file'"
20- # error message
27+ if sys .platform .lower () == 'darwin' :
28+ wx .PyApp .IsDisplayAvailable = lambda _ : True
29+ # importing the following wx modules at the same time as wx seems to
30+ # eliminate the "Debug: Adding duplicate image handler for 'Windows bitmap
31+ # file'" error message
2132 import wx .grid as wg
2233 import wx .aui
2334 import wx .lib .scrolledpanel as wxscroll
2435 import wx .lib .mixins .listctrl as listmix
2536 import wx .richtext as wxrt
2637 import wx .lib .filebrowsebutton as wxfilebrowse
2738 wg ,wx .aui ,wxscroll ,listmix ,wxrt ,wxfilebrowse ,scipy .optimize # avoid unused warning
28- except ImportError :
29- pass
30- import GSASIIpath
3139
32- __version__ = '2.0.0'
33- try :
34- import git_verinfo
35- __version__ = git_verinfo .git_tags [0 ]
36- except :
37- pass
38-
39- class G2App (wx .App ):
40- '''Used to create a wx python application for the GUI for Mac.
41- Customized to implement drop of GPX files onto app.
42- '''
43- startupMode = True
44- def ClearStartup (self ):
45- '''Call this after app startup complete because a Drop event is posted
46- when GSAS-II is initially started.
47- '''
48- self .startupMode = False
49- def MacOpenFiles (self , filenames ):
50- if self .startupMode :
51- return
52- import GSASIIfiles
53- for project in filenames :
54- #print("Start GSAS-II with project file "+str(project))
55- #GSASIIpath.MacStartGSASII(__file__,project)
56- GSASIIfiles .openInNewTerm (project )
40+ if sys .platform == "darwin" :
41+ class G2App (wx .App ):
42+ '''Used to create a wx python application for the GUI for Mac.
43+ Customized to implement drop of GPX files onto app.
44+ '''
45+ startupMode = True
46+ def ClearStartup (self ):
47+ '''Call this after app startup complete because a Drop event is posted
48+ when GSAS-II is initially started.
49+ '''
50+ self .startupMode = False
51+ def MacOpenFiles (self , filenames ):
52+ if self .startupMode :
53+ return
54+ from . import GSASIIfiles
55+ for project in filenames :
56+ #print("Start GSAS-II with project file "+str(project))
57+ #GSASIIpath.MacStartGSASII(__file__,project)
58+ GSASIIfiles .openInNewTerm (project )
5759
58- if __name__ == '__main__' :
59- if sys .platform == "darwin" :
6060 application = G2App (0 ) # create the GUI framework
6161 else :
6262 application = wx .App (0 ) # create the GUI framework
@@ -71,10 +71,10 @@ def MacOpenFiles(self, filenames):
7171 sys .exit ()
7272 # print('Unable to run with current setup, do you want to update to the')
7373 # try:
74- # if '2' in platform.python_version_tuple()[0]:
74+ # if '2' in platform.python_version_tuple()[0]:
7575 # ans = raw_input("latest GSAS-II version? Update ([Yes]/no): ")
7676 # else:
77- # ans = input("latest GSAS-II version? Update ([Yes]/no): ")
77+ # ans = input("latest GSAS-II version? Update ([Yes]/no): ")
7878 # except:
7979 # ans = 'no'
8080 # if ans.strip().lower() == "no":
@@ -89,9 +89,12 @@ def MacOpenFiles(self, filenames):
8989 # elif GSASIIpath.HowIsG2Installed().startswith('svn'):
9090 # svnCheckUpdates(None)
9191 # else:
92- import GSASIIdataGUI as G2gd
92+ from . import GSASIIdataGUI as G2gd
9393 G2gd .GSASIImain (application ) # start the GUI
94- if sys .platform == "darwin" :
94+ if sys .platform == "darwin" :
9595 wx .CallLater (50 ,application .ClearStartup )
9696 GSASIIpath .InvokeDebugOpts ()
9797 application .MainLoop ()
98+
99+ if __name__ == '__main__' :
100+ main ()
0 commit comments