Пример #1
0
    def __init__(self,
                 cls=None,
                 searchColumns=None,
                 editorClass=None,
                 filename=None,
                 store=None,
                 **kwargs):
        from fvl.cimarron.skin import Notebook, VBox, Button

        self.editors = []
        super(CRUDController, self).__init__(**kwargs)
        self.note = Notebook(parent=self.window)
        # why this fails so miserably?
        # self._innerWidget = self.note._innerWidget
        if not '_concreteWidget' in self.__dict__:
            self._concreteWidget = self.window

        # first tab
        self.firstTab = VBox(label='Search')
        self.firstTab.parent = self.note

        self.new = Button(parent=self.firstTab, label='New', expand=False)
        self.cls = cls
        if searchColumns is not None:
            # add the Search thing
            self.search = Search(parent=self.firstTab,
                                 columns=searchColumns,
                                 onAction=self.changeModel)

        if store is not None:
            self.store = store

        # second tab
        if editorClass is not None:
            if filename is not None:
                modelEditor = editorClass.fromXmlFile(filename)
            else:
                # let's hope the editorClass knows what to do
                modelEditor = editorClass()
            modelEditor.parent = self.note
            self.editors.append(modelEditor)
            self.mainWidget = modelEditor