/usr/lib/grass72/gui/wxpython/wxgui.py is in grass-gui 7.2.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | """
@package wxgui
@brief Main Python application for GRASS wxPython GUI
Classes:
- wxgui::GMApp
(C) 2006-2015 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
@author Michael Barton (Arizona State University)
@author Jachym Cepicky (Mendel University of Agriculture)
@author Martin Landa <landa.martin gmail.com>
@author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
"""
import os
import sys
import getopt
import atexit
from core import globalvar
from core.utils import _, registerPid, unregisterPid
from grass.exceptions import Usage
from grass.script.core import set_raise_on_error
import wx
try:
import wx.lib.agw.advancedsplash as SC
except ImportError:
SC = None
class GMApp(wx.App):
def __init__(self, workspace=None):
""" Main GUI class.
: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, "splash_screen.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
# and raises annoying (though seemingly harmless) errors everytime
# the GUI is started
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))
splash.SetTextFont(
wx.Font(
pointSize=15,
family=wx.DEFAULT,
style=wx.NORMAL,
weight=wx.BOLD))
splash.SetTextPosition((150, 430))
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
from lmgr.frame import GMFrame
mainframe = GMFrame(parent=None, id=wx.ID_ANY,
workspace=self.workspaceFile)
mainframe.Show()
self.SetTopWindow(mainframe)
return True
def printHelp():
""" Print program help"""
print >> sys.stderr, "Usage:"
print >> sys.stderr, " python wxgui.py [options]"
print >> sys.stderr, "%sOptions:" % os.linesep
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()
elif o in ("-w", "--workspace"):
if a != '':
workspaceFile = str(a)
else:
workspaceFile = args.pop(0)
return workspaceFile
def cleanup():
unregisterPid(os.getpid())
def main(argv=None):
if argv is None:
argv = sys.argv
try:
try:
opts, args = getopt.getopt(argv[1:], "hw:",
["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)
app = GMApp(workspaceFile)
# suppress wxPython logs
q = wx.LogNull()
set_raise_on_error(True)
# register GUI PID
registerPid(os.getpid())
app.MainLoop()
if __name__ == "__main__":
atexit.register(cleanup)
sys.exit(main())
|