[GRASS-SVN] r58540 - in grass/trunk/gui/wxpython: gmodeler gui_core
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Dec 28 05:04:03 PST 2013
Author: martinl
Date: 2013-12-28 05:04:03 -0800 (Sat, 28 Dec 2013)
New Revision: 58540
Modified:
grass/trunk/gui/wxpython/gmodeler/dialogs.py
grass/trunk/gui/wxpython/gmodeler/frame.py
grass/trunk/gui/wxpython/gui_core/prompt.py
Log:
wxGUI/modeler: set label and comment when adding new command to the model
Modified: grass/trunk/gui/wxpython/gmodeler/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/dialogs.py 2013-12-27 16:53:51 UTC (rev 58539)
+++ grass/trunk/gui/wxpython/gmodeler/dialogs.py 2013-12-28 13:04:03 UTC (rev 58540)
@@ -15,7 +15,7 @@
- dialogs::ItemListCtrl
- dialogs::ItemCheckListCtrl
-(C) 2010-2011 by the GRASS Development Team
+(C) 2010-2013 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
@@ -138,7 +138,7 @@
self.Destroy()
class ModelSearchDialog(wx.Dialog):
- def __init__(self, parent, title = _("Add new GRASS module to the model"),
+ def __init__(self, parent, title = _("Add GRASS command to the model"),
style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
"""!Graphical modeler module search window
@@ -158,12 +158,15 @@
self.cmdBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
label=" %s " % _("Command"))
+ self.labelBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
+ label=" %s " % _("Label and comment"))
# menu data for search widget and prompt
menuModel = LayerManagerMenuData()
self.cmd_prompt = GPromptSTC(parent = self, menuModel = menuModel.GetModel(), updateCmdHistory = False)
self.cmd_prompt.promptRunCmd.connect(self.OnCommand)
+ self.cmd_prompt.commandSelected.connect(lambda command: self.label.SetValue(command))
self.search = SearchModuleWidget(parent = self.panel,
model = menuModel.GetModel(),
showTip = True)
@@ -171,6 +174,9 @@
self.cmd_prompt.SetTextAndFocus(name + ' '))
wx.CallAfter(self.cmd_prompt.SetFocus)
+ self.label = wx.TextCtrl(parent = self.panel, id = wx.ID_ANY)
+ self.comment = wx.TextCtrl(parent = self.panel, id = wx.ID_ANY, style = wx.TE_MULTILINE)
+
self.btnCancel = wx.Button(self.panel, wx.ID_CANCEL)
self.btnOk = wx.Button(self.panel, wx.ID_OK)
self.btnOk.SetDefault()
@@ -180,12 +186,24 @@
self._layout()
- self.SetSize((500, 275))
+ self.SetSize((500, -1))
def _layout(self):
cmdSizer = wx.StaticBoxSizer(self.cmdBox, wx.VERTICAL)
cmdSizer.Add(item = self.cmd_prompt, proportion = 1,
flag = wx.EXPAND)
+ labelSizer = wx.StaticBoxSizer(self.labelBox, wx.VERTICAL)
+ gridSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
+ gridSizer.AddGrowableCol(1)
+ gridSizer.Add(item = wx.StaticText(parent = self.panel, id = wx.ID_ANY,
+ label = _("Label:")),
+ flag = wx.ALIGN_CENTER_VERTICAL, pos = (0, 0))
+ gridSizer.Add(item = self.label, pos = (0, 1), flag = wx.EXPAND)
+ gridSizer.Add(item = wx.StaticText(parent = self.panel, id = wx.ID_ANY,
+ label = _("Comment:")),
+ flag = wx.ALIGN_CENTER_VERTICAL, pos = (1, 0))
+ gridSizer.Add(item = self.comment, pos = (1, 1), flag = wx.EXPAND)
+ labelSizer.Add(item = gridSizer, proportion = 1, flag = wx.EXPAND)
btnSizer = wx.StdDialogButtonSizer()
btnSizer.AddButton(self.btnCancel)
@@ -197,11 +215,13 @@
flag = wx.EXPAND | wx.ALL, border = 3)
mainSizer.Add(item = cmdSizer, proportion = 1,
flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border = 3)
+ mainSizer.Add(item = labelSizer, proportion = 1,
+ flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border = 3)
mainSizer.Add(item = btnSizer, proportion = 0,
flag = wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border = 5)
self.panel.SetSizer(mainSizer)
- mainSizer.Fit(self.panel)
+ mainSizer.Fit(self)
self.Layout()
@@ -224,6 +244,10 @@
"""!Get command"""
return self._command
+ def GetLabel(self):
+ """!Get label and comment"""
+ return self.label.GetValue(), self.comment.GetValue()
+
def ValidateCmd(self, cmd):
if len(cmd) < 1:
GError(parent = self,
Modified: grass/trunk/gui/wxpython/gmodeler/frame.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/frame.py 2013-12-27 16:53:51 UTC (rev 58539)
+++ grass/trunk/gui/wxpython/gmodeler/frame.py 2013-12-28 13:04:03 UTC (rev 58540)
@@ -650,10 +650,11 @@
# add action to canvas
x, y = self.canvas.GetNewShapePos()
+ label, comment = self.searchDialog.GetLabel()
action = ModelAction(self.model, cmd = cmd,
x = x + self._randomShift(),
y = y + self._randomShift(),
- id = self.model.GetNextId())
+ id = self.model.GetNextId(), label = label, comment = comment)
overwrite = self.model.GetProperties().get('overwrite', None)
if overwrite is not None:
action.GetTask().set_flag('overwrite', overwrite)
Modified: grass/trunk/gui/wxpython/gui_core/prompt.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/prompt.py 2013-12-27 16:53:51 UTC (rev 58539)
+++ grass/trunk/gui/wxpython/gui_core/prompt.py 2013-12-28 13:04:03 UTC (rev 58540)
@@ -183,6 +183,9 @@
# signal which requests showing of a notification
self.showNotification = Signal('GPromptSTC.showNotification')
+ # signal to notify selected command
+ self.commandSelected = Signal('GPromptSTC.commandSelected')
+
def OnTextSelectionChanged(self, event):
"""!Copy selected text to clipboard and skip event.
The same function is in GStc class (goutput.py).
@@ -200,6 +203,7 @@
nodes = self._menuModel.SearchNodes(key='command', value=item)
desc = ''
if nodes:
+ self.commandSelected.emit(command=item)
desc = nodes[0].data['description']
except KeyError:
desc = ''
@@ -269,6 +273,7 @@
def SetTextAndFocus(self, text):
pos = len(text)
+ self.commandSelected.emit(command=text)
self.SetText(text)
self.SetSelectionStart(pos)
self.SetCurrentPos(pos)
More information about the grass-commit
mailing list