Source code for openalea.vpltk.control.controlpanel

from openalea.vpltk.qt import QtGui
from openalea.vpltk.control.abstractcontrolmanager import get_manager


[docs]class ControlPanel(QtGui.QTableWidget): def __init__(self, row=0, column=1): super(ControlPanel, self).__init__(row, column) headerName = QtGui.QTableWidgetItem("Control") self.setHorizontalHeaderItem(0,headerName)
[docs] def reset(self): self.clear() while self.rowCount() > 0: self.removeRow( 0 ) headerName = QtGui.QTableWidgetItem("Control") self.setHorizontalHeaderItem(0,headerName)
[docs] def add(self, ctrl): row = self.rowCount() self.insertRow(row) manager = get_manager(type(ctrl)) if manager is not None: self.setItem(row,0,manager.displayThumbnail()) else: self.setItem(row,0,QtGui.QTableWidgetItem(str(ctrl)))
[docs] def add_several(self, ctrls): for ctrl in ctrls: self.add(ctrl)
[docs] def set(self, ctrl): self.reset() self.add(ctrl)
[docs] def set_several(self, ctrls): self.reset() self.add_several(ctrls)
[docs] def new(self): pass # TODO
[docs] def write_all(self): ctrls = list() for row in self.row(): for column in self.colunm(): item = self.item(row, column) ctrl = item.writeObject() ctrls.append(ctrl) return ctrls