[GRASS-SVN] r45553 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 4 12:10:38 EST 2011
Author: martinl
Date: 2011-03-04 09:10:37 -0800 (Fri, 04 Mar 2011)
New Revision: 45553
Modified:
grass/trunk/gui/wxpython/gui_modules/gcpmanager.py
grass/trunk/gui/wxpython/gui_modules/gdialogs.py
grass/trunk/gui/wxpython/gui_modules/gmodeler.py
grass/trunk/gui/wxpython/gui_modules/goutput.py
grass/trunk/gui/wxpython/gui_modules/histogram.py
grass/trunk/gui/wxpython/gui_modules/layertree.py
grass/trunk/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI: define blackList for module flags/params (e.g. d.legend -m)
(merge r45552 from devbr6)
Modified: grass/trunk/gui/wxpython/gui_modules/gcpmanager.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcpmanager.py 2011-03-04 17:01:13 UTC (rev 45552)
+++ grass/trunk/gui/wxpython/gui_modules/gcpmanager.py 2011-03-04 17:10:37 UTC (rev 45553)
@@ -502,10 +502,9 @@
def OnMkGroup(self, event):
"""!Create new group in source location/mapset"""
- menuform.GUI().ParseCommand(['i.group'],
- completed=(self.GetOptData, None, ''),
- parentframe=self.parent.parent, modal=True)
-
+ menuform.GUI(parent = self.parent.parent, modal = True).ParseCommand(['i.group'],
+ completed = (self.GetOptData, None, ''))
+
def OnVGroup(self, event):
"""!Add vector maps to group"""
dlg = VectGroup(parent = self,
Modified: grass/trunk/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2011-03-04 17:01:13 UTC (rev 45552)
+++ grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2011-03-04 17:10:37 UTC (rev 45553)
@@ -467,9 +467,9 @@
mapName, found = utils.GetLayerNameFromCmd(self.parent.MapWindow.overlays[self.ovlId]['cmd'])
if self.parent.MapWindow.overlays[self.ovlId]['propwin'] is None and mapName:
# build properties dialog
- menuform.GUI().ParseCommand(cmd=self.cmd,
- completed=(self.GetOptData, self.name, ''),
- parentframe=self.parent, show=False)
+ menuform.GUI(parent = self.parent, show = False).ParseCommand(cmd=self.cmd,
+ completed=(self.GetOptData, self.name, ''))
+
if found:
# enable 'OK' button
self.btnOK.Enable()
@@ -506,9 +506,9 @@
"""
if self.parent.MapWindow.overlays[self.ovlId]['propwin'] is None:
# build properties dialog
- menuform.GUI().ParseCommand(cmd=self.cmd,
- completed=(self.GetOptData, self.name, ''),
- parentframe=self.parent)
+ menuform.GUI(parent = self.parent).ParseCommand(cmd=self.cmd,
+ completed=(self.GetOptData, self.name, ''))
+
else:
if self.parent.MapWindow.overlays[self.ovlId]['propwin'].IsShown():
self.parent.MapWindow.overlays[self.ovlId]['propwin'].SetFocus()
@@ -1244,9 +1244,8 @@
def OnCmdDialog(self, event):
"""!Show command dialog"""
name = self._getCommand()
- menuform.GUI().ParseCommand(cmd = [name],
- parentframe = self, modal = True)
-
+ menuform.GUI(parentframe = self, modal = True).ParseCommand(cmd = [name])
+
class DxfImportDialog(ImportDialog):
"""!Dialog for bulk import of DXF layers"""
def __init__(self, parent):
@@ -1332,9 +1331,8 @@
def OnCmdDialog(self, event):
"""!Show command dialog"""
- menuform.GUI().ParseCommand(cmd = ['v.in.dxf'],
- parentframe = self, modal = True)
-
+ menuform.GUI(parent = self, modal = True).ParseCommand(cmd = ['v.in.dxf'])
+
class LayersList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin,
listmix.CheckListCtrlMixin, listmix.TextEditMixin):
"""!List of layers to be imported (dxf, shp...)"""
Modified: grass/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2011-03-04 17:01:13 UTC (rev 45552)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2011-03-04 17:10:37 UTC (rev 45553)
@@ -379,10 +379,9 @@
error string"""
errList = list()
for action in self.GetItems(objType = ModelAction):
- task = menuform.GUI().ParseCommand(cmd = action.GetLog(string = False),
- show = None)
+ task = menuform.GUI(show = None).ParseCommand(cmd = action.GetLog(string = False))
errList += task.getCmdError()
-
+
return errList
def Run(self, log, onDone):
@@ -1200,9 +1199,8 @@
# show properties dialog
win = action.GetPropDialog()
if not win and action.GetLog(string = False):
- module = menuform.GUI().ParseCommand(action.GetLog(string = False),
- completed = (self.GetOptData, action, action.GetParams()),
- parentframe = self, show = True)
+ module = menuform.GUI(parent = self, show = True).ParseCommand(action.GetLog(string = False),
+ completed = (self.GetOptData, action, action.GetParams()))
elif win and not win.IsShown():
win.Show()
@@ -1667,8 +1665,7 @@
height = UserSettings.Get(group='modeler', key='action', subkey=('size', 'height'))
if cmd:
- self.task = menuform.GUI().ParseCommand(cmd = cmd,
- show = None)
+ self.task = menuform.GUI(show = None).ParseCommand(cmd = cmd)
else:
if task:
self.task = task
@@ -1944,8 +1941,7 @@
else:
action = rel.GetFrom()
- task = menuform.GUI().ParseCommand(cmd = action.GetLog(string = False),
- show = None)
+ task = menuform.GUI(show = None).ParseCommand(cmd = action.GetLog(string = False))
task.set_param(rel.GetName(), self.value)
action.SetParams(params = task.get_options())
@@ -2133,9 +2129,8 @@
self.frame.ModelChanged()
shape = self.GetShape()
if isinstance(shape, ModelAction):
- module = menuform.GUI().ParseCommand(shape.GetLog(string = False),
- completed = (self.frame.GetOptData, shape, shape.GetParams()),
- parentframe = self.frame, show = True)
+ module = menuform.GUI(parent = self.frame, show = True).ParseCommand(shape.GetLog(string = False),
+ completed = (self.frame.GetOptData, shape, shape.GetParams()))
elif isinstance(shape, ModelData):
dlg = ModelDataDialog(parent = self.frame, shape = shape)
@@ -2720,8 +2715,7 @@
cmd.append('%s=%s' % (name,
self._filterValue(self._getNodeText(p, 'value'))))
- task, err = menuform.GUI().ParseCommand(cmd = cmd,
- show = None, checkError = True)
+ task, err = menuform.GUI(show = None, checkError = True).ParseCommand(cmd = cmd)
if err:
GWarning(os.linesep.join(err))
@@ -4476,8 +4470,7 @@
def _writePythonAction(self, item):
"""!Write model action to Python file"""
- task = menuform.GUI().ParseCommand(cmd = item.GetLog(string = False),
- show = None)
+ task = menuform.GUI(show = None).ParseCommand(cmd = item.GetLog(string = False))
opts = task.get_options()
flags = ''
params = list()
Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py 2011-03-04 17:01:13 UTC (rev 45552)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py 2011-03-04 17:10:37 UTC (rev 45553)
@@ -126,7 +126,7 @@
except KeyError:
pass
else:
- moduleInterface = menuform.GUI().ParseCommand(args[0], show = None)
+ moduleInterface = menuform.GUI(show = None).ParseCommand(args[0])
outputParam = moduleInterface.get_param(value = 'output', raiseError = False)
if outputParam and outputParam['prompt'] == 'raster':
mapName = outputParam['value']
@@ -527,7 +527,7 @@
if task and command[0] not in ('v.krige'):
# process GRASS command without argument
- menuform.GUI().ParseCommand(command, parentframe = self)
+ menuform.GUI(parent = self).ParseCommand(command)
else:
# process GRASS command with argument
self.cmdThread.RunCmd(GrassCmd,
@@ -555,7 +555,7 @@
if task:
# process GRASS command without argument
- menuform.GUI().ParseCommand(command, parentframe = self)
+ menuform.GUI(parent = self).ParseCommand(command)
else:
self.cmdThread.RunCmd(GrassCmd,
onDone,
@@ -757,7 +757,7 @@
display.GetRender().GetListOfLayers(l_type = 'vector'))
try:
- task = menuform.GUI().ParseCommand(event.cmd, show = None)
+ task = menuform.GUI(show = None).ParseCommand(event.cmd)
except gcmd.GException:
task = None
return
Modified: grass/trunk/gui/wxpython/gui_modules/histogram.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/histogram.py 2011-03-04 17:01:13 UTC (rev 45552)
+++ grass/trunk/gui/wxpython/gui_modules/histogram.py 2011-03-04 17:10:37 UTC (rev 45553)
@@ -317,9 +317,8 @@
if self.mapname != '':
cmd.append('map=%s' % self.mapname)
- menuform.GUI().ParseCommand(cmd,
- completed = (self.GetOptData, None, self.params),
- parentframe = self)
+ menuform.GUI(parent = self).ParseCommand(cmd,
+ completed = (self.GetOptData, None, self.params))
def GetOptData(self, dcmd, layer, params, propwin):
"""!Callback method for histogram command generated by dialog
Modified: grass/trunk/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/layertree.py 2011-03-04 17:01:13 UTC (rev 45552)
+++ grass/trunk/gui/wxpython/gui_modules/layertree.py 2011-03-04 17:10:37 UTC (rev 45553)
@@ -517,10 +517,8 @@
def OnColorTable(self, event):
"""!Set color table for raster map"""
name = self.GetPyData(self.layer_selected)[0]['maplayer'].GetName()
- menuform.GUI().ParseCommand(['r.colors',
- 'map=%s' % name],
- parentframe = self,
- centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['r.colors',
+ 'map=%s' % name])
def OnHistogram(self, event):
"""
@@ -929,10 +927,9 @@
ltype)
if self.GetPyData(layer)[0]['cmd']:
- module = menuform.GUI()
+ module = menuform.GUI(parent = self, show = show, centreOnParent = False)
module.ParseCommand(self.GetPyData(layer)[0]['cmd'],
- completed = (self.GetOptData,layer,params),
- parentframe = self, show = show, centreOnParent = False)
+ completed = (self.GetOptData,layer,params))
self.GetPyData(layer)[0]['cmd'] = module.GetCmd()
elif ltype == 'raster':
@@ -940,58 +937,69 @@
if UserSettings.Get(group = 'cmd', key = 'rasterOpaque', subkey = 'enabled'):
cmd.append('-n')
- menuform.GUI().ParseCommand(cmd, completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(cmd,
+ completed = (self.GetOptData,layer,params))
+
elif ltype == '3d-raster':
cmd = ['d.rast3d']
- menuform.GUI().ParseCommand(cmd, completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(cmd,
+ completed = (self.GetOptData,layer,params))
+
elif ltype == 'rgb':
- menuform.GUI().ParseCommand(['d.rgb'], completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['d.rgb'],
+ completed = (self.GetOptData,layer,params))
+
elif ltype == 'his':
- menuform.GUI().ParseCommand(['d.his'], completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['d.his'],
+ completed = (self.GetOptData,layer,params))
+
elif ltype == 'shaded':
- menuform.GUI().ParseCommand(['d.shadedmap'], completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['d.shadedmap'],
+ completed = (self.GetOptData,layer,params))
+
elif ltype == 'rastarrow':
- menuform.GUI().ParseCommand(['d.rast.arrow'], completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['d.rast.arrow'],
+ completed = (self.GetOptData,layer,params))
+
elif ltype == 'rastnum':
- menuform.GUI().ParseCommand(['d.rast.num'], completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['d.rast.num'],
+ completed = (self.GetOptData,layer,params))
+
elif ltype == 'vector':
types = list()
for ftype in ['point', 'line', 'boundary', 'centroid', 'area', 'face']:
if UserSettings.Get(group = 'cmd', key = 'showType', subkey = [ftype, 'enabled']):
types.append(ftype)
- menuform.GUI().ParseCommand(['d.vect', 'type=%s' % ','.join(types)],
- completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['d.vect', 'type=%s' % ','.join(types)],
+ completed = (self.GetOptData,layer,params))
+
elif ltype == 'thememap':
# -s flag requested, otherwise only first thematic category is displayed
# should be fixed by C-based d.thematic.* modules
- menuform.GUI().ParseCommand(['d.thematic.area'],
- completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['d.thematic.area'],
+ completed = (self.GetOptData,layer,params))
+
elif ltype == 'themechart':
- menuform.GUI().ParseCommand(['d.vect.chart'],
- completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['d.vect.chart'],
+ completed = (self.GetOptData,layer,params))
+
elif ltype == 'grid':
- menuform.GUI().ParseCommand(['d.grid'], completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['d.grid'],
+ completed = (self.GetOptData,layer,params))
+
elif ltype == 'geodesic':
- menuform.GUI().ParseCommand(['d.geodesic'], completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['d.geodesic'],
+ completed = (self.GetOptData,layer,params))
+
elif ltype == 'rhumb':
- menuform.GUI().ParseCommand(['d.rhumbline'], completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['d.rhumbline'],
+ completed = (self.GetOptData,layer,params))
+
elif ltype == 'labels':
- menuform.GUI().ParseCommand(['d.labels'], completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['d.labels'],
+ completed = (self.GetOptData,layer,params))
+
elif ltype == 'cmdlayer':
pass
elif ltype == 'group':
Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py 2011-03-04 17:01:13 UTC (rev 45552)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py 2011-03-04 17:10:37 UTC (rev 45553)
@@ -21,7 +21,7 @@
The XML stream is read from executing the command given in the
command line, thus you may call it for instance this way:
-python menuform.py r.basins.fill
+python <this file.py> r.basins.fill
Or you set an alias or wrap the call up in a nice shell script, GUI
environment ... please contribute your idea.
@@ -135,6 +135,13 @@
for (s,r) in str2rgb.items():
rgb2str[ r ] = s
+"""!Hide some options in the GUI"""
+_blackList = {
+ 'd.legend' : { 'flags' : ['m'],
+ 'params' : [] }
+}
+_ignoreBlackList = True
+
def color_resolve(color):
if len(color) > 0 and color[0] in "0123456789":
rgb = tuple(map(int, color.split(':')))
@@ -637,8 +644,15 @@
required = True
else:
required = False
+
+ if not _ignoreBlackList and \
+ _blackList.has_key(self.task.name) and \
+ p.get('name') in _blackList[self.task.name]['params']:
+ hidden = True
+ else:
+ hidden = False
- self.task.params.append({
+ self.task.params.append( {
"name" : p.get('name'),
"type" : p.get('type'),
"required" : required,
@@ -655,24 +669,36 @@
"values" : values,
"values_desc" : values_desc,
"value" : '',
- "key_desc" : key_desc })
+ "key_desc" : key_desc,
+ "hidden" : hidden
+ })
def __processFlags(self):
"""!Process flags"""
+ global _ignoreBlackList
for p in self.root.findall('flag'):
+ if not _ignoreBlackList and \
+ _blackList.has_key(self.task.name) and \
+ p.get('name') in _blackList[self.task.name]['flags']:
+ hidden = True
+ else:
+ hidden = False
+
if p.find('suppress_required') is not None:
suppress_required = True
else:
suppress_required = False
- self.task.flags.append({
+ self.task.flags.append( {
"name" : p.get('name'),
"label" : self._getNodeText(p, 'label'),
"description" : self._getNodeText(p, 'description'),
"guisection" : self._getNodeText(p, 'guisection'),
"suppress_required" : suppress_required,
- "value" : False })
-
+ "value" : False,
+ "hidden" : hidden
+ } )
+
def _getNodeText(self, node, tag, default = ''):
"""!Get node text"""
p = node.find(tag)
@@ -960,7 +986,7 @@
display.GetRender().GetListOfLayers(l_type = 'raster') +
display.GetRender().GetListOfLayers(l_type = 'vector'))
- task = GUI().ParseCommand(cmd, show = None)
+ task = GUI(show = None).ParseCommand(cmd)
for p in task.get_options()['params']:
if p.get('prompt', '') not in ('raster', 'vector'):
continue
@@ -1093,7 +1119,7 @@
# Determine tab layout
sections = []
is_section = {}
- not_hidden = [ p for p in self.task.params + self.task.flags if not p.get('hidden','no') == 'yes' ]
+ not_hidden = [ p for p in self.task.params + self.task.flags if not p.get('hidden', False) == True ]
self.label_id = [] # wrap titles on resize
@@ -1166,7 +1192,7 @@
# flags
#
text_style = wx.FONTWEIGHT_NORMAL
- visible_flags = [ f for f in self.task.flags if not f.get('hidden', 'no') == 'yes' ]
+ visible_flags = [ f for f in self.task.flags if not f.get('hidden', False) == True ]
for f in visible_flags:
which_sizer = tabsizer[ f['guisection'] ]
which_panel = tab[ f['guisection'] ]
@@ -1220,7 +1246,7 @@
#
# parameters
#
- visible_params = [ p for p in self.task.params if not p.get('hidden', 'no') == 'yes' ]
+ visible_params = [ p for p in self.task.params if not p.get('hidden', False) == True ]
try:
first_param = visible_params[0]
@@ -2176,17 +2202,25 @@
return True
class GUI:
- """
- Parses GRASS commands when module is imported and used
- from Layer Manager.
- """
- def __init__(self, parent = -1):
+ def __init__(self, parent = None, show = True, modal = False,
+ centreOnParent = False, checkError = False):
+ """!Parses GRASS commands when module is imported and used from
+ Layer Manager.
+ """
self.parent = parent
+ self.show = show
+ self.modal = modal
+ self.centreOnParent = centreOnParent
+ self.checkError = checkError
+
self.grass_task = None
self.cmd = list()
-
+
+ global _ignoreBlackList
+ _ignoreBlackList = False if self.parent else True
+
def GetCmd(self):
- """Get validated command"""
+ """!Get validated command"""
return self.cmd
def ParseInterface(self, cmd, parser = processTask):
@@ -2202,8 +2236,7 @@
return processTask(tree).GetTask()
- def ParseCommand(self, cmd, gmpath = None, completed = None, parentframe = None,
- show = True, modal = False, centreOnParent = False, checkError = False):
+ def ParseCommand(self, cmd, gmpath = None, completed = None):
"""!Parse command
Note: cmd is given as list
@@ -2224,8 +2257,6 @@
if completed[2]:
dcmd_params.update(completed[2])
- self.parent = parentframe
-
# parse the interface decription
self.grass_task = self.ParseInterface(cmd)
@@ -2283,7 +2314,7 @@
# update original command list
cmd = cmd_validated
- if show is not None:
+ if self.show is not None:
self.mf = mainFrame(parent = self.parent, ID = wx.ID_ANY,
task_description = self.grass_task,
get_dcmd = get_dcmd, layer = layer)
@@ -2295,21 +2326,21 @@
get_dcmd(dcmd = None, layer = layer, params = None,
propwin = self.mf)
- if show is not None:
+ if self.show is not None:
self.mf.notebookpanel.OnUpdateSelection(None)
- if show is True:
- if self.parent and centreOnParent:
+ if self.show is True:
+ if self.parent and self.centreOnParent:
self.mf.CentreOnParent()
else:
self.mf.CenterOnScreen()
- self.mf.Show(show)
- self.mf.MakeModal(modal)
+ self.mf.Show(self.show)
+ self.mf.MakeModal(self.modal)
else:
self.mf.OnApply(None)
self.cmd = cmd
- if checkError:
+ if self.checkError:
return self.grass_task, err
else:
return self.grass_task
@@ -2416,7 +2447,7 @@
},{
"name" : "hidden_text",
"description" : "This text should not appear in the form",
- "hidden" : "yes"
+ "hidden" : True
},{
"name" : "text_default",
"description" : "Enter text to override the default",
More information about the grass-commit
mailing list