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

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 28 05:18:48 PDT 2012


Author: lucadelu
Date: 2012-05-28 05:18:47 -0700 (Mon, 28 May 2012)
New Revision: 51852

Modified:
   grass/trunk/gui/wxpython/gui_core/ghelp.py
   grass/trunk/gui/wxpython/lmgr/frame.py
Log:
new version of translation status, it has a bug for the scroll

Modified: grass/trunk/gui/wxpython/gui_core/ghelp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/ghelp.py	2012-05-28 11:52:53 UTC (rev 51851)
+++ grass/trunk/gui/wxpython/gui_core/ghelp.py	2012-05-28 12:18:47 UTC (rev 51852)
@@ -44,6 +44,15 @@
 from gui_core.widgets import GNotebook, StaticWrapText, ItemTree, ScrolledPanel
 from core.debug       import Debug
 
+# add for folderpanel in languages status
+try:
+    from agw import foldpanelbar as fpb
+except ImportError: # if it's not there locally, try the wxPython lib.
+    try:
+        import wx.lib.agw.foldpanelbar as fpb
+    except ImportError:
+        import wx.lib.foldpanelbar as fpb # versions <=2.5.5.1
+
 class SearchModuleWindow(wx.Panel):
     """!Search module window (used in MenuTreeWindow)"""
     def __init__(self, parent, id = wx.ID_ANY, cmdPrompt = None,
@@ -725,6 +734,45 @@
         
         return translatorswin
 
+    def _langString(self, k, v):
+        """Return string for the status of translation"""
+        allStr = "%s :" % k.upper()
+        try:
+            allStr += _("   %d translated" % v['good'])
+        except:
+            pass
+        try:
+            allStr += _("   %d fuzzy" % v['fuzzy'])
+        except:
+            pass
+        try:
+            allStr += _("   %d untranslated" % v['bad'])
+        except:
+            pass
+        return allStr
+        
+    def _langPanel(self, parent, js):
+        """Create panel for each languages"""
+        panel = wx.Panel(parent = parent, id = wx.ID_ANY)
+        pageSizer = wx.BoxSizer(wx.VERTICAL)
+        for k,v in js.iteritems():
+            if k != 'total':
+                text = self._langString(k,v)
+                statstext = wx.StaticText(panel, id = wx.ID_ANY,
+                                        label = text)
+                pageSizer.Add(item = statstext, proportion = 1,
+                                 flag = wx.EXPAND | wx.ALL, border = 3)
+        panel.SetSizer(pageSizer)
+        panel.Layout()
+        panel.Fit()
+        return panel
+
+    def OnPressCaption(self, event):
+        """!When foldpanel item collapsed/expanded, update scrollbars"""
+        foldpanel = event.GetBar().GetGrandParent().GetParent()
+        wx.CallAfter(self.UpdateScrolling, (foldpanel,))
+        event.Skip()
+
     def _pageStats(self):
         """Translation statistics info"""
         fname = "translation_status.json"
@@ -738,45 +786,43 @@
         statswin = ScrolledPanel(self)
         statswin.SetAutoLayout(True)
         statswin.SetupScrolling()
-        statswin.sizer = wx.BoxSizer(wx.VERTICAL)
+        
+        try:# wxpython <= 2.8.10
+            foldpanelAppear = fpb.FoldPanelBar(parent = statswin, id = wx.ID_ANY,
+                                                  style = fpb.FPB_DEFAULT_STYLE,
+                                                  extraStyle = fpb.FPB_SINGLE_FOLD)
+        except:
+            try:# wxpython >= 2.8.11
+                foldpanelAppear = fpb.FoldPanelBar(parent = statswin, id = wx.ID_ANY,                               
+                                                      agwStyle = fpb.FPB_SINGLE_FOLD)
+            except: # to be sure
+                foldpanelAppear = fpb.FoldPanelBar(parent = statswin, id = wx.ID_ANY,                               
+                                                      style = fpb.FPB_SINGLE_FOLD)
+        statswin.Bind(fpb.EVT_CAPTIONBAR, self.OnPressCaption)
         if not jsStats:
             Debug.msg(5, _("File <%s> not found") % fname)
+            sizer = wx.BoxSizer(wx.VERTICAL)
             statstext = wx.StaticText(statswin, id = wx.ID_ANY,
                                            label = _('%s file missing') % fname)
-            statswin.sizer.Add(item = statstext, proportion = 1,
+            sizer.Add(item = statstext, proportion = 1,
                                  flag = wx.EXPAND | wx.ALL, border = 3)
+            #statswin.SetSizer(statswin.sizer)
         else:
-            statsBox = wx.FlexGridSizer(cols = 4, vgap = 5, hgap = 5)
-            statsBox.Add(item = wx.StaticText(parent = statswin, id = wx.ID_ANY,
-                                                    label = _('Language')))
-            statsBox.Add(item = wx.StaticText(parent = statswin, id = wx.ID_ANY,
-                                                    label = _('Translated')))
-            statsBox.Add(item = wx.StaticText(parent = statswin, id = wx.ID_ANY,
-                                                    label = _('Fuzzy')))
-            statsBox.Add(item = wx.StaticText(parent = statswin, id = wx.ID_ANY,
-                                                    label = _('Untranslated')))
-
             languages = jsStats['langs'].keys()
             languages.sort()
             for lang in languages:
-                    v = jsStats['langs'][lang]
-                    statsBox.Add(item = wx.StaticText(parent = statswin, id = wx.ID_ANY,
-                                                    style =  wx.ALIGN_CENTRE, 
-                                                    label =  lang.upper()))
-                    statsBox.Add(item = wx.StaticText(parent = statswin, id = wx.ID_ANY,
-                                                    style =  wx.ALIGN_CENTRE, 
-                                                    label = str(v['total']['good'])))
-                    statsBox.Add(item = wx.StaticText(parent = statswin, id = wx.ID_ANY,
-                                                    style =  wx.ALIGN_CENTRE,
-                                                    label = str(v['total']['fuzzy'])))
-                    statsBox.Add(item = wx.StaticText(parent = statswin, id = wx.ID_ANY,
-                                                    style =  wx.ALIGN_CENTRE,
-                                                    label = str(v['total']['bad'])))
+                v = jsStats['langs'][lang]
+                
+                text = self._langString(lang, v['total'])
+                panel = foldpanelAppear.AddFoldPanel(text, collapsed = True)
+                foldpanelAppear.AddFoldPanelWindow(panel,
+                    window = self._langPanel(parent = panel, js = v), 
+                    flags = fpb.FPB_ALIGN_WIDTH)
 
-            statswin.sizer.Add(item = statsBox, proportion = 1,
-                                 flag = wx.EXPAND | wx.ALL, border = 2)    
+	        sizer = wx.BoxSizer(wx.VERTICAL)
+	        sizer.Add(foldpanelAppear, proportion = 1, flag = wx.EXPAND)
         
-        statswin.SetSizer(statswin.sizer)
+        statswin.SetSizer(sizer)
         statswin.Layout()      
         
         return statswin

Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py	2012-05-28 11:52:53 UTC (rev 51851)
+++ grass/trunk/gui/wxpython/lmgr/frame.py	2012-05-28 12:18:47 UTC (rev 51852)
@@ -376,6 +376,36 @@
         
         win.Show()
 
+    def OnRLiSetup(self, event):
+        """!Launch r.li.setup
+        """
+        #try:
+        from scripts.rlisetup import RLiSetupFrame
+        #except:
+            #gcmd.GError(parent = self.parent, message = _("r.li.setup is not available."))
+            #return      
+            
+        win = RLiSetupFrame(parent = self)
+        win.CentreOnScreen()
+        
+        win.Show()
+
+    def OnRStream(self, event):
+        """!GSoC's r.stream.* interface for testing
+        """
+        try:
+            from gui_modules import rstream
+        except:
+            gcmd.GError(parent = self.parent,
+                        message = _("RStream Utility is not available. You can install it by %s") % \
+                            'g.extension -s extension=wx.stream')
+            return
+        
+        win = rstream.RStreamFrame(parent = self)
+        win.CentreOnScreen()
+        
+        win.Show()
+        
     def OnDone(self, cmd, returncode):
         """Command execution finised"""
         if hasattr(self, "model"):



More information about the grass-commit mailing list