Generally, we use addWidget() instead of setWidget for panels that can contain multiple children.
However, instead of an error, maybe setWidget() should delete all it's (existing) children and do an addWidget. This would kind of mimic the behaviour of setWidget() as used on single-child containers...just a thought. Rich On Mon, Mar 5, 2012 at 10:39 AM, Janjaap Bos <[email protected]> wrote: > Hi, > > setWidget raises an error when used on VerticalPanel. > > Due to differences with Panel / ComplexPanel on which it is based, > regarding the insert() method. > > setWidget is defined in Panel, but assumes an insert method with 4 > parameters: > > def setWidget(self, index, widget): > """ Insert (or optionally replace) the widget at the given index > with a new one > """ > existing = self.getWidget(index) > if existing is not None: > self.remove(existing) > self.insert(widget, self.getElement(), index) > > > ComplexPanel defines insert with 4 parameters: > > def insert(self, widget, container, beforeIndex): > if widget.getParent() == self: > return > > self.adopt(widget, container) > self.children.insert(beforeIndex, widget) > > > In VerticalPanel insert is defined with 3 parameters: > > def insert(self, widget, beforeIndex): > widget.removeFromParent() > > tr = DOM.createTR() > td = DOM.createTD() > > DOM.insertChild(self.getBody(), tr, beforeIndex) > DOM.appendChild(tr, td) > > CellPanel.insert(self, widget, td, beforeIndex) > > self.setCellHorizontalAlignment(widget, self.horzAlign) > self.setCellVerticalAlignment(widget, self.vertAlign) > > > Now, if I want to use setWidget on VerticalPanel, should I redefine > setWidget in VerticalPanel, to use the proper insert for VerticalPanel? > > Or, should setWidget not be used on VerticalPanel at all? > > > Regards, > > -Janjaap > >

