[GRASS-SVN] r57202 - in grass/trunk/gui/wxpython: gui_core lmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 17 10:25:24 PDT 2013


Author: annakrat
Date: 2013-07-17 10:25:24 -0700 (Wed, 17 Jul 2013)
New Revision: 57202

Modified:
   grass/trunk/gui/wxpython/gui_core/goutput.py
   grass/trunk/gui/wxpython/lmgr/frame.py
Log:
wxGUI: show and hide progress in command console, simplify module command console, remove search engine from command console

Modified: grass/trunk/gui/wxpython/gui_core/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/goutput.py	2013-07-17 17:19:47 UTC (rev 57201)
+++ grass/trunk/gui/wxpython/gui_core/goutput.py	2013-07-17 17:25:24 UTC (rev 57202)
@@ -72,9 +72,9 @@
         wx.SplitterWindow.__init__(self, parent, id = wx.ID_ANY, style = style, **kwargs)
         self.SetName("GConsole")
         
-        self.panelOutput = wx.Panel(parent = self, id = wx.ID_ANY)
-        self.panelPrompt = wx.Panel(parent = self, id = wx.ID_ANY)
-
+        self.panelOutput = wx.Panel(parent=self, id=wx.ID_ANY)
+        self.panelProgress = wx.Panel(parent=self.panelOutput, id=wx.ID_ANY, name='progressPanel')
+        self.panelPrompt = wx.Panel(parent=self, id=wx.ID_ANY)
         # initialize variables
         self.parent = parent # GMFrame | CmdPanel | ?
         self._gconsole = gconsole
@@ -87,7 +87,7 @@
         self.showNotification = Signal("GConsoleWindow.showNotification")
 
         # progress bar
-        self.progressbar = wx.Gauge(parent = self.panelOutput, id = wx.ID_ANY,
+        self.progressbar = wx.Gauge(parent = self.panelProgress, id = wx.ID_ANY,
                                     range = 100, pos = (110, 50), size = (-1, 25),
                                     style = wx.GA_HORIZONTAL)
         self._gconsole.Bind(EVT_CMD_PROGRESS, self.OnCmdProgress)
@@ -144,16 +144,15 @@
         else:
             self.search = None
 
-        self.outputBox = wx.StaticBox(parent = self.panelOutput, id = wx.ID_ANY,
-                                      label = " %s " % _("Output window"))
 
         if self._gcstyle & GC_PROMPT:
             cmdLabel = _("Command prompt")
-        else:
-            cmdLabel = _("Command")
-        self.cmdBox = wx.StaticBox(parent = self.panelOutput, id = wx.ID_ANY,
-                                   label = " %s " % cmdLabel)
+            self.outputBox = wx.StaticBox(parent = self.panelOutput, id = wx.ID_ANY,
+                                          label = " %s " % _("Output window"))
 
+            self.cmdBox = wx.StaticBox(parent = self.panelOutput, id = wx.ID_ANY,
+                                       label = " %s " % cmdLabel)
+
         # buttons
         self.btnOutputClear = wx.Button(parent = self.panelOutput, id = wx.ID_CLEAR)
         self.btnOutputClear.SetToolTipString(_("Clear output window content"))
@@ -161,9 +160,8 @@
         self.btnCmdClear.SetToolTipString(_("Clear command prompt content"))
         self.btnOutputSave  = wx.Button(parent = self.panelOutput, id = wx.ID_SAVE)
         self.btnOutputSave.SetToolTipString(_("Save output window content to the file"))
-        self.btnCmdAbort = wx.Button(parent = self.panelOutput, id = wx.ID_STOP)
+        self.btnCmdAbort = wx.Button(parent = self.panelProgress, id = wx.ID_STOP)
         self.btnCmdAbort.SetToolTipString(_("Abort running command"))
-        self.btnCmdAbort.Enable(False)
         self.btnCmdProtocol = wx.ToggleButton(parent = self.panelOutput, id = wx.ID_ANY,
                                               label = _("&Log file"),
                                               size = self.btnCmdClear.GetSize())
@@ -184,10 +182,16 @@
         
     def _layout(self):
         """!Do layout"""
-        outputSizer = wx.BoxSizer(wx.VERTICAL)
+        self.outputSizer = wx.BoxSizer(wx.VERTICAL)
+        progressSizer = wx.BoxSizer(wx.HORIZONTAL)
         btnSizer = wx.BoxSizer(wx.HORIZONTAL)
-        outBtnSizer = wx.StaticBoxSizer(self.outputBox, wx.HORIZONTAL)
-        cmdBtnSizer = wx.StaticBoxSizer(self.cmdBox, wx.HORIZONTAL)
+        if self._gcstyle & GC_PROMPT:
+            outBtnSizer = wx.StaticBoxSizer(self.outputBox, wx.HORIZONTAL)
+            cmdBtnSizer = wx.StaticBoxSizer(self.cmdBox, wx.HORIZONTAL)
+        else:
+            outBtnSizer = wx.BoxSizer(wx.HORIZONTAL)
+            cmdBtnSizer = wx.BoxSizer(wx.HORIZONTAL)
+            
         
         if self._gcstyle & GC_PROMPT:
             promptSizer = wx.BoxSizer(wx.VERTICAL)
@@ -200,41 +204,48 @@
                             proportion = 0, flag = wx.EXPAND | wx.LEFT, border = 5)
         
         if self._gcstyle & GC_SEARCH:
-            outputSizer.Add(item = self.searchPane, proportion = 0,
+            self.outputSizer.Add(item = self.searchPane, proportion = 0,
                             flag = wx.EXPAND | wx.ALL, border = 3)
-        outputSizer.Add(item = self.cmdOutput, proportion = 1,
+        self.outputSizer.Add(item = self.cmdOutput, proportion = 1,
                         flag = wx.EXPAND | wx.ALL, border = 3)
-        outputSizer.Add(item = self.progressbar, proportion = 0,
-                        flag = wx.EXPAND | wx.LEFT | wx.RIGHT, border = 3)
-        outBtnSizer.Add(item = self.btnOutputClear, proportion = 1,
+        if self._gcstyle & GC_PROMPT:
+            proportion = 1
+        else:
+            proportion = 0
+            outBtnSizer.AddStretchSpacer()
+
+        outBtnSizer.Add(item = self.btnOutputClear, proportion = proportion,
                         flag = wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT, border = 5)
-        outBtnSizer.Add(item = self.btnOutputSave, proportion = 1,
+
+        outBtnSizer.Add(item = self.btnOutputSave, proportion = proportion,
                         flag = wx.ALIGN_RIGHT | wx.RIGHT, border = 5)
-        
+
         cmdBtnSizer.Add(item = self.btnCmdProtocol, proportion = 1,
                         flag = wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, border = 5)
         cmdBtnSizer.Add(item = self.btnCmdClear, proportion = 1,
                         flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5)
-        cmdBtnSizer.Add(item = self.btnCmdAbort, proportion = 1,
-                        flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5)
+        progressSizer.Add(item = self.btnCmdAbort, proportion = 0,
+                          flag = wx.ALL|wx.ALIGN_CENTER, border = 5)
+        progressSizer.Add(item = self.progressbar, proportion = 1,
+                          flag = wx.ALIGN_CENTER|wx.RIGHT|wx.TOP|wx.BOTTOM, border = 5)
+                          
+        self.panelProgress.SetSizer(progressSizer)
+        progressSizer.Fit(self.panelProgress)
         
-        if self._gcstyle & GC_PROMPT:
-            proportion = (2, 3)
-        else:
-            proportion = (1, 1)
-        
-        btnSizer.Add(item = outBtnSizer, proportion = proportion[0],
+        btnSizer.Add(item = outBtnSizer, proportion = 1,
                      flag = wx.ALL | wx.ALIGN_CENTER, border = 5)
-        btnSizer.Add(item = cmdBtnSizer, proportion = proportion[1],
+        btnSizer.Add(item = cmdBtnSizer, proportion = 1,
                      flag = wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM | wx.RIGHT, border = 5)
-        outputSizer.Add(item = btnSizer, proportion = 0,
+        self.outputSizer.Add(item = self.panelProgress, proportion = 0,
                         flag = wx.EXPAND)
+        self.outputSizer.Add(item = btnSizer, proportion = 0,
+                        flag = wx.EXPAND)
         
-        outputSizer.Fit(self)
-        outputSizer.SetSizeHints(self)
-        self.panelOutput.SetSizer(outputSizer)
+        self.outputSizer.Fit(self)
+        self.outputSizer.SetSizeHints(self)
+        self.panelOutput.SetSizer(self.outputSizer)
         # eliminate gtk_widget_size_allocate() warnings
-        outputSizer.SetVirtualSizeHints(self.panelOutput)
+        self.outputSizer.SetVirtualSizeHints(self.panelOutput)
         
         if self._gcstyle & GC_PROMPT:
             promptSizer.Fit(self)
@@ -251,6 +262,7 @@
         
         self.SetSashGravity(1.0)
         
+        self.outputSizer.Hide(self.panelProgress)
         # layout
         self.SetAutoLayout(True)
         self.Layout()
@@ -427,6 +439,9 @@
 
     def OnCmdProgress(self, event):
         """!Update progress message info"""
+        if not self.outputSizer.IsShown(self.panelProgress):
+            self.outputSizer.Show(self.panelProgress)
+            self.outputSizer.Layout()
         self.progressbar.SetValue(event.value)
         event.Skip()
 
@@ -477,18 +492,19 @@
 
     def OnCmdRun(self, event):
         """!Run command"""
-        self.btnCmdAbort.Enable()
-
         event.Skip()
 
     def OnCmdDone(self, event):
         """!Command done (or aborted)
         """
-        self.btnCmdAbort.Enable(False)
-
         self.progressbar.SetValue(0) # reset progress bar on '0%'
+        wx.CallLater(100, self._hideProgress)
         event.Skip()
 
+    def _hideProgress(self):
+        self.outputSizer.Hide(self.panelProgress)
+        self.outputSizer.Layout()
+        
     def OnStcChanged(self, event):
         newEvent = gGcContentChanged()
         wx.PostEvent(self, newEvent)

Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py	2013-07-17 17:19:47 UTC (rev 57201)
+++ grass/trunk/gui/wxpython/lmgr/frame.py	2013-07-17 17:25:24 UTC (rev 57202)
@@ -283,7 +283,7 @@
                                   ignoredCmdPattern = '^d\..*|^r[3]?\.mapcalc$|^i.group')
         self.goutput = GConsoleWindow(parent = self, gconsole = self._gconsole,
                                       menuModel=self._moduleTreeBuilder.GetModel(),
-                                      gcstyle = GC_SEARCH | GC_PROMPT)
+                                      gcstyle = GC_PROMPT)
         self.notebook.AddPage(page = self.goutput, text = _("Command console"), name = 'output')
 
         self.goutput.showNotification.connect(lambda message: self.SetStatusText(message))



More information about the grass-commit mailing list