[GRASS-SVN] r41631 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 30 12:22:10 EDT 2010


Author: martinl
Date: 2010-03-30 12:22:10 -0400 (Tue, 30 Mar 2010)
New Revision: 41631

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI/modeler: load model file from command line
(merge r41628-r41630 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2010-03-30 16:13:57 UTC (rev 41630)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2010-03-30 16:22:10 UTC (rev 41631)
@@ -20,6 +20,7 @@
 """
 
 import os
+import sys
 import shlex
 import time
 import traceback
@@ -46,8 +47,6 @@
 
 from grass.script import core as grass
 
-debug = False
-
 class ModelFrame(wx.Frame):
     def __init__(self, parent, id = wx.ID_ANY, title = _("Graphical modeler (under development)"), **kwargs):
         """!Graphical modeler main window
@@ -118,17 +117,12 @@
     def OnModelOpen(self, event):
         """!Load model from file"""
         filename = ''
-        global debug
-        if debug is False:
-            dlg = wx.FileDialog(parent = self, message=_("Choose model file"),
-                                defaultDir = os.getcwd(),
-                                wildcard=_("GRASS Model File (*.gxm)|*.gxm"))
-            if dlg.ShowModal() == wx.ID_OK:
-                filename = dlg.GetPath()
-        
-        else:
-            filename = '/home/martin/model1.gxm'
-            
+        dlg = wx.FileDialog(parent = self, message=_("Choose model file"),
+                            defaultDir = os.getcwd(),
+                            wildcard=_("GRASS Model File (*.gxm)|*.gxm"))
+        if dlg.ShowModal() == wx.ID_OK:
+            filename = dlg.GetPath()
+                    
         if not filename:
             return
         
@@ -162,20 +156,17 @@
         
     def OnModelSaveAs(self, event):
         """!Create model to file as"""
-        global debug
-        if debug is False:
-            dlg = wx.FileDialog(parent = self,
-                                message = _("Choose file to save current model"),
-                                defaultDir = os.getcwd(),
-                                wildcard=_("GRASS Model File (*.gxm)|*.gxm"),
-                                style=wx.FD_SAVE)
-            
-            filename = ''
-            if dlg.ShowModal() == wx.ID_OK:
-                filename = dlg.GetPath()
-        else:
-            filename = '/home/martin/model1.gxm'
+        filename = ''
+        dlg = wx.FileDialog(parent = self,
+                            message = _("Choose file to save current model"),
+                            defaultDir = os.getcwd(),
+                            wildcard=_("GRASS Model File (*.gxm)|*.gxm"),
+                            style=wx.FD_SAVE)
         
+        
+        if dlg.ShowModal() == wx.ID_OK:
+            filename = dlg.GetPath()
+        
         if not filename:
             return
         
@@ -215,22 +206,18 @@
 
     def OnAddAction(self, event):
         """!Add action to model"""
-        global debug
-        if debug == False:
-            if self.searchDialog is None:
-                self.searchDialog = ModelSearchDialog(self)
-                self.searchDialog.CentreOnParent()
-            else:
-                self.searchDialog.Reset()
+        if self.searchDialog is None:
+            self.searchDialog = ModelSearchDialog(self)
+            self.searchDialog.CentreOnParent()
+        else:
+            self.searchDialog.Reset()
             
-            if self.searchDialog.ShowModal() == wx.ID_CANCEL:
-                self.searchDialog.Hide()
-                return
-            
-            cmd = self.searchDialog.GetCmd()
+        if self.searchDialog.ShowModal() == wx.ID_CANCEL:
             self.searchDialog.Hide()
-        else:
-            cmd = ['r.buffer']
+            return
+            
+        cmd = self.searchDialog.GetCmd()
+        self.searchDialog.Hide()
         
         # add action to canvas
         width, height = self.canvas.GetSize()
@@ -276,7 +263,7 @@
     def GetOptData(self, dcmd, layer, params, propwin):
         """!Process action data"""
         layer.SetProperties(dcmd, params, propwin)
-        
+            
         if params: # add data items
             width, height = self.canvas.GetSize()
             x = [width/2 + 200, width/2 - 200]
@@ -447,8 +434,8 @@
 
     def SetProperties(self, dcmd, params, propwin):
         """!Record properties dialog"""
-        self.cmd     = dcmd
-        self.params  = params
+        self.cmd = dcmd
+        self.params = params
         self.propWin = propwin
 
     def GetPropDialog(self):
@@ -899,6 +886,8 @@
 def main():
     app = wx.PySimpleApp()
     frame = ModelFrame(parent = None)
+    if len(sys.argv) > 1:
+        frame.LoadModelFile(sys.argv[1])
     # frame.CentreOnScreen()
     frame.Show()
     

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2010-03-30 16:13:57 UTC (rev 41630)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2010-03-30 16:22:10 UTC (rev 41631)
@@ -872,7 +872,7 @@
         if cmd is not None and self.get_dcmd is not None:
             # return d.* command to layer tree for rendering
             self.get_dcmd(cmd, self.layer, {"params": self.task.params, 
-                                            "flags" :self.task.flags},
+                                            "flags" : self.task.flags},
                           self)
             # echo d.* command to output console
             # self.parent.writeDCommand(cmd)
@@ -946,7 +946,7 @@
                 self.parent.Delete(self.layer)
                 self.Destroy()
         elif self.parent and self.parent.GetName() == 'Modeler':
-            self.Hide()
+            self.Destroy()
         else:
             # cancel for non-display commands
             self.Destroy()



More information about the grass-commit mailing list