def __init__(self, name, parent=None): super(QuickViewNode, self).__init__(name, terminals={'In': { 'io': 'in' }}) self.graphicsItem().setBrush(fn.mkBrush(150, 150, 250, 200)) self._pandasDataModel = PandasDataModel(parent=self) self._pandasHeaderModel = PandasHeaderModel(parent=self) self._ctrlWidget = QuickViewCtrlWidget(self) # connect show/hide signals self._pandasHeaderModel.row_hidden.connect( self._ctrlWidget.tableView.horizontalHeader( ).hideSection) #argumnent [int] self._pandasHeaderModel.row_showed.connect( self._ctrlWidget.tableView.horizontalHeader( ).showSection) #argumnent [int] self._pandasDataModel.modelReset.connect( self._ctrlWidget.update) #no argument self._id = None
def __init__(self, name, parent=None): super(QuickViewNode, self).__init__(name, terminals={'In': {'io': 'in'}}) self.graphicsItem().setBrush(fn.mkBrush(150, 150, 250, 200)) self._pandasDataModel = PandasDataModel(parent=self) self._pandasHeaderModel = PandasHeaderModel(parent=self) self._ctrlWidget = QuickViewCtrlWidget(self) # connect show/hide signals self._pandasHeaderModel.row_hidden.connect(self._ctrlWidget.tableView.horizontalHeader().hideSection) #argumnent [int] self._pandasHeaderModel.row_showed.connect(self._ctrlWidget.tableView.horizontalHeader().showSection) #argumnent [int] self._pandasDataModel.modelReset.connect(self._ctrlWidget.update) #no argument self._id = None
class QuickViewNode(Node): """View dataframe in TableView/Matplotlib-plot""" nodeName = "Quick View" def __init__(self, name, parent=None): super(QuickViewNode, self).__init__(name, terminals={'In': { 'io': 'in' }}) self.graphicsItem().setBrush(fn.mkBrush(150, 150, 250, 200)) self._pandasDataModel = PandasDataModel(parent=self) self._pandasHeaderModel = PandasHeaderModel(parent=self) self._ctrlWidget = QuickViewCtrlWidget(self) # connect show/hide signals self._pandasHeaderModel.row_hidden.connect( self._ctrlWidget.tableView.horizontalHeader( ).hideSection) #argumnent [int] self._pandasHeaderModel.row_showed.connect( self._ctrlWidget.tableView.horizontalHeader( ).showSection) #argumnent [int] self._pandasDataModel.modelReset.connect( self._ctrlWidget.update) #no argument self._id = None def process(self, In): ''' Take the dataframe from the terminal `In` and process it ''' if id(In) != self._id and self._pandasDataModel is not None: logger.debug('clearing QuickView on_process()') self.clearModels() if In is not None: if isinstance(In, pd.Series): In = In.to_frame(name='SERIES') self._pandasDataModel.setPandasDataframe(In) self._pandasHeaderModel.setPandasDataframe(In) self._id = id(In) self.ctrlWidget().update() def getPandasDataModel(self): return self._pandasDataModel def getPandasHeaderModel(self): return self._pandasHeaderModel def ctrlWidget(self): return self._ctrlWidget def saveState(self): """overwriting stadart Node method to extend it with saving ctrlWidget state""" state = Node.saveState(self) # sacing additionaly state of the control widget #state['crtlWidget'] = self.ctrlWidget().saveState() return state def restoreState(self, state): """overwriting stadart Node method to extend it with restoring ctrlWidget state""" Node.restoreState(self, state) # additionally restore state of the control widget #self.ctrlWidget().restoreState(state['crtlWidget']) def clearModels(self): self._id = None self._pandasDataModel.clear() self._pandasHeaderModel.destroy()
class QuickViewNode(Node): """View dataframe in TableView/Matplotlib-plot""" nodeName = "Quick View" def __init__(self, name, parent=None): super(QuickViewNode, self).__init__(name, terminals={'In': {'io': 'in'}}) self.graphicsItem().setBrush(fn.mkBrush(150, 150, 250, 200)) self._pandasDataModel = PandasDataModel(parent=self) self._pandasHeaderModel = PandasHeaderModel(parent=self) self._ctrlWidget = QuickViewCtrlWidget(self) # connect show/hide signals self._pandasHeaderModel.row_hidden.connect(self._ctrlWidget.tableView.horizontalHeader().hideSection) #argumnent [int] self._pandasHeaderModel.row_showed.connect(self._ctrlWidget.tableView.horizontalHeader().showSection) #argumnent [int] self._pandasDataModel.modelReset.connect(self._ctrlWidget.update) #no argument self._id = None def process(self, In): ''' Take the dataframe from the terminal `In` and process it ''' if id(In) != self._id and self._pandasDataModel is not None: logger.debug('clearing QuickView on_process()') self.clearModels() if In is not None: if isinstance(In, pd.Series): In = In.to_frame(name='SERIES') self._pandasDataModel.setPandasDataframe(In) self._pandasHeaderModel.setPandasDataframe(In) self._id = id(In) self.ctrlWidget().update() def getPandasDataModel(self): return self._pandasDataModel def getPandasHeaderModel(self): return self._pandasHeaderModel def ctrlWidget(self): return self._ctrlWidget def saveState(self): """overwriting stadart Node method to extend it with saving ctrlWidget state""" state = Node.saveState(self) # sacing additionaly state of the control widget #state['crtlWidget'] = self.ctrlWidget().saveState() return state def restoreState(self, state): """overwriting stadart Node method to extend it with restoring ctrlWidget state""" Node.restoreState(self, state) # additionally restore state of the control widget #self.ctrlWidget().restoreState(state['crtlWidget']) def clearModels(self): self._id = None self._pandasDataModel.clear() self._pandasHeaderModel.destroy()