def NewGroup(self, group=None, layout=False): if group is None: while "%s %s" % (self.L["GROUP_NEW"], self.newGroupIndex) in self.Groups: self.newGroupIndex += 1 group = "%s %s" % (self.L["GROUP_NEW"], self.newGroupIndex) else: if group in self.Groups: return group panel = UI.BaseControl(self.Inner) title = GroupTitle(self.Inner, group) groupSizer = wx.WrapSizer() btnAdd = UI.Button(panel, size=wx.Size(36, 36), pic=self.R["MANAGE_ADD"], func=None, edge=None, res="L") groupSizer.Add(btnAdd, SF_ITEM) btnDel = UI.Button(panel, size=wx.Size(36, 36), pic=self.R["MANAGE_DEL"], func=(self.DelGroup, title), edge=None, res="L") groupSizer.Add(btnDel, SF_ITEM) panel.SetSizer(groupSizer) self.Inner.GetSizer().AddMany(((title, SF_TITLE), (panel, SF_PANEL))) self.Groups[group] = { "TITLE": title, "PANEL": panel, "ADD": btnAdd, "DEL": btnDel } if self["NEW"]: self.Inner.GetSizer().Detach(self["NEW"]) self.Inner.GetSizer().Add(self["NEW"], SF_NEW) if layout: self.OnArrangement() return group
def AddItems(self, args): self.Freeze() group = self.NewGroup(self.L["GROUP_NONE"]) for arg in args: if isinstance(arg, str): group = self.NewGroup(arg or self.L["GROUP_NONE"]) else: self.AddItem( WidgetItem(self.Groups[group]["PANEL"], item=arg, group=group)) if self["NEW"] is None: self["NEW"] = UI.Button(self.Inner, size=wx.Size(-1, 64), tag=self.L["MANAGE_NEW_GROUP"], func=(self.NewGroup, None, True), res="L", edge="D") self.Inner.GetSizer().Add(self["NEW"], SF_NEW) self.Inner.Layout() self.OnSize() self.Thaw()