[GRASS-SVN] r55845 - in grass/branches/develbranch_6: display/d.thematic.area gui/wxpython/gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 17 02:16:26 PDT 2013


Author: annakrat
Date: 2013-04-17 02:16:26 -0700 (Wed, 17 Apr 2013)
New Revision: 55845

Modified:
   grass/branches/develbranch_6/display/d.thematic.area/main.c
   grass/branches/develbranch_6/gui/wxpython/gui_core/forms.py
Log:
wxGUI/forms: merge fix for #1774 (multiple color)

Modified: grass/branches/develbranch_6/display/d.thematic.area/main.c
===================================================================
--- grass/branches/develbranch_6/display/d.thematic.area/main.c	2013-04-17 09:04:50 UTC (rev 55844)
+++ grass/branches/develbranch_6/display/d.thematic.area/main.c	2013-04-17 09:16:26 UTC (rev 55845)
@@ -122,8 +122,7 @@
     colors_opt->required = YES;
     colors_opt->multiple = YES;
     colors_opt->description = _("Colors (one per class).");
-    /* This won't work. We would need multiple color prompt.
-     * colors_opt->gisprompt = GISPROMPT_COLOR; */
+    colors_opt->gisprompt = GISPROMPT_COLOR;
 
     field_opt = G_define_standard_option(G_OPT_V_FIELD);
     field_opt->description =

Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/forms.py	2013-04-17 09:04:50 UTC (rev 55844)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/forms.py	2013-04-17 09:16:26 UTC (rev 55845)
@@ -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