On Fri, 2006-05-05 at 15:14 +0000, Michele Cella wrote:
> Robin Haswell wrote:
> > Hey there
> >
> > Would it be possible to get <optgroup> functionality in
> > SingleSelectField before 1.0? I believe it's missing at the moment
> > because searching the source tree returns essentially nothing.
> >
> 
> How would you like this to work ideally?
> I mean what's the most intuitive way of marking an option group when
> passing options from an user POV?
> 
> I can see two ways:
> 
> actual way without optgroup:
> 
> options=[(1, "Python"), (2, "Java")]
> 
> solution 1)
> 
> options=["Dynamic Languages", (1, "Python"), (2, "Java"), "Others",
> (3,
> "Java"), (4, "C++")]
> 
> solution 2) more correct semantically and probably easier to handle
> since I can check for the presence of a dict for backward
> compatibility.
> 
> options={'Dynamic Languages': (1, "Python"), (2, "Java")
>                 'Others':  (3, "Java"), (4, "C++")}
> 
> I vote for option 2). 

The option groups sound like a good idea.  The dict implementation seems
easy to use, but unfortunately you lose all control over the ordering of
the groups and can't have options without a group.  If you wanted to
keep the options more structured you could use a hybrid solution:

options=[(None, 'Please choose an option'),
         {'Dynamic Languages':
          [(1, "Python"),
           (2, "Ruby")]},
         {'Others':
          [(3, "Java"),
           (4, "C++")]}]

If you wanted to also allow multi-keyed dicts of option groups sorting
by the key would keep them from appearing in totally random order.

-- 
Matt Good <[EMAIL PROTECTED]>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to