Esempio n. 1
0
    def _update(self, name, workspace_func):

        if (not hasattr(self, '_dock_widget')
                or not self._dock_widget.isVisible()):
            return
        self._dock_widget.setWindowTitle(_(u'Workspace ({})').format(name))
        workspace = workspace_func()
        # If the workspace didn't reply, we try again in a second
        if workspace is None or workspace.get(u'no reply', False) is None:
            QTimer.singleShot(1000, lambda: self._update(name, workspace_func))
            return
        # If the current kernel doesn't expose its workspace, indicate this
        if workspace.get(u'not supported', False) is None:
            dm = DataMatrix(length=0)
            dm.kernel_not_supported = -1
        # Create a DataMatrix that exposes the workspace
        else:
            dm = DataMatrix(length=len(workspace))
            dm.sorted = False
            dm.name = ''
            dm.value = ''
            dm.shape = ''
            dm.type = ''
            for row, (var, data) in zip(dm, workspace.items()):
                if data is None:
                    oslogger.warning(u'invalid workspace data: {}'.format(var))
                    continue
                value, type_, shape = data
                row.value = value
                row.name = var
                if shape is not None:
                    row.shape = repr(shape)
                row.type = type_
        self._qdm.dm = dm
        self._qdm.refresh()
from datamatrix import DataMatrix
data = {
    'Mahendra suthar': (19, '1234567890', 'Dabok', 313022),
    'Pradeep suthar': (21, '8440077147', 'Udaipur', 307022),
    'Vishal suthar': (20, '0987654321', 'Pindwara', 303122)
}

dm = DataMatrix(length=len(data))
dm.name = data.key()
dm.age = data.value()
print(dm)