Beispiel #1
0
class MainWindow(ApplicationWindow):
    """ The main application window. """

    data = List(Instance(Person))

    row_info = Instance(AbstractRowInfo)

    data_view = Instance(IDataViewWidget)

    def _create_contents(self, parent):
        """ Creates the left hand side or top depending on the style. """

        self.data_view = DataViewWidget(
            parent=parent,
            data_model=ColumnDataModel(
                data=self.data,
                row_info=self.row_info,
            ),
            selection_mode='extended',
            exporters=[
                RowExporter(
                    format=table_format,
                    column_headers=True,
                    row_headers=True,
                ),
                RowExporter(
                    format=csv_format,
                    column_headers=True,
                ),
            ]
        )
        self.data_view._create()
        return self.data_view.control

    def _data_default(self):
        logger.info("Initializing data")
        people = [
            Person(
                name='%s %s' % (any_name(), family_name()),
                age=age(),
                favorite_color=favorite_color(),
                address=Address(
                    street=street(),
                    city=city(),
                    country=country(),
                ),
            )
            for i in range(100)
        ]
        logger.info("Data initialized")
        return people

    def destroy(self):
        self.data_view.destroy()
        super().destroy()
Beispiel #2
0
class MainWindow(ApplicationWindow):
    """ The main application window. """

    data = Array()

    data_view = Instance(IDataViewWidget)

    def load_data(self, path):
        try:
            self.data = np.load(path)
        except Exception:
            logger.exception()

    def _create_contents(self, parent):
        """ Creates the left hand side or top depending on the style. """

        self.data_view = DataViewWidget(
            parent=parent,
            data_model=ArrayDataModel(
                data=self.data,
                value_type=FloatValue(),
            ),
            selection_mode='extended',
            exporters=[
                RowExporter(format=table_format),
                RowExporter(format=csv_format),
                RowExporter(format=npy_format),
            ],
            drop_handlers=[
                FileDropHandler(extensions=['.npy'], open_file=self.load_data),
            ],
        )
        self.data_view._create()
        return self.data_view.control

    def destroy(self):
        self.data_view.destroy()
        super().destroy()

    @observe('data')
    def _data_updated(self, event):
        if self.data_view is not None:
            self.data_view.data_model.data = self.data

    def _data_default(self):
        return np.random.uniform(size=(10000, 10, 10)) * 1000000
Beispiel #3
0
class MainWindow(ApplicationWindow):
    """ The main application window. """

    #: A collection of People.
    data = List(Instance(Person))

    #: The data view widget.
    data_view = Instance(IDataViewWidget)

    def _create_contents(self, parent):
        """ Creates the left hand side or top depending on the style. """

        self.data_view = DataViewWidget(
            parent=parent,
            data_model=RowTableDataModel(data=self.data,
                                         row_header_data=row_header_data,
                                         column_data=column_data),
        )
        self.data_view._create()
        return self.data_view.control

    def _data_default(self):
        logger.info("Initializing data")
        people = [
            Person(
                name='%s %s' % (any_name(), family_name()),
                age=age(),
                favorite_color=favorite_color(),
                address=Address(
                    street=street(),
                    city=city(),
                    country=country(),
                ),
            ) for i in range(10000)
        ]
        logger.info("Data initialized")
        return people

    def destroy(self):
        self.data_view.destroy()
        super().destroy()