From: Alex T. <al...@tw...> - 2004-09-19 01:37:13
|
I was reviewing old email (aka "tidying up") and realized I hadn't sent my reply to this - so apologies for replying kind o flate. At 00:28 24/08/2004 -0700, Kevin Altis wrote: >On Aug 23, 2004, at 11:58 PM, jamesr wrote: > >>The multiple layout windows i briefly read about above may be overkill >>- but a widget that 'encapsulates' other widgets could be handy in >>this case. A vaguish suggestion - a 'Group' Widget that takes as it >>items a list of other widget names. Setting an attribute of this >>widget changes the attributes (if they have it) of all listed widgets >>connected to it Immediately, I would use this to change the >>visibility of groups of widgets with one call, but an ability to add >>or subtract (relatively) from the position x and y from a group of >>objects would be very handy too, as well as font or color. Anyone else >>think of a use for this? > >If you want to do something like this today I suggest making a list of the >component names that you can then do an operation on. For example... > >group = ['btnOne', 'btnTwo', 'fldOne', 'someList'] >for c in group: > self.components[c].visible = False > >...could be used to make all the components in the "group" hidden. Rather >than string names you could just as easily use the actual component >references, it just depends on what you prefer. If you want to make this >more generic then use setattr within a function that takes the group list, >attribute name, and value as parameters. > >def groupChange(self, group, attribute, value): > for name in group: > setattr(self.components[name], attribute, value) > >attribute is a string like 'visible'. The advantage of James's suggestion is that it is a resourceEditor change, rather than a code editor change, to add or subtract items from the "group". So I'll suggest using an invisible component (say a StaticBox - which could more or less surround the relevant components) and store the list of component names in its "userdata". The change to the code suggested are obvious, but his moves it out to something you change in the resource Editor. -- Alex. |