[GRASS-SVN] r55170 - grass/branches/releasebranch_6_4/gui/wxpython/gui_core
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Feb 22 03:08:41 PST 2013
Author: annakrat
Date: 2013-02-22 03:08:41 -0800 (Fri, 22 Feb 2013)
New Revision: 55170
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/gui_core/forms.py
Log:
wxGUI: fix 1774 (merge from trunk, r55150)
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_core/forms.py 2013-02-22 11:06:52 UTC (rev 55169)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_core/forms.py 2013-02-22 11:08:41 UTC (rev 55170)
@@ -1249,21 +1249,36 @@
label_color = _("Select Color")
if p.get('default','') != '':
default_color, label_color = color_resolve(p['default'])
- if p.get('value','') != '': # parameter previously set
+ if p.get('value','') != '' and p.get('value','') != 'none': # parameter previously set
default_color, label_color = color_resolve(p['value'])
- if p.get('prompt', '') == 'color_none':
+ if p.get('prompt', '') == 'color_none' or p.get('multiple', False):
this_sizer = wx.BoxSizer(orient = wx.HORIZONTAL)
else:
this_sizer = which_sizer
+ colorSize = 150
+ # For color selectors, this is a three-member array, holding the IDs of
+ # the text control for multiple colors (or None),
+ # the selector proper and either a "transparent" checkbox or None
+ if p.get('multiple', False):
+ txt = wx.TextCtrl(parent = which_panel, id = wx.ID_ANY)
+ this_sizer.Add(item = txt, proportion = 1,
+ flag = wx.ADJUST_MINSIZE | wx.LEFT | wx.TOP, border = 5)
+ txt.Bind(wx.EVT_TEXT, self.OnSetValue)
+ colorSize = 40
+ label_color = ''
+ p['wxId'] = [txt.GetId(),]
+ which_sizer.Add(this_sizer, flag = wx.EXPAND | wx.RIGHT, border = 5)
+ else:
+ p['wxId'] = [None,]
+
btn_colour = csel.ColourSelect(parent = which_panel, id = wx.ID_ANY,
label = label_color, colour = default_color,
- pos = wx.DefaultPosition, size = (150,-1))
+ pos = wx.DefaultPosition, size = (colorSize,-1))
this_sizer.Add(item = btn_colour, proportion = 0,
flag = wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT, border = 5)
- # For color selectors, this is a two-member array, holding the IDs of
- # the selector proper and either a "transparent" button or None
- p['wxId'] = [btn_colour.GetId(),]
btn_colour.Bind(csel.EVT_COLOURSELECT, self.OnColorChange)
+ p['wxId'].append(btn_colour.GetId())
+
if p.get('prompt', '') == 'color_none':
none_check = wx.CheckBox(which_panel, wx.ID_ANY, _("Transparent"))
if p.get('value','') != '' and p.get('value',[''])[0] == "none":
@@ -1613,11 +1628,25 @@
myId = event.GetId()
for p in self.task.params:
if 'wxId' in p and myId in p['wxId']:
- has_button = p['wxId'][1] is not None
- if has_button and wx.FindWindowById(p['wxId'][1]).GetValue() == True:
+ multiple = p['wxId'][0] is not None # multiple colors
+ hasTransp = p['wxId'][2] is not None
+ if multiple:
+ # selected color is added at the end of textCtrl
+ colorchooser = wx.FindWindowById(p['wxId'][1])
+ new_color = colorchooser.GetValue()[:]
+ new_label = rgb2str.get(new_color, ':'.join(map(str, new_color)))
+ textCtrl = wx.FindWindowById(p['wxId'][0])
+ val = textCtrl.GetValue()
+ sep = ','
+ if val and val[-1] != sep:
+ val += sep
+ val += new_label
+ textCtrl.SetValue(val)
+ p[ 'value' ] = val
+ elif hasTransp and wx.FindWindowById(p['wxId'][2]).GetValue():
p[ 'value' ] = 'none'
else:
- colorchooser = wx.FindWindowById(p['wxId'][0])
+ colorchooser = wx.FindWindowById(p['wxId'][1])
new_color = colorchooser.GetValue()[:]
# This is weird: new_color is a 4-tuple and new_color[:] is a 3-tuple
# under wx2.8.1
More information about the grass-commit
mailing list