[GRASS-SVN] r46534 - in grass/trunk/gui/wxpython: . gui_modules scripts

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jun 3 05:08:46 EDT 2011


Author: martinl
Date: 2011-06-03 02:08:46 -0700 (Fri, 03 Jun 2011)
New Revision: 46534

Modified:
   grass/trunk/gui/wxpython/gui_modules/gmodeler.py
   grass/trunk/gui/wxpython/gui_modules/goutput.py
   grass/trunk/gui/wxpython/gui_modules/menuform.py
   grass/trunk/gui/wxpython/gui_modules/preferences.py
   grass/trunk/gui/wxpython/scripts/vkrige.py
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: don't use static indeces for notebook tabs


Modified: grass/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2011-06-03 07:43:29 UTC (rev 46533)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2011-06-03 09:08:46 UTC (rev 46534)
@@ -547,14 +547,9 @@
         
         self.statusbar = self.CreateStatusBar(number = 1)
         
-        if globalvar.hasAgw:
-            self.notebook = FN.FlatNotebook(parent = self, id = wx.ID_ANY,
-                                            agwStyle = FN.FNB_FANCY_TABS | FN.FNB_BOTTOM |
-                                            FN.FNB_NO_NAV_BUTTONS | FN.FNB_NO_X_BUTTON)
-        else:
-            self.notebook = FN.FlatNotebook(parent = self, id = wx.ID_ANY,
-                                            style = FN.FNB_FANCY_TABS | FN.FNB_BOTTOM |
-                                            FN.FNB_NO_NAV_BUTTONS | FN.FNB_NO_X_BUTTON)
+        self.notebook = menuform.GNotebook(parent = self,
+                                           style = FN.FNB_FANCY_TABS | FN.FNB_BOTTOM |
+                                           FN.FNB_NO_NAV_BUTTONS | FN.FNB_NO_X_BUTTON)
         
         self.canvas = ModelCanvas(self)
         self.canvas.SetBackgroundColour(wx.WHITE)
@@ -566,13 +561,12 @@
         
         self.itemPanel = ItemPanel(parent = self)
         
-        self.goutput = goutput.GMConsole(parent = self, pageid = 3,
-                                         notebook = self.notebook)
+        self.goutput = goutput.GMConsole(parent = self, notebook = self.notebook)
         
-        self.notebook.AddPage(self.canvas, text=_('Model'))
-        self.notebook.AddPage(self.itemPanel, text=_('Items'))
-        self.notebook.AddPage(self.variablePanel, text=_('Variables'))
-        self.notebook.AddPage(self.goutput, text=_('Command output'))
+        self.notebook.AddPage(page = self.canvas, text=_('Model'), name = 'model')
+        self.notebook.AddPage(page = self.itemPanel, text=_('Items'), name = 'items')
+        self.notebook.AddPage(page = self.variablePanel, text=_('Variables'), name = 'variables')
+        self.notebook.AddPage(page = self.goutput, text=_('Command output'), name = 'output')
         wx.CallAfter(self.notebook.SetSelection, 0)
         wx.CallAfter(self.ModelChanged, False)
 

Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py	2011-06-03 07:43:29 UTC (rev 46533)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py	2011-06-03 09:08:46 UTC (rev 46534)
@@ -169,9 +169,9 @@
 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,
+    def __init__(self, parent, id = wx.ID_ANY, margin = False,
                  notebook = None,
-                 style=wx.TAB_TRAVERSAL | wx.FULL_REPAINT_ON_RESIZE,
+                 style = wx.TAB_TRAVERSAL | wx.FULL_REPAINT_ON_RESIZE,
                  **kwargs):
         wx.SplitterWindow.__init__(self, parent, id, style = style, *kwargs)
         self.SetName("GMConsole")
@@ -186,8 +186,7 @@
         else:
             self._notebook = self.parent.notebook
         self.lineWidth       = 80
-        self.pageid          = pageid
-                        
+        
         # remember position of line begining (used for '\r')
         self.linePos         = -1
         
@@ -384,8 +383,8 @@
         self.cmd_output.SetStyle()
 
         if switchPage and \
-                self._notebook.GetSelection() != self.parent.goutput.pageid:
-            self._notebook.SetSelection(self.parent.goutput.pageid)
+                self._notebook.GetSelection() != self._notebook.GetPageIndexByName('console'):
+            self._notebook.SetSelectionByName('console')
         
         if not style:
             style = self.cmd_output.StyleDefault
@@ -513,8 +512,8 @@
                 # other GRASS commands (r|v|g|...)
                 # switch to 'Command output' if required
                 if switchPage:
-                    if self._notebook.GetSelection() != self.parent.goutput.pageid:
-                        self._notebook.SetSelection(self.parent.goutput.pageid)
+                    if self._notebook.GetSelection() != self._notebook.GetPageIndexByName('console'):
+                        self._notebook.SetSelectionByName('console')
                     
                     self.parent.SetFocus()
                     self.parent.Raise()
@@ -635,12 +634,12 @@
         """!Print command output"""
         message = event.text
         type  = event.type
-        if self._notebook.GetSelection() != self.parent.goutput.pageid:
-            textP = self._notebook.GetPageText(self.parent.goutput.pageid)
+        if self._notebook.GetSelection() != self._notebook.GetPageIndexByName('console'):
+            page = self._notebook.GetPageIndexByName('console')
+            textP = self._notebook.GetPageText(page)
             if textP[-1] != ')':
                 textP += ' (...)'
-            self._notebook.SetPageText(self.parent.goutput.pageid,
-                                       textP)
+            self._notebook.SetPageText(page, textP)
         
         # message prefix
         if type == 'warning':

Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2011-06-03 07:43:29 UTC (rev 46533)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2011-06-03 09:08:46 UTC (rev 46534)
@@ -12,6 +12,7 @@
  - GrassGUIApp
  - GUI
  - FloatValidator
+ - GNotebook
 
 This program is just a coarse approach to automatically build a GUI
 from a xml-based GRASS user interface description.
@@ -845,9 +846,9 @@
         self.btn_help = wx.Button(parent = self.panel, id = wx.ID_HELP)
         self.btn_help.SetToolTipString(_("Show manual page of the command (Ctrl+H)"))
         self.btn_help.Bind(wx.EVT_BUTTON, self.OnHelp)
-        if not hasattr(self.notebookpanel, "manual_tab_id"):
+        if self.notebookpanel.notebook.GetPageIndexByName('manual') < 0:
             self.btn_help.Hide()
-
+        
         # add help button
         btnsizer.Add(item = self.btn_help, proportion = 0, flag = wx.ALL | wx.ALIGN_CENTER, border = 10)
         
@@ -1020,8 +1021,8 @@
         if self.standalone or cmd[0][0:2] !=  "d.":
             # Send any non-display command to parent window (probably wxgui.py)
             # put to parents switch to 'Command output'
-            if self.notebookpanel.notebook.GetSelection() !=  self.notebookpanel.goutputId:
-                self.notebookpanel.notebook.SetSelection(self.notebookpanel.goutputId)
+            if self.notebookpanel.notebook.GetSelection() !=  self.notebookpanel.notebook.GetPageIndexByName('output'):
+                self.notebookpanel.notebook.SetSelectionByName('output')
             
             try:
                 if self.task.path:
@@ -1082,8 +1083,8 @@
 
     def OnHelp(self, event):
         """!Show manual page (switch to the 'Manual' notebook page)"""
-        if hasattr(self.notebookpanel, "manual_tab_id"):
-            self.notebookpanel.notebook.SetSelection(self.notebookpanel.manual_tab_id)
+        if self.notebookpanel.notebook.GetPageIndexByName('manual') > -1:
+            self.notebookpanel.notebook.SetSelectionByName('manual')
             self.notebookpanel.OnPageChange(None)
         
         if event:    
@@ -1140,11 +1141,7 @@
         panelsizer = wx.BoxSizer(orient = wx.VERTICAL)
 
         # Build notebook
-        nbStyle = globalvar.FNPageStyle
-        if globalvar.hasAgw:
-            self.notebook = FN.FlatNotebook(self, id = wx.ID_ANY, agwStyle = nbStyle)
-        else:
-            self.notebook = FN.FlatNotebook(self, id = wx.ID_ANY, style = nbStyle)
+        self.notebook = GNotebook(self, style = globalvar.FNPageStyle)
         self.notebook.SetTabAreaColour(globalvar.FNPageColor)
         self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChange)
 
@@ -1154,25 +1151,21 @@
             tab[section] = scrolled.ScrolledPanel(parent = self.notebook)
             tab[section].SetScrollRate(10, 10)
             tabsizer[section] = wx.BoxSizer(orient = wx.VERTICAL)
-            self.notebook.AddPage(tab[section], text = section)
+            self.notebook.AddPage(page = tab[section], text = section)
 
         # are we running from command line?
         ### add 'command output' tab regardless standalone dialog
         if self.parent.GetName() ==  "MainFrame" and self.parent.get_dcmd is None:
-            self.goutput = goutput.GMConsole(parent = self, margin = False,
-                                             pageid = self.notebook.GetPageCount())
-            self.goutputId = self.notebook.GetPageCount()
-            self.outpage = self.notebook.AddPage(self.goutput, text = _("Command output"))
+            self.goutput = goutput.GMConsole(parent = self, margin = False)
+            self.outpage = self.notebook.AddPage(page = self.goutput, text = _("Command output"), name = 'output')
         else:
             self.goutput = None
-            self.goutputId = -1
         
         self.manual_tab = HelpPanel(parent = self, grass_command = self.task.name)
         if not self.manual_tab.IsFile():
             self.manual_tab.Hide()
         else:
-            self.notebook.AddPage(self.manual_tab, text = _("Manual"))
-            self.manual_tab_id = self.notebook.GetPageCount() - 1
+            self.notebook.AddPage(page = self.manual_tab, text = _("Manual"), name = 'manual')
         
         self.notebook.SetSelection(0)
 
@@ -1989,9 +1982,9 @@
             sel = self.notebook.GetSelection()
         else:
             sel = event.GetSelection()
-
-        if hasattr(self, "manual_tab_id") and \
-                sel ==  self.manual_tab_id:
+        
+        idx = self.notebook.GetPageIndexByName('manual')
+        if idx > -1 and sel ==  idx:
             # calling LoadPage() is strangely time-consuming (only first call)
             # FIXME: move to helpPage.__init__()
             if not self.manual_tab.IsLoaded():
@@ -2405,7 +2398,43 @@
     
     def TransferFromWindow(self):
         return True # Prevent wxDialog from complaining.
-     
+
+class GNotebook(FN.FlatNotebook):
+    """!Generic notebook widget
+    """
+    def __init__(self, parent, style, **kwargs):
+        if globalvar.hasAgw:
+            FN.FlatNotebook.__init__(self, parent, id = wx.ID_ANY, agwStyle = style, **kwargs)
+        else:
+            FN.FlatNotebook.__init__(self, parent, id = wx.ID_ANY, style = style, **kwargs)
+        
+        self.notebookPages = {}
+            
+    def AddPage(self, **kwargs):
+        """!Add a page
+        """
+        if 'name' in kwargs:
+            self.notebookPages[kwargs['name']] = kwargs['page']
+            del kwargs['name']
+        super(GNotebook, self).AddPage(**kwargs)
+
+    def SetSelectionByName(self, page):
+        """!Set notebook
+        
+        @param page names, eg. 'layers', 'console', 'search', 'pyshell', 'nviz'
+        """
+        self.SetSelection(self.GetPageIndexByName(page))
+        
+    def GetPageIndexByName(self, page):
+        """!Get notebook page index
+        
+        @param page name
+        """
+        if page not in self.notebookPages:
+            return -1
+        
+        return self.GetPageIndex(self.notebookPages[page])
+    
 if __name__ ==  "__main__":
 
     if len(sys.argv) ==  1:

Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py	2011-06-03 07:43:29 UTC (rev 46533)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py	2011-06-03 09:08:46 UTC (rev 46534)
@@ -112,6 +112,11 @@
                 'askOnQuit' : {
                     'enabled' : True
                     },
+                # hide tabs
+                'hideTabs' : {
+                    'search' : False,
+                    'pyshell' : False,
+                    },
                 },
             #
             # appearance
@@ -1127,7 +1132,27 @@
         
         gridSizer.Add(item = askOnQuit,
                       pos = (row, 0), span = (1, 2))
+
+        row += 1
+        hideSearch = wx.CheckBox(parent = panel, id = wx.ID_ANY,
+                                 label = _("Hide '%s' tab (requires GUI restart)") % _("Search module"),
+                                 name = 'IsChecked')
+        hideSearch.SetValue(self.settings.Get(group = 'manager', key = 'hideTabs', subkey = 'search'))
+        self.winId['manager:hideTabs:search'] = hideSearch.GetId()
         
+        gridSizer.Add(item = hideSearch,
+                      pos = (row, 0), span = (1, 2))
+        
+        row += 1
+        hidePyShell = wx.CheckBox(parent = panel, id = wx.ID_ANY,
+                                  label = _("Hide '%s' tab (requires GUI restart)") % _("Python shell"),
+                                  name = 'IsChecked')
+        hidePyShell.SetValue(self.settings.Get(group = 'manager', key = 'hideTabs', subkey = 'pyshell'))
+        self.winId['manager:hideTabs:pyshell'] = hidePyShell.GetId()
+        
+        gridSizer.Add(item = hidePyShell,
+                      pos = (row, 0), span = (1, 2))
+        
         sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
         

Modified: grass/trunk/gui/wxpython/scripts/vkrige.py
===================================================================
--- grass/trunk/gui/wxpython/scripts/vkrige.py	2011-06-03 07:43:29 UTC (rev 46533)
+++ grass/trunk/gui/wxpython/scripts/vkrige.py	2011-06-03 09:08:46 UTC (rev 46534)
@@ -103,7 +103,6 @@
         
         ## Command output. From menuform module, cmdPanel class
         self.goutput = goutput.GMConsole(parent = self, margin = False,
-                                         pageid = self.RPackagesBook.GetPageCount(),
                                          notebook = self.RPackagesBook)
         self.goutputId = self.RPackagesBook.GetPageCount()
         self.outpage = self.RPackagesBook.AddPage(self.goutput, text = _("Command output"))

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2011-06-03 07:43:29 UTC (rev 46533)
+++ grass/trunk/gui/wxpython/wxgui.py	2011-06-03 09:08:46 UTC (rev 46534)
@@ -127,11 +127,10 @@
         
         # creating widgets
         self._createMenuBar()
-        self.statusbar = self.CreateStatusBar(number=1)
-        self.notebookPages = {}
+        self.statusbar = self.CreateStatusBar(number = 1)
         self.notebook  = self._createNoteBook()
-        self.toolbars = { 'main'  : LayerManagerToolbar(parent = self),
-                          'tools' : ToolsToolbar(parent = self) }
+        self.toolbars  = { 'main'  : LayerManagerToolbar(parent = self),
+                           'tools' : ToolsToolbar(parent = self) }
         
         # self.SetToolBar(self.toolbar)
         self._auimgr.AddPane(self.toolbars['main'],
@@ -165,7 +164,7 @@
 
         self._auimgr.Update()
 
-        wx.CallAfter(self.SetNBPage, 'layers')
+        wx.CallAfter(self.notebook.SetSelectionByName, 'layers')
         
         # use default window layout ?
         if UserSettings.Get(group = 'general', key = 'defWindowPos', subkey = 'enabled'):
@@ -219,10 +218,7 @@
         
     def _createNoteBook(self):
         """!Creates notebook widgets"""
-        if globalvar.hasAgw:
-            self.notebook = FN.FlatNotebook(parent = self, id = wx.ID_ANY, agwStyle = globalvar.FNPageDStyle)
-        else:
-            self.notebook = FN.FlatNotebook(parent = self, id = wx.ID_ANY, style = globalvar.FNPageDStyle)
+        self.notebook = menuform.GNotebook(parent = self, style = globalvar.FNPageDStyle)
         # create displays notebook widget and add it to main notebook page
         cbStyle = globalvar.FNPageStyle
         if globalvar.hasAgw:
@@ -230,23 +226,25 @@
         else:
             self.gm_cb = FN.FlatNotebook(self, id = wx.ID_ANY, style = cbStyle)
         self.gm_cb.SetTabAreaColour(globalvar.FNPageColor)
-        self.notebook.AddPage(self.gm_cb, text = _("Map layers"))
-        self.notebookPages['layers'] = self.gm_cb
+        self.notebook.AddPage(page = self.gm_cb, text = _("Map layers"), name = 'layers')
         
         # create 'command output' text area
-        self.goutput = goutput.GMConsole(self, pageid = 1)
-        self.notebook.AddPage(self.goutput, text = _("Command console"))
-        self.notebookPages['console'] = self.goutput
+        self.goutput = goutput.GMConsole(self)
+        self.notebook.AddPage(page = self.goutput, text = _("Command console"), name = 'console')
         
         # create 'search module' notebook page
-        self.search = MenuTreeWindow(parent = self)
-        self.notebook.AddPage(self.search, text = _("Search module"))
-        self.notebookPages['search'] = self.search
+        if not UserSettings.Get(group = 'manager', key = 'hideTabs', subkey = 'search'):
+            self.search = MenuTreeWindow(parent = self)
+            self.notebook.AddPage(page = self.search, text = _("Search module"), name = 'search')
+        else:
+            self.search = None
         
         # create 'python shell' notebook page
-        self.pyshell = PyShellWindow(parent = self)
-        self.notebook.AddPage(self.pyshell, text = _("Python shell"))
-        self.notebookPages['pyshell'] = self.pyshell
+        if not UserSettings.Get(group = 'manager', key = 'hideTabs', subkey = 'pyshell'):
+            self.pyshell = PyShellWindow(parent = self)
+            self.notebook.AddPage(page = self.pyshell, text = _("Python shell"), name = 'pyshell')
+        else:
+            self.pyshell = None
         
         # bindings
         self.gm_cb.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED,    self.OnCBPageChanged)
@@ -254,30 +252,21 @@
         self.gm_cb.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING,    self.OnCBPageClosed)
         
         return self.notebook
-    
-    def SetNBPage(self, page):
-        """!Set notebook page - 'layers', 'console', 'search', 'pyshell', 'nviz'"""
-        self.notebook.SetSelection(self.GetNBPageIndex(page))
-        
-    def GetNBPageIndex(self, page):
-        """!Get notebook page index"""
-        return self.notebook.GetPageIndex(self.notebookPages[page])
-        
+            
     def AddNviz(self):
         """!Add nviz notebook page"""
         self.nviz = nviz_tools.NvizToolWindow(parent = self,
                                               display = self.curr_page.maptree.GetMapDisplay())
-        self.notebook.AddPage(self.nviz, text = _("3D view"))
-        self.notebookPages['nviz'] = self.nviz
-        self.SetNBPage('nviz')
+        self.notebook.AddPage(page = self.nviz, text = _("3D view"), name = 'nviz')
+        self.notebook.SetSelectionByName('nviz')
         self.existNviz = True
         
     def RemoveNviz(self):
         """!Remove nviz notebook page"""
         # print self.notebook.GetPage(1)
-        self.notebook.RemovePage(self.GetNBPageIndex('nviz'))
+        self.notebook.RemovePage(self.notebook.GetPageIndexByName('nviz'))
         del self.nviz
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         
     def WorkspaceChanged(self):
         """!Update window title"""
@@ -390,7 +379,7 @@
     def OnPageChanged(self, event):
         """!Page in notebook changed"""
         page = event.GetSelection()
-        if page == self.goutput.pageid:
+        if page == self.notebook.GetPageIndexByName('console'):
             # remove '(...)'
             self.notebook.SetPageText(page, _("Command console"))
             wx.CallAfter(self.goutput.cmd_prompt.SetFocus)
@@ -1258,7 +1247,7 @@
         if not self.curr_page:
             self.NewDisplay(show = True)
         
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('raster')
         
     def OnAddRaster3D(self, event):
@@ -1294,7 +1283,7 @@
         if not self.curr_page:
             self.NewDisplay(show = True)
         
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('vector')
 
     def OnAddVectorMisc(self, event):
@@ -1311,12 +1300,12 @@
 
     def OnAddVectorTheme(self, event):
         """!Add thematic vector map to the current layer tree"""
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('thememap')
 
     def OnAddVectorChart(self, event):
         """!Add chart vector map to the current layer tree"""
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('themechart')
 
     def OnAddOverlay(self, event):
@@ -1337,32 +1326,32 @@
         
     def OnAddRaster3D(self, event):
         """!Add 3D raster map to the current layer tree"""
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('3d-raster')
 
     def OnAddRasterRGB(self, event):
         """!Add RGB raster map to the current layer tree"""
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('rgb')
 
     def OnAddRasterHIS(self, event):
         """!Add HIS raster map to the current layer tree"""
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('his')
 
     def OnAddRasterShaded(self, event):
         """!Add shaded relief raster map to the current layer tree"""
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('shaded')
 
     def OnAddRasterArrow(self, event):
         """!Add flow arrows raster map to the current layer tree"""
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('rastarrow')
 
     def OnAddRasterNum(self, event):
         """!Add cell number raster map to the current layer tree"""
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('rastnum')
 
     def OnAddCommand(self, event):
@@ -1371,7 +1360,7 @@
         if not self.curr_page:
             self.NewDisplay(show = True)
 
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('command')
 
         # show map display
@@ -1383,7 +1372,7 @@
         if not self.curr_page:
             self.NewDisplay(show = True)
 
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('group')
 
         # show map display
@@ -1391,17 +1380,17 @@
 
     def OnAddGrid(self, event):
         """!Add grid map layer to the current layer tree"""
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('grid')
 
     def OnAddGeodesic(self, event):
         """!Add geodesic line map layer to the current layer tree"""
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('geodesic')
 
     def OnAddRhumb(self, event):
         """!Add rhumb map layer to the current layer tree"""
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('rhumb')
 
     def OnAddLabels(self, event):
@@ -1410,7 +1399,7 @@
         if not self.curr_page:
             self.NewDisplay(show = True)
 
-        self.SetNBPage('layers')
+        self.notebook.SetSelectionByName('layers')
         self.curr_page.maptree.AddLayer('labels')
 
         # show map display
@@ -1463,10 +1452,10 @@
         if event.ControlDown():
             if kc == wx.WXK_TAB:
                 # switch layer list / command output
-                if self.notebook.GetSelection() == self.GetNBPageIndex('layers'):
-                    self.SetNBPage('console')
+                if self.notebook.GetSelection() == self.notebook.GetPageIndexByName('layers'):
+                    self.notebook.SetSelectionByName('console')
                 else:
-                    self.SetNBPage('layers')
+                    self.notebook.SetSelectionByName('layers')
         
         try:
             ckc = chr(kc)



More information about the grass-commit mailing list