[GRASS-SVN] r67627 - in grass/trunk/gui/wxpython: gui_core lmgr nviz
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jan 22 20:03:13 PST 2016
Author: annakrat
Date: 2016-01-22 20:03:12 -0800 (Fri, 22 Jan 2016)
New Revision: 67627
Modified:
grass/trunk/gui/wxpython/gui_core/menu.py
grass/trunk/gui/wxpython/gui_core/widgets.py
grass/trunk/gui/wxpython/lmgr/frame.py
grass/trunk/gui/wxpython/lmgr/pyshell.py
grass/trunk/gui/wxpython/nviz/tools.py
Log:
wxGUI: correct parent hierarchy in layer manager bottom notebook, it's first step to use wx.Notebook instead of FlatNotebook
Modified: grass/trunk/gui/wxpython/gui_core/menu.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/menu.py 2016-01-22 19:42:04 UTC (rev 67626)
+++ grass/trunk/gui/wxpython/gui_core/menu.py 2016-01-23 04:03:12 UTC (rev 67627)
@@ -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/trunk/gui/wxpython/gui_core/widgets.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/widgets.py 2016-01-22 19:42:04 UTC (rev 67626)
+++ grass/trunk/gui/wxpython/gui_core/widgets.py 2016-01-23 04:03:12 UTC (rev 67627)
@@ -119,7 +119,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
@@ -230,7 +236,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/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py 2016-01-22 19:42:04 UTC (rev 67626)
+++ grass/trunk/gui/wxpython/lmgr/frame.py 2016-01-23 04:03:12 UTC (rev 67627)
@@ -282,9 +282,9 @@
# 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)
@@ -296,7 +296,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')
@@ -314,20 +314,21 @@
# 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:
self.search = None
# create 'data catalog' notebook page
- self.datacatalog = DataCatalog(parent = self, giface = self._giface)
+ self.datacatalog = DataCatalog(parent=self.notebook, giface=self._giface)
self.datacatalog.showNotification.connect(lambda message: self.SetStatusText(message))
self.notebook.AddPage(page = self.datacatalog, text = _("Data catalog"), name = 'catalog')
# 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
@@ -359,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/trunk/gui/wxpython/lmgr/pyshell.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/pyshell.py 2016-01-22 19:42:04 UTC (rev 67626)
+++ grass/trunk/gui/wxpython/lmgr/pyshell.py 2016-01-23 04:03:12 UTC (rev 67627)
@@ -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/trunk/gui/wxpython/nviz/tools.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/tools.py 2016-01-22 19:42:04 UTC (rev 67626)
+++ grass/trunk/gui/wxpython/nviz/tools.py 2016-01-23 04:03:12 UTC (rev 67627)
@@ -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