[GRASS-SVN] r67769 - in grass/branches/releasebranch_7_0/gui/wxpython: gui_core lmgr nviz

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Feb 7 13:21:24 PST 2016


Author: annakrat
Date: 2016-02-07 13:21:24 -0800 (Sun, 07 Feb 2016)
New Revision: 67769

Modified:
   grass/branches/releasebranch_7_0/gui/wxpython/gui_core/menu.py
   grass/branches/releasebranch_7_0/gui/wxpython/gui_core/widgets.py
   grass/branches/releasebranch_7_0/gui/wxpython/lmgr/frame.py
   grass/branches/releasebranch_7_0/gui/wxpython/lmgr/pyshell.py
   grass/branches/releasebranch_7_0/gui/wxpython/nviz/tools.py
Log:
wxGUI: use native notebook for Layer manager tabs on linux and mac to avoid glitches, keep the FlatNotebook for Windows because native looks ugly (merge from trunk, r67627, r67679)

Modified: grass/branches/releasebranch_7_0/gui/wxpython/gui_core/menu.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/gui_core/menu.py	2016-02-07 21:13:00 UTC (rev 67768)
+++ grass/branches/releasebranch_7_0/gui/wxpython/gui_core/menu.py	2016-02-07 21:21:24 UTC (rev 67769)
@@ -130,8 +130,9 @@
     Signal:
         showNotification - attribute 'message'
     """
-    def __init__(self, parent, model, id = wx.ID_ANY, **kwargs):
-        self.parent = parent # LayerManager
+    def __init__(self, parent, handlerObj, model, id = wx.ID_ANY, **kwargs):
+        self.parent = parent
+        self.handlerObj = handlerObj
         
         self.showNotification = Signal('SearchModuleWindow.showNotification')
         wx.Panel.__init__(self, parent = parent, id = id, **kwargs)
@@ -217,7 +218,7 @@
         if not data:
             return
 
-        handler = 'self.parent.' + data['handler'].lstrip('self.')
+        handler = 'self.handlerObj.' + data['handler'].lstrip('self.')
 
         if data['command']:
             eval(handler)(event=None, cmd=data['command'].split())

Modified: grass/branches/releasebranch_7_0/gui/wxpython/gui_core/widgets.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/gui_core/widgets.py	2016-02-07 21:13:00 UTC (rev 67768)
+++ grass/branches/releasebranch_7_0/gui/wxpython/gui_core/widgets.py	2016-02-07 21:21:24 UTC (rev 67769)
@@ -103,7 +103,13 @@
         if 'name' in kwargs:
             self.notebookPages[kwargs['name']] = kwargs['page']
             del kwargs['name']
-        self.classObject.InsertPage(self.widget, **kwargs)
+        try:
+            self.classObject.InsertPage(self.widget, **kwargs)
+        except TypeError, e:  # documentation says 'index', but certain versions of wx require 'n'
+            print e
+            kwargs['n'] = kwargs['index']
+            del kwargs['index']
+            self.classObject.InsertPage(self.widget, **kwargs)
 
     def DeletePage(self, page):
         """Delete page
@@ -214,7 +220,17 @@
 
         return self.classObject.GetPageIndex(self.widget, self.notebookPages[page])
 
+    def InsertPage(self, **kwargs):
+        """Insert a new page
+        """
+        if 'name' in kwargs:
+            self.notebookPages[kwargs['name']] = kwargs['page']
+            del kwargs['name']
+        kwargs['indx'] = kwargs['index']
+        del kwargs['index']
+        self.classObject.InsertPage(self.widget, **kwargs)
 
+
 class GNotebook(FN.FlatNotebook):
     """Generic notebook widget.
 

Modified: grass/branches/releasebranch_7_0/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/lmgr/frame.py	2016-02-07 21:13:00 UTC (rev 67768)
+++ grass/branches/releasebranch_7_0/gui/wxpython/lmgr/frame.py	2016-02-07 21:21:24 UTC (rev 67769)
@@ -49,7 +49,7 @@
 from gui_core.preferences  import MapsetAccess, PreferencesDialog
 from lmgr.layertree        import LayerTree, LMIcons
 from lmgr.menudata         import LayerManagerMenuData, LayerManagerModuleTree
-from gui_core.widgets      import GNotebook
+from gui_core.widgets      import GNotebook, FormNotebook
 from modules.mcalc_builder import MapCalcFrame
 from dbmgr.manager         import AttributeManager
 from core.workspace        import ProcessWorkspaceFile, ProcessGrcFile, WriteWorkspaceFile
@@ -277,13 +277,16 @@
     
     def _createNoteBook(self):
         """Creates notebook widgets"""
-        self.notebook = GNotebook(parent = self, style = globalvar.FNPageDStyle)
+        if sys.platform == 'win32':
+            self.notebook = GNotebook(parent=self, style=globalvar.FNPageDStyle)
+        else:
+            self.notebook = FormNotebook(parent=self, style=wx.NB_BOTTOM)
         # create displays notebook widget and add it to main notebook page
         cbStyle = globalvar.FNPageStyle
         if globalvar.hasAgw:
-            self.notebookLayers = FN.FlatNotebook(self, id = wx.ID_ANY, agwStyle = cbStyle)
+            self.notebookLayers = FN.FlatNotebook(self.notebook, id=wx.ID_ANY, agwStyle=cbStyle)
         else:
-            self.notebookLayers = FN.FlatNotebook(self, id = wx.ID_ANY, style = cbStyle)
+            self.notebookLayers = FN.FlatNotebook(self.notebook, id=wx.ID_ANY, style=cbStyle)
         self.notebookLayers.SetTabAreaColour(globalvar.FNPageColor)
         menu = self._createTabMenu()
         self.notebookLayers.SetRightClickMenu(menu)
@@ -295,7 +298,7 @@
                                                       '^r.external$|^r.external.out$|'
                                                       '^v.in.ogr$|^v.external$|^v.external.out$|'
                                                       '^cd$|^cd .*')
-        self.goutput = GConsoleWindow(parent = self, gconsole = self._gconsole,
+        self.goutput = GConsoleWindow(parent=self.notebook, gconsole=self._gconsole,
                                       menuModel=self._moduleTreeBuilder.GetModel(),
                                       gcstyle = GC_PROMPT)
         self.notebook.AddPage(page = self.goutput, text = _("Command console"), name = 'output')
@@ -313,7 +316,8 @@
         
         # create 'search module' notebook page
         if not UserSettings.Get(group = 'manager', key = 'hideTabs', subkey = 'search'):
-            self.search = SearchModuleWindow(parent = self, model=self._moduleTreeBuilder.GetModel())
+            self.search = SearchModuleWindow(parent=self.notebook, handlerObj=self,
+                                             model=self._moduleTreeBuilder.GetModel())
             self.search.showNotification.connect(lambda message: self.SetStatusText(message))
             self.notebook.AddPage(page = self.search, text = _("Search modules"), name = 'search')
         else:
@@ -321,14 +325,17 @@
         
         # create 'python shell' notebook page
         if not UserSettings.Get(group = 'manager', key = 'hideTabs', subkey = 'pyshell'):
-            self.pyshell = PyShellWindow(parent = self)
+            self.pyshell = PyShellWindow(parent=self.notebook, giface=self._giface)
             self.notebook.AddPage(page = self.pyshell, text = _("Python shell"), name = 'pyshell')
         else:
             self.pyshell = None
         
         # bindings
+        if sys.platform == 'win32':
+            self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
+        else:
+            self.notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
         self.notebookLayers.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED,    self.OnCBPageChanged)
-        self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
         self.notebookLayers.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING,    self.OnCBPageClosed)
         
         return self.notebook
@@ -353,10 +360,10 @@
         self._auimgr.Update()
         
         # create nviz tools tab
-        self.nviz = NvizToolWindow(parent = self,
-                                   display = self.GetMapDisplay())
+        self.nviz = NvizToolWindow(parent=self.notebook, tree=self.GetLayerTree(),
+                                   display=self.GetMapDisplay())
         idx = self.notebook.GetPageIndexByName('layers')
-        self.notebook.InsertPage(indx = idx + 1, page = self.nviz, text = _("3D view"), name = 'nviz')
+        self.notebook.InsertPage(index=idx + 1, page=self.nviz, text=_("3D view"), name='nviz')
         self.notebook.SetSelectionByName('nviz')
 
         # this is a bit strange here since a new window is created everytime

Modified: grass/branches/releasebranch_7_0/gui/wxpython/lmgr/pyshell.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/lmgr/pyshell.py	2016-02-07 21:13:00 UTC (rev 67768)
+++ grass/branches/releasebranch_7_0/gui/wxpython/lmgr/pyshell.py	2016-02-07 21:21:24 UTC (rev 67769)
@@ -29,8 +29,9 @@
 
 class PyShellWindow(wx.Panel):
     """Python Shell Window"""
-    def __init__(self, parent, id = wx.ID_ANY, **kwargs):
-        self.parent = parent # GMFrame
+    def __init__(self, parent, giface, id = wx.ID_ANY, **kwargs):
+        self.parent = parent
+        self.giface = giface
         
         wx.Panel.__init__(self, parent = parent, id = id, **kwargs)
         
@@ -98,7 +99,7 @@
         if not fname:
             return _("Raster or vector map <%s> not found") % (name)
         
-        self.parent.GetLayerTree().AddLayer(ltype = ltype,
+        self.giface.GetLayerTree().AddLayer(ltype = ltype,
                                             lname = fname,
                                             lchecked = True,
                                             lcmd = [lcmd, 'map=%s' % fname])

Modified: grass/branches/releasebranch_7_0/gui/wxpython/nviz/tools.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/nviz/tools.py	2016-02-07 21:13:00 UTC (rev 67768)
+++ grass/branches/releasebranch_7_0/gui/wxpython/nviz/tools.py	2016-02-07 21:21:24 UTC (rev 67769)
@@ -64,14 +64,15 @@
 class NvizToolWindow(FN.FlatNotebook):
     """Nviz (3D view) tools panel
     """
-    def __init__(self, parent, display, id = wx.ID_ANY,
-                 style = globalvar.FNPageStyle|FN.FNB_NO_X_BUTTON,
+    def __init__(self, parent, tree, display, id=wx.ID_ANY,
+                 style=globalvar.FNPageStyle|FN.FNB_NO_X_BUTTON,
                  **kwargs):
         Debug.msg(5, "NvizToolWindow.__init__()")
-        self.parent     = parent # GMFrame
+        self.parent = parent
+        self.tree = tree
         self.mapDisplay = display
-        self.mapWindow  = display.GetWindow()
-        self._display   = self.mapWindow.GetDisplay()
+        self.mapWindow = display.GetWindow()
+        self._display = self.mapWindow.GetDisplay()
          
         if globalvar.hasAgw:
             kwargs['agwStyle'] = style
@@ -129,10 +130,10 @@
     def SetInitialMaps(self):
         """Set initial raster and vector map"""
         for ltype in ('raster', 'vector', '3d-raster'):
-            selectedLayer = self.parent.GetLayerTree().GetSelectedLayer(multi = False, checkedOnly = True)
+            selectedLayer = self.tree.GetSelectedLayer(multi = False, checkedOnly = True)
             if selectedLayer is None:
                 continue
-            selectedLayer = self.parent.GetLayerTree().GetLayerInfo(selectedLayer, key = 'maplayer')
+            selectedLayer = self.tree.GetLayerInfo(selectedLayer, key = 'maplayer')
             layers = self.mapWindow.Map.GetListOfLayers(ltype = ltype, active = True)
             if selectedLayer in layers:
                 selection = selectedLayer.GetName()
@@ -2075,13 +2076,12 @@
         :param name: layer name
         :param mapType: map type (raster, vector, 3d-raster)
         """
-        tree = self.parent.GetLayerTree()
-        items = tree.FindItemByData(key = 'name', value = name)
+        items = self.tree.FindItemByData(key = 'name', value = name)
         if not items:
             return None
         for item in items:
-            if tree.GetLayerInfo(item, key = 'type') == mapType:
-                return tree.GetLayerInfo(item, key = 'nviz')
+            if self.tree.GetLayerInfo(item, key = 'type') == mapType:
+                return self.tree.GetLayerInfo(item, key = 'nviz')
         return None
 
     def OnRecord(self, event):
@@ -3405,9 +3405,9 @@
        
         checked = event.IsChecked()
         name = self.FindWindowById(self.win['vector']['map']).GetValue()
-        items = self.parent.GetLayerTree().FindItemByData(key = 'name', value = name)
+        items = self.tree.FindItemByData(key = 'name', value = name)
         for item in items:
-            if self.parent.GetLayerTree().GetLayerInfo(item, key = 'type') == 'vector':
+            if self.tree.GetLayerInfo(item, key = 'type') == 'vector':
                 break
         data = self.GetLayerData('vector')['vector']
         
@@ -3720,10 +3720,10 @@
         """Enable/disable buttons 'add', 'delete',
         'move up', 'move down'"""
         nitems = list.GetCount()
-        add = self.parent.FindWindowById(self.win['volume']['btnAdd'])
-        delete = self.parent.FindWindowById(self.win['volume']['btnDelete'])
-        moveDown = self.parent.FindWindowById(self.win['volume']['btnMoveDown'])
-        moveUp = self.parent.FindWindowById(self.win['volume']['btnMoveUp'])
+        add = self.FindWindowById(self.win['volume']['btnAdd'])
+        delete = self.FindWindowById(self.win['volume']['btnDelete'])
+        moveDown = self.FindWindowById(self.win['volume']['btnMoveDown'])
+        moveUp = self.FindWindowById(self.win['volume']['btnMoveUp'])
         if nitems >= wxnviz.MAX_ISOSURFS:
             # disable add button on max
             add.Enable(False)



More information about the grass-commit mailing list