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

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Dec 19 16:20:53 EST 2009


Author: martinl
Date: 2009-12-19 16:20:53 -0500 (Sat, 19 Dec 2009)
New Revision: 40077

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py
Log:
wxGUI: split log/prompt area


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2009-12-19 21:17:21 UTC (rev 40076)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2009-12-19 21:20:53 UTC (rev 40077)
@@ -128,15 +128,17 @@
     def abort(self):
         self.requestCmd.abort()
     
-class GMConsole(wx.Panel):
+class GMConsole(wx.SplitterWindow):
     """!Create and manage output console for commands run by GUI.
     """
     def __init__(self, parent, id=wx.ID_ANY, margin=False, pageid=0,
                  notebook = None,
                  style=wx.TAB_TRAVERSAL | wx.FULL_REPAINT_ON_RESIZE,
                  **kwargs):
-        wx.Panel.__init__(self, parent, id, style = style, *kwargs)
+        wx.SplitterWindow.__init__(self, parent, id, style = style, *kwargs)
         self.SetName("GMConsole")
+
+        self.panel = wx.Panel(parent = self, id = wx.ID_ANY)
         
         # initialize variables
         self.Map             = None
@@ -160,16 +162,10 @@
         #
         # progress bar
         #
-        self.console_progressbar = wx.Gauge(parent=self, id=wx.ID_ANY,
+        self.console_progressbar = wx.Gauge(parent=self.panel, id=wx.ID_ANY,
                                             range=100, pos=(110, 50), size=(-1, 25),
                                             style=wx.GA_HORIZONTAL)
         self.console_progressbar.Bind(EVT_CMD_PROGRESS, self.OnCmdProgress)
-        # abort
-        self.btn_abort = wx.Button(parent = self, id = wx.ID_ANY, label = _("&Abort command"),
-                                   size=(125,-1))
-        self.btn_abort.SetToolTipString(_("Abort the running command"))
-        self.btn_abort.Bind(wx.EVT_BUTTON, self.OnCmdAbort)
-        self.btn_abort.Enable(False)
         
         #
         # text control for command output
@@ -181,13 +177,15 @@
         self.cmd_output.Bind(wx.EVT_TIMER, self.OnProcessPendingOutputWindowEvents)
         self.Bind(EVT_CMD_RUN, self.OnCmdRun)
         self.Bind(EVT_CMD_DONE, self.OnCmdDone)
+
+        #
+        # command prompt
+        #
+        self.cmd_prompt = prompt.GPromptSTC(parent = self.panel, id=wx.ID_ANY,
+                                            onRun = self.RunCmd)
+        if self.parent.GetName() != 'LayerManager':
+            self.cmd_prompt.Hide()
         
-        if self.parent.GetName() == 'LayerManager':
-            #
-            # command prompt
-            #
-            self.cmd_prompt = prompt.GPromptSTC(self, id=wx.ID_ANY)
-        
         #
         # stream redirection
         #
@@ -202,21 +200,25 @@
         #
         # buttons
         #
-        self.console_clear = wx.Button(parent = self, id = wx.ID_ANY,
-                                       label = _("C&lear output"), size=(125,-1))
-        
-        if self.parent.GetName() == 'LayerManager':
-            self.cmd_clear = wx.Button(parent = self, id = wx.ID_ANY,
+        self.btn_console_clear = wx.Button(parent = self.panel, id = wx.ID_ANY,
+                                           label = _("C&lear output"), size=(125,-1))
+        self.btn_cmd_clear = wx.Button(parent = self.panel, id = wx.ID_ANY,
                                        label = _("Cl&ear command"), size=(125,-1))
-            self.Bind(wx.EVT_BUTTON, self.cmd_prompt.OnCmdErase, self.cmd_clear)
-            
-        self.console_save  = wx.Button(parent = self, id = wx.ID_ANY,
-                                       label = _("&Save output"), size=(125,-1))
-        
-        self.Bind(wx.EVT_BUTTON, self.ClearHistory, self.console_clear)
-        self.Bind(wx.EVT_BUTTON, self.SaveHistory,  self.console_save)
+        if self.parent.GetName() != 'LayerManager':
+            self.btn_cmd_clear.Hide()
+        self.btn_console_save  = wx.Button(parent = self.panel, id = wx.ID_ANY,
+                                           label = _("&Save output"), size=(125,-1))
+        # abort
+        self.btn_abort = wx.Button(parent = self.panel, id = wx.ID_ANY, label = _("&Abort command"),
+                                   size=(125,-1))
+        self.btn_abort.SetToolTipString(_("Abort the running command"))
+        self.btn_abort.Enable(False)
 
-        self.Bind(EVT_CMD_ABORT, self.OnCmdAbort)
+        self.btn_cmd_clear.Bind(wx.EVT_BUTTON,     self.cmd_prompt.OnCmdErase)
+        self.btn_console_clear.Bind(wx.EVT_BUTTON, self.ClearHistory)
+        self.btn_console_save.Bind(wx.EVT_BUTTON,  self.SaveHistory)
+        self.btn_abort.Bind(wx.EVT_BUTTON,         self.OnCmdAbort)
+        self.btn_abort.Bind(EVT_CMD_ABORT,         self.OnCmdAbort)
         
         self.__layout()
 
@@ -225,33 +227,39 @@
         boxsizer = wx.BoxSizer(wx.VERTICAL)
         buttonsizer = wx.BoxSizer(wx.HORIZONTAL)
         
-        boxsizer.Add(item=self.cmd_output, proportion=1,
-                      flag=wx.EXPAND | wx.ALIGN_BOTTOM, border=0)
-        if self.parent.GetName() == 'LayerManager':
-            boxsizer.Add(item=self.cmd_prompt, proportion=0,
-                          flag=wx.EXPAND | wx.FIXED_MINSIZE | wx.ALIGN_BOTTOM, border=0)
-                                            
-        buttonsizer.Add(item=self.console_clear, proportion=0,
+        boxsizer.Add(item=self.cmd_prompt, proportion=1,
+                         flag=wx.EXPAND | wx.ALL, border=1)
+        
+        buttonsizer.Add(item=self.btn_console_clear, proportion=0,
                         flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE | wx.ALL, border=5)
-        buttonsizer.Add(item=self.console_save, proportion=0,
+        buttonsizer.Add(item=self.btn_console_save, proportion=0,
                         flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE | wx.ALL, border=5)
-        if self.parent.GetName() == 'LayerManager':
-            buttonsizer.Add(item=self.cmd_clear, proportion=0,
-                            flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE | wx.ALL, border=5)
+        buttonsizer.Add(item=self.btn_cmd_clear, proportion=0,
+                        flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE | wx.ALL, border=5)
         buttonsizer.Add(item=self.btn_abort, proportion=0,
                         flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE | wx.ALL, border=5)
         boxsizer.Add(item=buttonsizer, proportion=0,
                       flag=wx.ALIGN_CENTER)
         
-        boxsizer.Add(item=self.console_progressbar, proportion=0,
-                      flag=wx.EXPAND | wx.ALIGN_CENTRE_VERTICAL | wx.LEFT | wx.RIGHT, border=5)
+        boxsizer.Add(item=self.console_progressbar, proportion=1,
+                      flag=wx.EXPAND | wx.ALIGN_CENTRE_VERTICAL | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=3)
         
         boxsizer.Fit(self)
         boxsizer.SetSizeHints(self)
 
+        self.panel.SetSizer(boxsizer)
+        
+        # split window
+        if self.parent.GetName() == 'LayerManager':
+            self.SplitHorizontally(self.cmd_output, self.panel, -75)
+            self.SetMinimumPaneSize(100)
+        else:
+            self.SplitHorizontally(self.cmd_output, self.panel, -10)
+            self.SetMinimumPaneSize(65)
+        self.Fit()
+        
         # layout
         self.SetAutoLayout(True)
-        self.SetSizer(boxsizer)
         self.Layout()
 
     def Redirect(self):

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py	2009-12-19 21:17:21 UTC (rev 40076)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py	2009-12-19 21:20:53 UTC (rev 40077)
@@ -668,11 +668,12 @@
 
 class GPromptSTC(wx.stc.StyledTextCtrl):
     """!Styled GRASS prompt with autocomplete and calltips"""    
-    def __init__(self, parent, id, size=wx.DefaultSize, margin=False, wrap=None):
+    def __init__(self, parent, id, onRun, margin=False, wrap=None):
         wx.stc.StyledTextCtrl.__init__(self, parent, id)
         self.parent = parent
         self.SetUndoCollection(True)        
-
+        self.RunCmd = onRun
+        
         #
         # styles
         #                
@@ -898,7 +899,7 @@
                 maplist = []
                 self.maptype = ''
 
-                #what kind of map/data type is desired?
+                # what kind of map/data type is desired?
                 if (((cmdtype in ['r', 'i'] or cmd in self.drastcmd) and arg in self.rastargs) or
                   ((cmd=='nviz' or cmdtype=='r3') and arg in ['elevation','color']) or
                   arg in ['rast', 'raster']):
@@ -920,9 +921,7 @@
                     self.maptype ='group'
                 elif arg=='3dview':
                     self.maptype ='3dview'
-                    
-                print 'maptype at end of = ' + str(self.maptype)
-
+                
             elif event.GetKeyCode() == 44:
                 # autocompletion after ','
                 # if comma is pressed, use the same maptype as previous for multiple map entries
@@ -996,7 +995,7 @@
             cmd = shlex.split(str(line))
             
             #send the command list to the processor 
-            self.parent.RunCmd(cmd)
+            self.RunCmd(cmd)
                             
             #add command to history    
             self.cmdbuffer.append(line)



More information about the grass-commit mailing list