[GRASS-SVN] r45552 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 4 12:01:13 EST 2011
Author: martinl
Date: 2011-03-04 09:01:13 -0800 (Fri, 04 Mar 2011)
New Revision: 45552
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/gcpmanager.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/histogram.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI: define blackList for module flags/params (e.g. d.legend -m)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gcpmanager.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gcpmanager.py 2011-03-04 16:13:43 UTC (rev 45551)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gcpmanager.py 2011-03-04 17:01:13 UTC (rev 45552)
@@ -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/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2011-03-04 16:13:43 UTC (rev 45551)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2011-03-04 17:01:13 UTC (rev 45552)
@@ -465,9 +465,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()
@@ -504,9 +504,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()
@@ -1242,9 +1242,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):
@@ -1330,9 +1329,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/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py 2011-03-04 16:13:43 UTC (rev 45551)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py 2011-03-04 17:01:13 UTC (rev 45552)
@@ -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):
@@ -1206,9 +1205,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()
@@ -1673,8 +1671,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
@@ -1950,8 +1947,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())
@@ -2139,9 +2135,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)
@@ -2726,8 +2721,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))
@@ -4482,8 +4476,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/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2011-03-04 16:13:43 UTC (rev 45551)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2011-03-04 17:01:13 UTC (rev 45552)
@@ -125,7 +125,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']
@@ -526,7 +526,7 @@
if task and command[0] not in ('v.krige.py'):
# 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,
@@ -554,7 +554,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,
@@ -756,7 +756,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/branches/develbranch_6/gui/wxpython/gui_modules/histogram.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/histogram.py 2011-03-04 16:13:43 UTC (rev 45551)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/histogram.py 2011-03-04 17:01:13 UTC (rev 45552)
@@ -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/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py 2011-03-04 16:13:43 UTC (rev 45551)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py 2011-03-04 17:01:13 UTC (rev 45552)
@@ -498,9 +498,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)
+ menuform.GUI(parent = self).ParseCommand(['r.colors',
+ 'map=%s' % name])
def OnHistogram(self, event):
"""
@@ -908,10 +907,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':
@@ -920,58 +918,69 @@
if UserSettings.Get(group='cmd', key='rasterOverlay', subkey='enabled'):
cmd.append('-o')
- 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.vect.thematic', '-s'],
- completed = (self.GetOptData,layer,params),
- parentframe = self, centreOnParent = False)
+ menuform.GUI(parent = self, centreOnParent = False).ParseCommand(['d.vect.thematic', '-s'],
+ 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/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py 2011-03-04 16:13:43 UTC (rev 45551)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py 2011-03-04 17:01:13 UTC (rev 45552)
@@ -13,24 +13,19 @@
- GUI
- FloatValidator
- Copyright (C) 2000-2010 by the GRASS Development Team
+This program is just a coarse approach to automatically build a GUI
+from a xml-based GRASS user interface description.
- This program is free software under the GPL (>=v2) Read the file
- COPYING coming with GRASS for details.
+You need to have Python 2.4, wxPython 2.8 and python-xml.
- This program is just a coarse approach to automatically build a GUI
- from a xml-based GRASS user interface description.
+The XML stream is read from executing the command given in the
+command line, thus you may call it for instance this way:
- You need to have Python 2.4, wxPython 2.8 and python-xml.
+python <this file.py> r.basins.fill
- The XML stream is read from executing the command given in the
- command line, thus you may call it for instance this way:
+Or you set an alias or wrap the call up in a nice shell script, GUI
+environment ... please contribute your idea.
- 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.
-
Copyright(C) 2000-2011 by the GRASS Development Team
This program is free software under the GPL(>=v2) Read the file
COPYING coming with GRASS for details.
@@ -135,6 +130,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(':')))
@@ -594,8 +596,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,
@@ -611,17 +620,29 @@
"values" : values,
"values_desc" : values_desc,
"value" : '',
- "key_desc" : key_desc })
+ "key_desc" : key_desc,
+ "hidden" : hidden
+ })
def __processFlags(self):
"""!Process flags description"""
+ global _ignoreBlackList
for p in self.root.findall('flag'):
- self.task.flags.append({
+ 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
+
+ self.task.flags.append( {
"name" : p.get('name'),
"label" : self._getNodeText(p, 'label'),
"description" : self._getNodeText(p, 'description'),
"guisection" : self._getNodeText(p, 'guisection'),
- "value" : False })
+ "value" : False,
+ "hidden" : hidden
+ } )
def _getNodeText(self, node, tag, default = ''):
"""!Get node text"""
@@ -905,7 +926,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
@@ -1036,7 +1057,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
@@ -1109,7 +1130,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'] ]
@@ -1163,7 +1184,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]
@@ -1996,17 +2017,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):
@@ -2022,8 +2051,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
@@ -2043,8 +2071,6 @@
layer = completed[1]
if completed[2]:
dcmd_params.update(completed[2])
-
- self.parent = parentframe
# parse the interface decription
self.grass_task = self.ParseInterface(cmd)
@@ -2101,7 +2127,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)
@@ -2113,21 +2139,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
@@ -2234,7 +2260,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