widget for list of dicts

Sorry, yes, if you weren’t inside my head that might not have been
totally clear :wink:

Here's the filters dialog in Thunderbird (or attached hopefully if

not in-line):

 ![jbgfggeg.png|603x116](upload://spyrfgLb8SHHw5NscgrjMIBJEJg.png)

That widget would make sense in python as::

    [ {'source':'From', 'operation':'contains',

‘value’:‘psych…’},

        {'source':'Body', 'operation':'contains',

‘value’:‘pyglet…’},

        ...

    ]

hence my reference to a list of dicts.

It's easy enough for me to do with regular wx widgets and build my

own class to handle it, but the key thing is the ability to
insert/remove rows at any point in the list. I haven’t worked out a
straight-forward way to do that in any of the wx sizer objects.
Maybe I just need to remove all rows below the inserted and add them
all back afterwards.

cheers,

Jon

This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

Sorry, as half-expected the image got scraped:
http://i52.tinypic.com/k4v3gp.jpg

Jon

Sorry, yes, if you weren't inside my head that might not have been

totally clear :wink:

Here's the filters dialog in Thunderbird (or attached hopefully if

not in-line):

Reading your message on the wxPython email list with Gmail, the inline image appears just fine.

That widget would make sense in python as::

    [ {'source':'From', 'operation':'contains',

‘value’:‘psych…’},

        {'source':'Body', 'operation':'contains',

‘value’:‘pyglet…’},

        ...

    ]

hence my reference to a list of dicts.

I see. I would suggest that, when communicating about widgets, you think in terms of the user’s perspective, more than the developers. You, as the developer, see this as a list of dicts. But the user would only see it as a list of “limiters” or “conditions choosers”. Now that I am seeing it that way, too (after seeing the image), the whole thing makes more sense to me.

What do the + and - buttons do? I can understand that - means to remove this row, but +?

Do you want to essentially reproduce exactly what you’ve shown in this image, or is there some difference in the widget you want?

It's easy enough for me to do with regular wx widgets and build my

own class to handle it, but the key thing is the ability to
insert/remove rows at any point in the list. I haven’t worked out a
straight-forward way to do that in any of the wx sizer objects.
Maybe I just need to remove all rows below the inserted and add them
all back afterwards.

Hmm, I don’t understand what the problem is: If you have a set of “row items”, why can’t you just Destroy() that
widget and call .Layout() on the parent panel? The sizer should automatically re-layout. It’s all done for you. (Same thing with Inserting() into the sizer, as long as you always call Layout() ).

Che

···

On Mon, Oct 10, 2011 at 1:29 PM, Jonathan Peirce jonathan.peirce@nottingham.ac.uk wrote:

Reading your message on the wxPython email list with Gmail, the inline
image appears just fine.

ah, ok, on the web forum it was removed

I see. I would suggest that, when communicating about widgets, you think in
terms of the *user's* perspective, more than the developers. You, as the
developer, see this as a list of dicts. But the user would only see it as a
list of "limiters" or "conditions choosers".

Sorry, I figured everyone on a wxpython list was a developer to some
degree. :-/
The controls are being used by thunderbird like a 'conditions
chooser', but the more general case that I'm considering wouldn't be
limited to that. The meaning of each dict isn't important, but for
instance, one of the uses I have in mind is a list of dicts where each
one will change

What do the + and - buttons do? I can understand that - means to remove
this row, but +?

It inserts a new row/condition/dict at that point in the sequence

Do you want to essentially reproduce exactly what you've shown in this
image, or is there some difference in the widget you want?

My app has a number of locations where it could use variants of this.
I need to create the general case.

> It's easy enough for me to do with regular wx widgets and build my own
> class to handle it, but the key thing is the ability to insert/remove rows
> at any point in the list. I haven't worked out a straight-forward way to do
> that in any of the wx sizer objects. Maybe I just need to remove all rows
> below the inserted and add them all back afterwards.

Hmm, I don't understand what the problem is: If you have a set of "row
items", why can't you just Destroy() that widget and call .Layout() on the
parent panel? The sizer should automatically re-layout. It's all done for
you. (Same thing with Inserting() into the sizer, as long as you always
call Layout() ).

The problem I'm having is that I need a grid sizer of some sort
(FlexGridSizer or GridBagSizer) in order to keep the columns aligned
correctly. And those don't appear to have Insert() methods. And I
think that doing Destroy() followed by Layout() won't work either for
these sizers - they will render an empty row rather than remove it.

Well, I guess the solution would work for a BoxSizer though, so maybe
I need to go that route and just force everything to have a fixed
width to make them align. Sigh.

cheers,
Jon

You can insert items in the middle of a FlexGridSizer with its Insert() methods and existing items will shift down, and in a GridBagSizer you can move existing items to new positions (to make room for new items in the middle) with SetItemPosition.

···

On 10/11/11 10:01 AM, Jon wrote:

The problem I'm having is that I need a grid sizer of some sort
(FlexGridSizer or GridBagSizer) in order to keep the columns aligned
correctly. And those don't appear to have Insert() methods.

--
Robin Dunn
Software Craftsman

Hi,

The problem I'm having is that I need a grid sizer of some sort
(FlexGridSizer or GridBagSizer) in order to keep the columns aligned
correctly. And those don't appear to have Insert() methods. And I
think that doing Destroy() followed by Layout() won't work either for
these sizers - they will render an empty row rather than remove it.

Well, I guess the solution would work for a BoxSizer though, so maybe
I need to go that route and just force everything to have a fixed
width to make them align. Sigh.

Based on the screenshot I would suggest the following:

1) Create 1 composite widget class that represents a single row
(Choice controls, TextCtrl, and buttons all on a single Panel).

ConditionRow(Panel)
   +- Choice
   +- Choice
   +- TextCtrl
   +- Button
   +- Button

2) Create one more class to act as the container / manager for the
above control that just manages adding / removing the rows from its
layout (i.e a Vertical BoxSizer).

ConditionList(Panel)
   +- ConditionRow
   +- ConditionRow
   ...

Cody

···

On Tue, Oct 11, 2011 at 12:01 PM, Jon <jon.peirce@gmail.com> wrote:

I see. I would suggest that, when communicating about widgets, you think in
terms of the user’s perspective, more than the developers. You, as the

developer, see this as a list of dicts. But the user would only see it as a

list of “limiters” or “conditions choosers”.

Sorry, I figured everyone on a wxpython list was a developer to some

degree. :-/

I would say that appears to be the case. Still, (at least in my case), when I develop a GUI, I think in terms of user interaction first (it is after all a user interface) and data representation in Python second. The point is, you can have a dict, a list, a tuple, a table, a field, whatever, and they could all be represented as some sort of row in a list-like control–it doesn’t tell me anything about what widgets you will need. Whereas if you specify a conditions chooser (and, better, show the image you did), now I know you will need some wxChoice widgets and buttons. Had I been more familiar with the Thunderbird limits GUI I would have gotten this immediately.

The problem I’m having is that I need a grid sizer of some sort

(FlexGridSizer or GridBagSizer) in order to keep the columns aligned

correctly. And those don’t appear to have Insert() methods.

I would have suggested exactly what Cody did. The “row” can be built with a FlexGridSizer. The overall container can be just a vertical box sizer.

Che