|
@@ -1,4 +1,4 @@
|
|
|
-"""
|
|
|
+"""
|
|
|
@package wxgui
|
|
|
|
|
|
@brief Main Python application for GRASS wxPython GUI
|
|
@@ -25,6 +25,8 @@ import getopt
|
|
|
from core import globalvar
|
|
|
from core.utils import _
|
|
|
|
|
|
+from grass.exceptions import Usage
|
|
|
+
|
|
|
import wx
|
|
|
try:
|
|
|
import wx.lib.agw.advancedsplash as SC
|
|
@@ -33,6 +35,7 @@ except ImportError:
|
|
|
|
|
|
from lmgr.frame import GMFrame
|
|
|
|
|
|
+
|
|
|
class GMApp(wx.App):
|
|
|
def __init__(self, workspace = None):
|
|
|
""" Main GUI class.
|
|
@@ -40,28 +43,28 @@ class GMApp(wx.App):
|
|
|
:param workspace: path to the workspace file
|
|
|
"""
|
|
|
self.workspaceFile = workspace
|
|
|
-
|
|
|
+
|
|
|
# call parent class initializer
|
|
|
wx.App.__init__(self, False)
|
|
|
-
|
|
|
+
|
|
|
self.locale = wx.Locale(language = wx.LANGUAGE_DEFAULT)
|
|
|
-
|
|
|
+
|
|
|
def OnInit(self):
|
|
|
""" Initialize all available image handlers
|
|
|
-
|
|
|
+
|
|
|
:return: True
|
|
|
"""
|
|
|
if not globalvar.CheckWxVersion([2, 9]):
|
|
|
wx.InitAllImageHandlers()
|
|
|
-
|
|
|
+
|
|
|
# create splash screen
|
|
|
introImagePath = os.path.join(globalvar.IMGDIR, "silesia_splash.png")
|
|
|
introImage = wx.Image(introImagePath, wx.BITMAP_TYPE_PNG)
|
|
|
introBmp = introImage.ConvertToBitmap()
|
|
|
if SC and sys.platform != 'darwin':
|
|
|
- # AdvancedSplash is buggy on the Mac as of 2.8.12.1
|
|
|
+ # AdvancedSplash is buggy on the Mac as of 2.8.12.1
|
|
|
# and raises annoying (though seemingly harmless) errors everytime the GUI is started
|
|
|
- splash = SC.AdvancedSplash(bitmap = introBmp,
|
|
|
+ splash = SC.AdvancedSplash(bitmap = introBmp,
|
|
|
timeout = 2000, parent = None, id = wx.ID_ANY)
|
|
|
splash.SetText(_('Starting GRASS GUI...'))
|
|
|
splash.SetTextColour(wx.Colour(45, 52, 27))
|
|
@@ -71,21 +74,18 @@ class GMApp(wx.App):
|
|
|
else:
|
|
|
wx.SplashScreen (bitmap = introBmp, splashStyle = wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
|
|
|
milliseconds = 2000, parent = None, id = wx.ID_ANY)
|
|
|
-
|
|
|
+
|
|
|
wx.Yield()
|
|
|
-
|
|
|
+
|
|
|
# create and show main frame
|
|
|
mainframe = GMFrame(parent = None, id = wx.ID_ANY,
|
|
|
workspace = self.workspaceFile)
|
|
|
-
|
|
|
+
|
|
|
mainframe.Show()
|
|
|
self.SetTopWindow(mainframe)
|
|
|
-
|
|
|
+
|
|
|
return True
|
|
|
|
|
|
-class Usage(Exception):
|
|
|
- def __init__(self, msg):
|
|
|
- self.msg = msg
|
|
|
|
|
|
def printHelp():
|
|
|
""" Print program help"""
|
|
@@ -95,13 +95,14 @@ def printHelp():
|
|
|
print >> sys.stderr, " -w\t--workspace file\tWorkspace file to load"
|
|
|
sys.exit(1)
|
|
|
|
|
|
+
|
|
|
def process_opt(opts, args):
|
|
|
""" Process command-line arguments"""
|
|
|
workspaceFile = None
|
|
|
for o, a in opts:
|
|
|
if o in ("-h", "--help"):
|
|
|
printHelp()
|
|
|
-
|
|
|
+
|
|
|
if o in ("-w", "--workspace"):
|
|
|
if a != '':
|
|
|
workspaceFile = str(a)
|
|
@@ -110,8 +111,9 @@ def process_opt(opts, args):
|
|
|
|
|
|
return (workspaceFile,)
|
|
|
|
|
|
+
|
|
|
def main(argv = None):
|
|
|
-
|
|
|
+
|
|
|
if argv is None:
|
|
|
argv = sys.argv
|
|
|
try:
|
|
@@ -120,19 +122,19 @@ def main(argv = None):
|
|
|
["help", "workspace"])
|
|
|
except getopt.error as msg:
|
|
|
raise Usage(msg)
|
|
|
-
|
|
|
+
|
|
|
except Usage as err:
|
|
|
print >> sys.stderr, err.msg
|
|
|
print >> sys.stderr, "for help use --help"
|
|
|
printHelp()
|
|
|
-
|
|
|
+
|
|
|
workspaceFile = process_opt(opts, args)[0]
|
|
|
-
|
|
|
+
|
|
|
app = GMApp(workspaceFile)
|
|
|
# suppress wxPython logs
|
|
|
q = wx.LogNull()
|
|
|
-
|
|
|
+
|
|
|
app.MainLoop()
|
|
|
-
|
|
|
+
|
|
|
if __name__ == "__main__":
|
|
|
sys.exit(main())
|