[GRASS-SVN] r47387 - in grass/branches/develbranch_6/gui/wxpython: . gui_modules icons

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Aug 3 12:54:06 EDT 2011


Author: martinl
Date: 2011-08-03 09:54:06 -0700 (Wed, 03 Aug 2011)
New Revision: 47387

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/ghelp.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/location_wizard.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mcalc_builder.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/psmap.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/sqlbuilder.py
   grass/branches/develbranch_6/gui/wxpython/icons/grass_icons.py
   grass/branches/develbranch_6/gui/wxpython/icons/icon.py
   grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI: clean up - gettext and __main__
       (merge r47386 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -35,10 +35,6 @@
 import copy
 import types
 
-### i18N
-import gettext
-gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
-
 import globalvar
 import wx
 import wx.lib.mixins.listctrl as listmix
@@ -3048,30 +3044,28 @@
 
         event.Skip()
 
-def main(argv=None):
+def main(argv = None):
+    import gettext
+    gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
+    
     if argv is None:
         argv = sys.argv
-
+    
     if len(argv) != 2:
         print >> sys.stderr, __doc__
         sys.exit()
-
-    # Command line arguments of the script to be run are preserved by the
-    # hotswap.py wrapper but hotswap.py and its options are removed that
-    # sys.argv looks as if no wrapper was present.
-    #print "argv:", `argv`
-
+    
     #some applications might require image handlers
     wx.InitAllImageHandlers()
-
+    
     app = wx.PySimpleApp()
     f = AttributeManager(parent=None, id=wx.ID_ANY,
                          title="%s - <%s>" % (_("GRASS GIS Attribute Table Manager"),
                                               argv[1]),
                          size=(900,600), vectorName=argv[1])
     f.Show()
-
+    
     app.MainLoop()
-
+    
 if __name__ == '__main__':
     main()

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/ghelp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/ghelp.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/ghelp.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -23,6 +23,7 @@
 """
 
 import os
+import codecs
 
 import wx
 try:
@@ -667,7 +668,7 @@
         """Contributors info"""
         contribfile = os.path.join(os.getenv("GISBASE"), "contributors.csv")
         if os.path.exists(contribfile):
-            contribFile = open(contribfile, 'r')
+            contribFile = codecs.open(contribfile, encoding = 'utf-8', mode = 'r')
             contribs = dict()
             errLines = list()
             for line in contribFile.readlines():

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -20,9 +20,6 @@
 
 if not os.getenv("GISBASE"):
     sys.exit("GRASS is not running. Exiting...")
-### i18N
-import gettext
-gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
 
 # path to python scripts
 ETCDIR = os.path.join(os.getenv("GISBASE"), "etc")

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -4552,6 +4552,9 @@
 
         
 def main():
+    import gettext
+    gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
+    
     app = wx.PySimpleApp()
     wx.InitAllImageHandlers()
     frame = ModelFrame(parent = None)

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/location_wizard.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/location_wizard.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/location_wizard.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -2668,11 +2668,3 @@
         self.transnum = self.translist.GetSelection()
         self.transnum = self.transnum - 1
         return self.transnum
-
-if __name__ == "__main__":
-    import gettext
-    gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
-    app = wx.PySimpleApp()
-    gWizard = RegionDef(None)
-    gWizzard.Show()
-    app.MainLoop()

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mcalc_builder.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mcalc_builder.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mcalc_builder.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -543,8 +543,10 @@
         self.Destroy()
 
 if __name__ == "__main__":
+    import gettext
+    gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
+    
     app = wx.App(0)
     frame = MapCalcFrame(parent = None, cmd = 'r.mapcalc')
     frame.Show()
     app.MainLoop()
-

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -52,10 +52,6 @@
 import Queue
 import tempfile
 
-### i18N
-import gettext
-gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
-
 import globalvar
 import wx
 import wx.html
@@ -1920,9 +1916,12 @@
         return self.GetPageIndex(self.notebookPages[page])
     
 if __name__ ==  "__main__":
-
+    import gettext
+    gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
+    
     if len(sys.argv) ==  1:
         sys.exit(_("usage: %s <grass command>") % sys.argv[0])
+    
     if sys.argv[1] !=  'test':
         q = wx.LogNull()
         cmd = utils.split(sys.argv[1])

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -37,10 +37,6 @@
 except ImportError:
     havePwd = False
 
-### i18N
-import gettext
-gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
-
 import wx
 import wx.lib.filebrowsebutton as filebrowse
 import wx.lib.colourselect as csel

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/psmap.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/psmap.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/psmap.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -1642,6 +1642,9 @@
                        rect.GetSize()[0]*scale, rect.GetSize()[1]*scale)   
     
 def main():
+    import gettext
+    gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
+    
     app = wx.PySimpleApp()
     wx.InitAllImageHandlers()
     frame = PsMapFrame()

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -1281,30 +1281,22 @@
         return self.layers.reverse()
 
 if __name__ == "__main__":
-    """!Test of Display class.
-    Usage: display=Render()
-    """
     import gettext
     gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
     
-    print "Initializing..."
-    grass.run_command("g.region", flags = "d")
+    Map = Map()
+    Map.GetRegion(update = True)
     
-    map = Map()
-    map.width = 640
-    map.height = 480
-    
-    map.AddLayer(type = "raster",
-                 name = "elevation.dem",
-                 command = ["d.rast", "elevation.dem at PERMANENT", "catlist=1000-1500", "-i"],
+    Map.AddLayer(type = "raster",
+                 name = "elevation",
+                 command = ["d.rast", "map=elevation at PERMANENT"],
                  l_opacity = .7)
     
-    map.AddLayer(type = "vector",
-                 name = "streams",
-                 command = ["d.vect", "streams at PERMANENT", "color=red", "width=3", "type=line"])
+    Map.AddLayer(type = "vector",
+                 name = "roadsmajor",
+                 command = ["d.vect", "map=roadsmajor at PERMANENT", "color=red", "width=3", "type=line"])
     
-    image = map.Render(force = True)
+    image = Map.Render(force = True)
     
     if image:
-        os.system("display %s" % image)
-    
+        grass.call(["display", image])

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/sqlbuilder.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/sqlbuilder.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/sqlbuilder.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -13,7 +13,7 @@
 python sqlbuilder.py vector_map
 @endcode
 
-(C) 2007-2009 by the GRASS Development Team
+(C) 2007-2009, 2011 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
@@ -28,10 +28,6 @@
 import sys
 import time
 
-### i18N
-import gettext
-gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
-
 import globalvar
 import wx
 
@@ -58,7 +54,7 @@
         #
         self.vectmap = vectmap # fullname
         if not "@" in self.vectmap:
-            self.vectmap = self.vectmap + "@" + grass.gisenv()['MAPSET']
+            self.vectmap = grass.find_file(self.vectmap, element = 'vector')['fullname']
         self.mapname, self.mapset = self.vectmap.split("@")
         
         # db info
@@ -446,6 +442,9 @@
         print >>sys.stderr, __doc__
         sys.exit()
     
+    import gettext
+    gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
+    
     app = wx.App(0)
     sqlb = SQLFrame(parent = None, title = _('SQL Builder'), vectmap = sys.argv[1])
     sqlb.Show()

Modified: grass/branches/develbranch_6/gui/wxpython/icons/grass_icons.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/grass_icons.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/icons/grass_icons.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -4,7 +4,7 @@
 
 import os
 
-from gui_modules import globalvar
+import globalvar
 
 iconPath = os.path.join(globalvar.ETCDIR, "gui", "icons", "grass")
 iconPathVDigit  = os.path.join(globalvar.ETCDIR, "gui", "icons", "grass", "edit")

Modified: grass/branches/develbranch_6/gui/wxpython/icons/icon.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/icon.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/icons/icon.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -27,7 +27,7 @@
 
 import wx
 
-from gui_modules.preferences import globalSettings as UserSettings
+from preferences import globalSettings as UserSettings
 
 import grass2_icons # default icon set
 iconPathDefault = grass2_icons.iconPath
@@ -473,4 +473,5 @@
 # testing ...
 if __name__ == '__main__':
     for k, v in iconSet.iteritems():
-        print v.GetImageName()
+        for kk, vv in v.iteritems():
+            print k, kk, vv.GetImageName()

Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py	2011-08-03 16:50:21 UTC (rev 47386)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py	2011-08-03 16:54:06 UTC (rev 47387)
@@ -28,17 +28,11 @@
 import platform
 import signal
 import tempfile
-
-### XML
 try:
     import xml.etree.ElementTree as etree
 except ImportError:
     import elementtree.ElementTree as etree # Python <= 2.4
 
-### i18N
-import gettext
-gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
-
 from gui_modules import globalvar
 import wx
 import wx.aui
@@ -1720,9 +1714,9 @@
     return (workspaceFile,)
 
 def main(argv = None):
-    #
-    # process command-line arguments
-    #
+    import gettext
+    gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
+    
     if argv is None:
         argv = sys.argv
     try:
@@ -1731,21 +1725,18 @@
                                        ["help", "workspace"])
         except getopt.error, msg:
             raise Usage(msg)
-
+    
     except Usage, err:
         print >> sys.stderr, err.msg
         print >> sys.stderr, "for help use --help"
         printHelp()
-
+    
     workspaceFile = process_opt(opts, args)[0]
-
-    #
-    # run application
-    #
+    
     app = GMApp(workspaceFile)
     # suppress wxPython logs
     q = wx.LogNull()
-
+    
     app.MainLoop()
 
 if __name__ == "__main__":



More information about the grass-commit mailing list