'Setup editor.'

def setup(self, data, title='', readonly=False, width=650, remote=False, icon=None, parent=None):

    if isinstance(data, dict):
        self.data_copy = data.copy()
        datalen = len(data)
    elif isinstance(data, (tuple, list)):
        self.data_copy = data[:]
        datalen = len(data)
    else:
        import copy
        self.data_copy = copy.deepcopy(data)
        datalen = len(get_object_attrs(data))
    self.widget = CollectionsEditorWidget(self, self.data_copy, title=title, readonly=readonly, remote=remote)
    layout = QVBoxLayout()
    layout.addWidget(self.widget)
    self.setLayout(layout)
    buttons = QDialogButtonBox.Ok
    if (not readonly):
        buttons = (buttons | QDialogButtonBox.Cancel)
    self.bbox = QDialogButtonBox(buttons)
    self.bbox.accepted.connect(self.accept)
    if (not readonly):
        self.bbox.rejected.connect(self.reject)
    layout.addWidget(self.bbox)
    constant = 121
    row_height = 30
    error_margin = 10
    height = ((constant + (row_height * min([10, datalen]))) + error_margin)
    self.resize(width, height)
    self.setWindowTitle(self.widget.get_title())
    if (icon is None):
        self.setWindowIcon(ima.icon('dictedit'))
    self.setWindowFlags(Qt.Window)
