[GRASS-SVN] r57388 - in grass/trunk/gui/wxpython: animation core dbmgr gcp gmodeler iclass mapswipe psmap rlisetup vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Aug 4 02:06:49 PDT 2013
Author: martinl
Date: 2013-08-04 02:06:49 -0700 (Sun, 04 Aug 2013)
New Revision: 57388
Modified:
grass/trunk/gui/wxpython/animation/g.gui.animation.py
grass/trunk/gui/wxpython/core/utils.py
grass/trunk/gui/wxpython/dbmgr/g.gui.dbmgr.py
grass/trunk/gui/wxpython/gcp/g.gui.gcp.py
grass/trunk/gui/wxpython/gmodeler/g.gui.gmodeler.py
grass/trunk/gui/wxpython/iclass/g.gui.iclass.py
grass/trunk/gui/wxpython/mapswipe/g.gui.mapswipe.py
grass/trunk/gui/wxpython/psmap/g.gui.psmap.py
grass/trunk/gui/wxpython/rlisetup/g.gui.rlisetup.py
grass/trunk/gui/wxpython/vdigit/g.gui.vdigit.py
Log:
g.gui.*: define common GuiModuleMain fn
Modified: grass/trunk/gui/wxpython/animation/g.gui.animation.py
===================================================================
--- grass/trunk/gui/wxpython/animation/g.gui.animation.py 2013-08-03 21:57:44 UTC (rev 57387)
+++ grass/trunk/gui/wxpython/animation/g.gui.animation.py 2013-08-04 09:06:49 UTC (rev 57388)
@@ -63,12 +63,10 @@
from core.settings import UserSettings
from core.globalvar import CheckWxVersion
from core.giface import StandaloneGrassInterface
-from core.utils import _
+from core.utils import _, GuiModuleMain
from animation.frame import AnimationFrame, MAX_COUNT
def main():
- options, flags = grass.parser()
-
rast = options['rast']
vect = options['vect']
strds = options['strds']
@@ -114,8 +112,6 @@
app.MainLoop()
if __name__ == '__main__':
- # launch GUI in the background
- child_pid = os.fork()
- if child_pid == 0:
- main()
- os._exit(0)
+ options, flags = grass.parser()
+
+ GuiModuleMain(main)
Modified: grass/trunk/gui/wxpython/core/utils.py
===================================================================
--- grass/trunk/gui/wxpython/core/utils.py 2013-08-03 21:57:44 UTC (rev 57387)
+++ grass/trunk/gui/wxpython/core/utils.py 2013-08-04 09:06:49 UTC (rev 57388)
@@ -3,7 +3,7 @@
@brief Misc utilities for wxGUI
-(C) 2007-2009, 2011-2012 by the GRASS Development Team
+(C) 2007-2013 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.
@@ -1044,3 +1044,14 @@
missing_args.append(a)
return kwargs, missing_args
+
+def GuiModuleMain(mainfn):
+ """!Main function for g.gui.* modules
+
+ @param module's main function
+ """
+ # launch GUI in the background
+ child_pid = os.fork()
+ if child_pid == 0:
+ mainfn()
+ os._exit(0)
Modified: grass/trunk/gui/wxpython/dbmgr/g.gui.dbmgr.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/g.gui.dbmgr.py 2013-08-03 21:57:44 UTC (rev 57387)
+++ grass/trunk/gui/wxpython/dbmgr/g.gui.dbmgr.py 2013-08-04 09:06:49 UTC (rev 57388)
@@ -4,7 +4,7 @@
# MODULE: g.gui.dbmgr
# AUTHOR(S): Martin Landa <landa.martin gmail.com>
# PURPOSE: Attribute Table Manager
-# COPYRIGHT: (C) 2012 by Martin Landa, and the GRASS Development Team
+# COPYRIGHT: (C) 2012-2013 by Martin Landa, and the GRASS Development Team
#
# This program is free software; you can 1redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -39,7 +39,7 @@
if gui_wx_path not in sys.path:
sys.path.append(gui_wx_path)
-from core.utils import _
+from core.utils import _, GuiModuleMain
from dbmgr.manager import AttributeManager
def main():
@@ -61,8 +61,4 @@
if __name__ == "__main__":
options, flags = grass.parser()
- # launch GUI in the background
- child_pid = os.fork()
- if child_pid == 0:
- main()
- os._exit(0)
+ GuiModuleMain(main)
Modified: grass/trunk/gui/wxpython/gcp/g.gui.gcp.py
===================================================================
--- grass/trunk/gui/wxpython/gcp/g.gui.gcp.py 2013-08-03 21:57:44 UTC (rev 57387)
+++ grass/trunk/gui/wxpython/gcp/g.gui.gcp.py 2013-08-04 09:06:49 UTC (rev 57388)
@@ -47,9 +47,9 @@
from core.settings import UserSettings
from core.globalvar import CheckWxVersion
from core.giface import StandaloneGrassInterface
+from core.utils import GuiModuleMain
from gcp.manager import GCPWizard
-
def main():
"""!Sets the GRASS display driver
@@ -60,9 +60,7 @@
os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
else:
os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'
-
- options, flags = grass.parser()
-
+
app = wx.PySimpleApp()
if not CheckWxVersion([2, 9]):
wx.InitAllImageHandlers()
@@ -71,10 +69,7 @@
app.MainLoop()
-
if __name__ == '__main__':
- # launch GUI in the background
- child_pid = os.fork()
- if child_pid == 0:
- main()
- os._exit(0)
+ options, flags = grass.parser()
+
+ GuiModuleMain(main)
Modified: grass/trunk/gui/wxpython/gmodeler/g.gui.gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/g.gui.gmodeler.py 2013-08-03 21:57:44 UTC (rev 57387)
+++ grass/trunk/gui/wxpython/gmodeler/g.gui.gmodeler.py 2013-08-04 09:06:49 UTC (rev 57388)
@@ -47,11 +47,10 @@
from core.giface import StandaloneGrassInterface
from core.globalvar import CheckWxVersion
-from core.utils import _
+from core.utils import _, GuiModuleMain
from gmodeler.frame import ModelFrame
def main():
-
app = wx.PySimpleApp()
if not CheckWxVersion([2, 9]):
wx.InitAllImageHandlers()
@@ -65,8 +64,4 @@
if __name__ == "__main__":
options, flags = grass.parser()
- # launch GUI in the background
- child_pid = os.fork()
- if child_pid == 0:
- main()
- os._exit(0)
+ GuiModuleMain(main)
Modified: grass/trunk/gui/wxpython/iclass/g.gui.iclass.py
===================================================================
--- grass/trunk/gui/wxpython/iclass/g.gui.iclass.py 2013-08-03 21:57:44 UTC (rev 57387)
+++ grass/trunk/gui/wxpython/iclass/g.gui.iclass.py 2013-08-04 09:06:49 UTC (rev 57388)
@@ -62,7 +62,7 @@
from core.settings import UserSettings
from core.globalvar import CheckWxVersion
from core.giface import StandaloneGrassInterface
-from core.utils import _
+from core.utils import _, GuiModuleMain
from iclass.frame import IClassMapFrame
def main():
@@ -116,8 +116,4 @@
grass.set_raise_on_error(False)
options, flags = grass.parser()
- # launch GUI in the background
- child_pid = os.fork()
- if child_pid == 0:
- main()
- os._exit(0)
+ GuiModuleMain(main)
Modified: grass/trunk/gui/wxpython/mapswipe/g.gui.mapswipe.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/g.gui.mapswipe.py 2013-08-03 21:57:44 UTC (rev 57387)
+++ grass/trunk/gui/wxpython/mapswipe/g.gui.mapswipe.py 2013-08-04 09:06:49 UTC (rev 57388)
@@ -60,7 +60,7 @@
from core.settings import UserSettings
from core.globalvar import CheckWxVersion
from core.giface import StandaloneGrassInterface
-from core.utils import _
+from core.utils import _, GuiModuleMain
from mapswipe.frame import SwipeMapFrame
@@ -70,9 +70,7 @@
os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
else:
os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'
-
- options, flags = grass.parser()
-
+
first = options['first']
second = options['second']
mode = options['mode']
@@ -101,10 +99,7 @@
app.MainLoop()
-
if __name__ == '__main__':
- # launch GUI in the background
- child_pid = os.fork()
- if child_pid == 0:
- main()
- os._exit(0)
+ options, flags = grass.parser()
+
+ GuiModuleMain(main)
Modified: grass/trunk/gui/wxpython/psmap/g.gui.psmap.py
===================================================================
--- grass/trunk/gui/wxpython/psmap/g.gui.psmap.py 2013-08-03 21:57:44 UTC (rev 57387)
+++ grass/trunk/gui/wxpython/psmap/g.gui.psmap.py 2013-08-04 09:06:49 UTC (rev 57388)
@@ -44,13 +44,11 @@
sys.path.append(wxbase)
from core.globalvar import CheckWxVersion
-from core.utils import _
+from core.utils import _, GuiModuleMain
from psmap.frame import PsMapFrame
from psmap.instructions import Instruction
def main():
- gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
-
app = wx.PySimpleApp()
if not CheckWxVersion([2, 9]):
wx.InitAllImageHandlers()
@@ -65,9 +63,4 @@
if __name__ == "__main__":
options, flags = grass.parser()
- # launch GUI in the background
- child_pid = os.fork()
- if child_pid == 0:
- main()
- os._exit(0)
-
+ GuiModuleMain(main)
Modified: grass/trunk/gui/wxpython/rlisetup/g.gui.rlisetup.py
===================================================================
--- grass/trunk/gui/wxpython/rlisetup/g.gui.rlisetup.py 2013-08-03 21:57:44 UTC (rev 57387)
+++ grass/trunk/gui/wxpython/rlisetup/g.gui.rlisetup.py 2013-08-04 09:06:49 UTC (rev 57388)
@@ -36,9 +36,9 @@
if wxbase not in sys.path:
sys.path.append(wxbase)
-from core.giface import StandaloneGrassInterface
+from core.giface import StandaloneGrassInterface
from core.globalvar import CheckWxVersion
-from core.utils import _
+from core.utils import _, GuiModuleMain
from rlisetup.frame import RLiSetupFrame
@@ -53,9 +53,5 @@
if __name__ == "__main__":
options, flags = grass.parser()
-
- # launch GUI in the background
- child_pid = os.fork()
- if child_pid == 0:
- main()
- os._exit(0)
+
+ GuiModuleMain(main)
Modified: grass/trunk/gui/wxpython/vdigit/g.gui.vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/g.gui.vdigit.py 2013-08-03 21:57:44 UTC (rev 57387)
+++ grass/trunk/gui/wxpython/vdigit/g.gui.vdigit.py 2013-08-04 09:06:49 UTC (rev 57388)
@@ -4,7 +4,7 @@
# MODULE: g.gui.vdigit
# AUTHOR(S): Martin Landa <landa.martin gmail.com>
# PURPOSE: wxGUI Vector Digitizer
-# COPYRIGHT: (C) 2007-2012 by Martin Landa, and the GRASS Development Team
+# COPYRIGHT: (C) 2007-2013 by Martin Landa, and the GRASS Development Team
#
# This program is free software; you can 1redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -43,11 +43,11 @@
sys.path.append(gui_wx_path)
from core.globalvar import CheckWxVersion
-from core.utils import _
-from mapdisp.frame import MapFrame
-from core.giface import StandaloneGrassInterface
-from core.settings import UserSettings
-from vdigit.main import haveVDigit, errorMsg
+from core.utils import _, GuiModuleMain
+from mapdisp.frame import MapFrame
+from core.giface import StandaloneGrassInterface
+from core.settings import UserSettings
+from vdigit.main import haveVDigit, errorMsg
class VDigitMapFrame(MapFrame):
def __init__(self, vectorMap):
@@ -67,13 +67,6 @@
self.toolbars['vdigit'].StartEditing(mapLayer)
def main():
- if not haveVDigit:
- grass.fatal(_("Vector digitizer not available. %s") % errorMsg)
-
- if not grass.find_file(name = options['map'], element = 'vector',
- mapset = grass.gisenv()['MAPSET'])['fullname']:
- grass.fatal(_("Vector map <%s> not found in current mapset") % options['map'])
-
# allow immediate rendering
driver = UserSettings.Get(group = 'display', key = 'driver', subkey = 'type')
if driver == 'png':
@@ -91,10 +84,14 @@
if __name__ == "__main__":
grass.set_raise_on_error(False)
+
options, flags = grass.parser()
- # launch GUI in the background
- child_pid = os.fork()
- if child_pid == 0:
- main()
- os._exit(0)
+ if not haveVDigit:
+ grass.fatal(_("Vector digitizer not available. %s") % errorMsg)
+
+ if not grass.find_file(name = options['map'], element = 'vector',
+ mapset = grass.gisenv()['MAPSET'])['fullname']:
+ grass.fatal(_("Vector map <%s> not found in current mapset") % options['map'])
+
+ GuiModuleMain(main)
More information about the grass-commit
mailing list