ソースを参照

fix wxGUI to work with p.mon

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@35511 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 16 年 前
コミット
f8fd54ff93

+ 16 - 12
gui/wxpython/gui_modules/mapdisp.py

@@ -32,6 +32,8 @@ import math
 import tempfile
 import tempfile
 import copy
 import copy
 
 
+import gui_modules.globalvar as globalvar
+globalvar.CheckForWx()
 import wx
 import wx
 import wx.aui
 import wx.aui
 
 
@@ -46,6 +48,9 @@ except:
 gmpath = os.path.join(globalvar.ETCWXDIR, "icons")
 gmpath = os.path.join(globalvar.ETCWXDIR, "icons")
 sys.path.append(gmpath)
 sys.path.append(gmpath)
 
 
+grassPath = os.path.join(globalvar.ETCDIR, "python")
+sys.path.append(grassPath)
+
 import render
 import render
 import toolbars
 import toolbars
 import menuform
 import menuform
@@ -463,7 +468,8 @@ class MapFrame(wx.Frame):
         Change choicebook page to match display.
         Change choicebook page to match display.
         Or set display for georectifying
         Or set display for georectifying
         """
         """
-        if self.gismanager.georectifying:
+        if self.gismanager and \
+                self.gismanager.georectifying:
             # in georectifying session; display used to get get geographic
             # in georectifying session; display used to get get geographic
             # coordinates for GCPs
             # coordinates for GCPs
             self.OnPointer(event)
             self.OnPointer(event)
@@ -959,16 +965,14 @@ class MapFrame(wx.Frame):
 
 
         if self.toolbars['nviz']:
         if self.toolbars['nviz']:
             self.toolbars['nviz'].OnExit()
             self.toolbars['nviz'].OnExit()
-        
-        if self.page:
+
+        if not self.gismanager:
+            self.Destroy()
+        elif self.page:
             pgnum = self.layerbook.GetPageIndex(self.page)
             pgnum = self.layerbook.GetPageIndex(self.page)
             if pgnum > -1:
             if pgnum > -1:
                 self.layerbook.DeletePage(pgnum)
                 self.layerbook.DeletePage(pgnum)
         
         
-        ### self.Destroy()
-        # if event:
-        #    event.Skip() <- causes application crash
-        
     def GetRender(self):
     def GetRender(self):
         """
         """
         Returns the current instance of render.Map()
         Returns the current instance of render.Map()
@@ -1641,7 +1645,7 @@ class MapApp(wx.App):
         if __name__ == "__main__":
         if __name__ == "__main__":
             # redraw map, if new command appears
             # redraw map, if new command appears
             self.redraw = False
             self.redraw = False
-            status = Command(self, Map)
+            status = Command(self, Map, cmdfilename)
             status.start()
             status.start()
             self.timer = wx.PyTimer(self.watcher)
             self.timer = wx.PyTimer(self.watcher)
             # check each 0.1s
             # check each 0.1s
@@ -1675,9 +1679,9 @@ if __name__ == "__main__":
     cmdfilename = sys.argv[2]
     cmdfilename = sys.argv[2]
 
 
     import gettext
     import gettext
-    gettext.install("gm_map") # replace with the appropriate catalog name
+    gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
 
 
-    print "Starting monitor <%s>" % (title)
+    print >> sys.stderr, "\nStarting monitor <%s>...\n" % (title)
 
 
     gm_map = MapApp(0)
     gm_map = MapApp(0)
     # set title
     # set title
@@ -1688,6 +1692,6 @@ if __name__ == "__main__":
     os.remove(cmdfilename)
     os.remove(cmdfilename)
     os.system("""g.gisenv set="GRASS_PYCMDFILE" """)
     os.system("""g.gisenv set="GRASS_PYCMDFILE" """)
 
 
-    print "Stoping monitor <%s>" % (title)
+    print >> sys.stderr, "\nStoping monitor <%s>...\n" % (title)
 
 
-    sys.exit()
+    sys.exit(0)

+ 5 - 2
gui/wxpython/gui_modules/mapdisp_command.py

@@ -14,6 +14,9 @@ for details.
 @author Jachym Cepicky
 @author Jachym Cepicky
 """
 """
 
 
+import sys
+import time
+
 from threading import Thread
 from threading import Thread
 
 
 class Command(Thread):
 class Command(Thread):
@@ -21,14 +24,14 @@ class Command(Thread):
     Creates thread which will observe the command file and see, if
     Creates thread which will observe the command file and see, if
     there is new command to be executed
     there is new command to be executed
     """
     """
-    def __init__ (self, parent, Map):
+    def __init__ (self, parent, Map, cmdfile):
         Thread.__init__(self)
         Thread.__init__(self)
 
 
         global cmdfilename
         global cmdfilename
 
 
         self.parent = parent
         self.parent = parent
         self.map = Map
         self.map = Map
-        self.cmdfile = open(cmdfilename, "r")
+        self.cmdfile = open(cmdfile, "r")
 
 
     def run(self):
     def run(self):
         """
         """

+ 2 - 1
gui/wxpython/gui_modules/mapdisp_window.py

@@ -688,7 +688,8 @@ class BufferedWindow(MapWindow, wx.Window):
         if len(self.polycoords) > 0:
         if len(self.polycoords) > 0:
             self.DrawLines(self.pdcTmp)
             self.DrawLines(self.pdcTmp)
         
         
-        if self.parent.gismanager.georectifying:
+        if self.parent.gismanager and \
+                self.parent.gismanager.georectifying:
             # -> georectifier (redraw GCPs)
             # -> georectifier (redraw GCPs)
             if self.parent.toolbars['georect']:
             if self.parent.toolbars['georect']:
                 coordtype = 'gcpcoord'
                 coordtype = 'gcpcoord'

+ 2 - 2
gui/wxpython/icons/icon.py

@@ -21,8 +21,8 @@ for details.
 import os
 import os
 import sys
 import sys
 
 
-import wxversion
-wxversion.select('2.8')
+import gui_modules.globalvar as globalvar
+globalvar.CheckForWx()
 import wx
 import wx
 
 
 gmPath = os.path.join(os.getenv("GISBASE"), "etc", "wxpython", "gui_modules")
 gmPath = os.path.join(os.getenv("GISBASE"), "etc", "wxpython", "gui_modules")