class NewServerTreeView(): def __init__(self, schid, parent=None): self.lay = QHBoxLayout(parent) self.tree = DragDropServerview(schid, parent) self.lay.addWidget(self.tree) self.lay.setContentsMargins(0,0,0,0) parent.setLayout(self.lay) self.tree.connect("clicked(QModelIndex)", self.tree.onItemClicked) self.tree.connect("customContextMenuRequested(QPoint)", self.tree.onContextMenu) self.searchFrame = [item for item in QApplication.instance().allWidgets() if type(item).__name__ == "SearchFrame"][0] self.searchFrame.connect("find(QString,QTextDocument::FindFlags,bool,bool,bool&)", self.tree.onSearch) def close(self): self.lay.removeWidget(self.tree) self.lay.deleteLater() self.tree.setParent(None) #no parent-> child of python -> gets garbage collected when out of scope #maybe use deleteLater def select(self, firstid, firsttype, secid, sectype, action): self.tree.select(firstid, firsttype, secid, sectype, action) def show(self): self.tree.show() def raise_(self): self.tree.raise_() def toggle(self): if self.tree.isHidden(): self.show() else: self.hide() def show(self): self.tree.show() self.tree.raise_() def hide(self): self.tree.hide()