def setData(self, data):
     self.data = data
     self.closeContext("")
     self.information(0)
     self.error(0)
     if data is not None:
         self.imageAttrCB.clear()
         self.titleAttrCB.clear()
         self.allAttrs = data.domain.variables + data.domain.getmetas().values()
         self.stringAttrs = [attr for attr in self.allAttrs if attr.varType == orange.VarTypes.String]
         self.hasTypeImageHint = any("type" in attr.attributes for attr in self.stringAttrs)
         self.stringAttrs = sorted(self.stringAttrs, key=lambda  attr: 0 if "type" in attr.attributes else 1)
         icons = OWGUI.getAttributeIcons()
         for attr in self.stringAttrs:
             self.imageAttrCB.addItem(icons[attr.varType], attr.name)
         for attr in self.allAttrs:
             self.titleAttrCB.addItem(icons[attr.varType], attr.name)
         
         self.openContext("", data)
         self.imageAttr = max(min(self.imageAttr, len(self.stringAttrs) - 1), 0)
         self.titleAttr = max(min(self.titleAttr, len(self.allAttrs) - 1), 0)
         
         if self.stringAttrs:
             self.setupScene()
         else:
             self.clearScene()
     else:
         self.imageAttrCB.clear()
         self.titleAttrCB.clear()
         self.clearScene()
    def setData(self, data=None):
        self.closeContext("")
        self.clear()
        self.data = data
        self.warning([0])
        if data is not None:
            attrs = data.domain.variables + data.domain.getmetas().values()
            attrs = [
                attr for attr in attrs if isinstance(attr, orange.EnumVariable)
            ]
            if not attrs:
                self.warning(0, "Data has no discrete variables!")
                self.clear()
                return
            self.allAttrs = attrs
            self.colAttrCB.clear()
            self.rowAttrCB.clear()
            icons = OWGUI.getAttributeIcons()
            for attr in attrs:
                self.colAttrCB.addItem(QIcon(icons[attr.varType]), attr.name)
                self.rowAttrCB.addItem(QIcon(icons[attr.varType]), attr.name)

            self.colAttr = max(min(len(attrs) - 1, self.colAttr), 0)
            self.rowAttr = max(min(len(attrs) - 1, self.rowAttr),
                               min(1,
                                   len(attrs) - 1))

            self.openContext("", data)
            self.runCA()
Ejemplo n.º 3
0
 def setData(self, data=None):
     self.closeContext("")
     self.clear()
     self.data = data
     self.warning([0])
     if data is not None:
         attrs = data.domain.variables + data.domain.getmetas().values()
         attrs = [attr for attr in attrs if isinstance(attr, orange.EnumVariable)]
         if not attrs:
             self.warning(0, "Data has no discrete variables!")
             self.clear()
             return
         self.allAttrs = attrs
         self.colAttrCB.clear()
         self.rowAttrCB.clear()
         icons = OWGUI.getAttributeIcons()
         for attr in attrs:
             self.colAttrCB.addItem(QIcon(icons[attr.varType]), attr.name)
             self.rowAttrCB.addItem(QIcon(icons[attr.varType]), attr.name)
             
         self.colAttr = max(min(len(attrs) - 1, self.colAttr), 0)
         self.rowAttr = max(min(len(attrs) - 1, self.rowAttr), min(1, len(attrs) - 1))
         
         self.openContext("", data)
         self.runCA()
Ejemplo n.º 4
0
 def setData(self, data):
     self.data = data
     self.closeContext("")
     self.information(0)
     self.error(0)
     if data is not None:
         self.imageAttrCB.clear()
         self.titleAttrCB.clear()
         self.allAttrs = data.domain.variables + data.domain.getmetas().values()
         self.stringAttrs = [attr for attr in self.allAttrs if attr.varType == orange.VarTypes.String]
         self.hasTypeImageHint = any("type" in attr.attributes for attr in self.stringAttrs)
         self.stringAttrs = sorted(self.stringAttrs, key=lambda  attr: 0 if "type" in attr.attributes else 1)
         icons = OWGUI.getAttributeIcons()
         for attr in self.stringAttrs:
             self.imageAttrCB.addItem(icons[attr.varType], attr.name)
         for attr in self.allAttrs:
             self.titleAttrCB.addItem(icons[attr.varType], attr.name)
         
         self.openContext("", data)
         self.imageAttr = max(min(self.imageAttr, len(self.stringAttrs) - 1), 0)
         self.titleAttr = max(min(self.titleAttr, len(self.allAttrs) - 1), 0)
         
         if self.stringAttrs:
             self.setupScene()
         else:
             self.clearScene()
     else:
         self.imageAttrCB.clear()
         self.titleAttrCB.clear()
         self.clearScene()
Ejemplo n.º 5
0
    def init_attr_values(self):
        self.x_attr_cb.clear()
        self.y_attr_cb.clear()
        self.z_attr_cb.clear()
        self.color_attr_cb.clear()
        self.size_attr_cb.clear()
        self.symbol_attr_cb.clear()
        self.label_attr_cb.clear()

        self.discrete_attrs = {}

        if not self.data:
            return

        self.color_attr_cb.addItem('(Same color)')
        self.label_attr_cb.addItem('(No labels)')
        self.symbol_attr_cb.addItem('(Same symbol)')
        self.size_attr_cb.addItem('(Same size)')

        icons = OWGUI.getAttributeIcons()
        for metavar in [
                self.data.domain.getmeta(mykey)
                for mykey in self.data.domain.getmetas().keys()
        ]:
            self.label_attr_cb.addItem(icons[metavar.varType], metavar.name)

        for attr in self.data.domain:
            if attr.varType in [Discrete, Continuous]:
                self.x_attr_cb.addItem(icons[attr.varType], attr.name)
                self.y_attr_cb.addItem(icons[attr.varType], attr.name)
                self.z_attr_cb.addItem(icons[attr.varType], attr.name)
                self.color_attr_cb.addItem(icons[attr.varType], attr.name)
                self.size_attr_cb.addItem(icons[attr.varType], attr.name)
            if attr.varType == Discrete and len(attr.values) < len(Symbol):
                self.symbol_attr_cb.addItem(icons[attr.varType], attr.name)
            self.label_attr_cb.addItem(icons[attr.varType], attr.name)

        self.x_attr = str(self.x_attr_cb.itemText(0))
        if self.y_attr_cb.count() > 1:
            self.y_attr = str(self.y_attr_cb.itemText(1))
        else:
            self.y_attr = str(self.y_attr_cb.itemText(0))

        if self.z_attr_cb.count() > 2:
            self.z_attr = str(self.z_attr_cb.itemText(2))
        else:
            self.z_attr = str(self.z_attr_cb.itemText(0))

        if self.data.domain.classVar and self.data.domain.classVar.varType in [
                Discrete, Continuous
        ]:
            self.color_attr = self.data.domain.classVar.name
        else:
            self.color_attr = ''

        self.symbol_attr = self.size_attr = self.label_attr = ''
        self.shown_attrs = [
            self.x_attr, self.y_attr, self.z_attr, self.color_attr
        ]
Ejemplo n.º 6
0
 def headerData(self, section, orientation, role=Qt.DisplayRole):
     if orientation == Qt.Horizontal and role == Qt.DecorationRole:
         var = self.all_attrs[section]
         return QIcon(OWGUI.getAttributeIcons()[var.varType])
     elif orientation == Qt.Horizontal and role == Qt.TextAlignmentRole:
         return Qt.AlignLeft
     else:
         return super(TableModel, self).headerData(section, orientation,
                                                   role)
Ejemplo n.º 7
0
 def headerData(self, section, orientation, role=Qt.DisplayRole):
     if orientation == Qt.Horizontal and role == Qt.DecorationRole:
         var = self.all_attrs[section]
         return QIcon(OWGUI.getAttributeIcons()[var.varType])
     elif orientation == Qt.Horizontal and role == Qt.TextAlignmentRole:
         return Qt.AlignLeft
     else:
         return super(TableModel, self).headerData(section, orientation,
                                                   role)
Ejemplo n.º 8
0
 def data(self, index, role=Qt.DisplayRole):
     i = index.row()
     if role == Qt.DisplayRole:
         return self.__getitem__(i).name#QVariant(self.__getitem__(i).name)
     elif role == Qt.DecorationRole:
         return OWGUI.getAttributeIcons().get(self.__getitem__(i).varType, -1)#QVariant(OWGUI.getAttributeIcons().get(self.__getitem__(i).varType, -1))
     elif role == Qt.EditRole:
         return self.__getitem__(i)#QVariant(self.__getitem__(i))
     return None #QVariant()
 def SetSmilesAttrCombo(self):
     fragmenter = obiChem.Fragmenter()
     attr = [fragmenter.FindSmilesAttr(self.data)]
     self.smilesAttrList = attr
     if self.smilesAttr > len(attr) - 1:
         self.smilesAttr = 0
     self.smilesAttrCombo.clear()
     icons = OWGUI.getAttributeIcons()
     for a in attr:
         self.smilesAttrCombo.addItem(QIcon(icons[a.varType]), a.name)
Ejemplo n.º 10
0
 def data(self, index, role=Qt.DisplayRole):
     i = index.row()
     var = self[i]
     if role == Qt.DisplayRole:
         return QVariant(var.name)
     elif role == Qt.DecorationRole:
         return QVariant(OWGUI.getAttributeIcons().get(var.varType, -1))
     elif role == Qt.ToolTipRole:
         return QVariant(self.variable_tooltip(var))
     else:
         return PyListModel.data(self, index, role)
Ejemplo n.º 11
0
 def data(self, index, role=Qt.DisplayRole):
     i = index.row()
     var = self[i]
     if role == Qt.DisplayRole:
         return QVariant(var.name)
     elif role == Qt.DecorationRole:
         return QVariant(OWGUI.getAttributeIcons().get(var.varType, -1))
     elif role == Qt.ToolTipRole:
         return QVariant(self.variable_tooltip(var))
     else:
         return PyListModel.data(self, index, role)
Ejemplo n.º 12
0
    def init_attr_values(self):
        self.x_attr_cb.clear()
        self.y_attr_cb.clear()
        self.z_attr_cb.clear()
        self.color_attr_cb.clear()
        self.size_attr_cb.clear()
        self.symbol_attr_cb.clear()
        self.label_attr_cb.clear()

        self.discrete_attrs = {}

        if not self.data:
            return

        self.color_attr_cb.addItem('(Same color)')
        self.label_attr_cb.addItem('(No labels)')
        self.symbol_attr_cb.addItem('(Same symbol)')
        self.size_attr_cb.addItem('(Same size)')

        icons = OWGUI.getAttributeIcons() 
        for metavar in [self.data.domain.getmeta(mykey) for mykey in self.data.domain.getmetas().keys()]:
            self.label_attr_cb.addItem(icons[metavar.varType], metavar.name)

        for attr in self.data.domain:
            if attr.varType in [Discrete, Continuous]:
                self.x_attr_cb.addItem(icons[attr.varType], attr.name)
                self.y_attr_cb.addItem(icons[attr.varType], attr.name)
                self.z_attr_cb.addItem(icons[attr.varType], attr.name)
                self.color_attr_cb.addItem(icons[attr.varType], attr.name)
                self.size_attr_cb.addItem(icons[attr.varType], attr.name)
            if attr.varType == Discrete and len(attr.values) < len(Symbol):
                self.symbol_attr_cb.addItem(icons[attr.varType], attr.name)
            self.label_attr_cb.addItem(icons[attr.varType], attr.name)

        self.x_attr = str(self.x_attr_cb.itemText(0))
        if self.y_attr_cb.count() > 1:
            self.y_attr = str(self.y_attr_cb.itemText(1))
        else:
            self.y_attr = str(self.y_attr_cb.itemText(0))

        if self.z_attr_cb.count() > 2:
            self.z_attr = str(self.z_attr_cb.itemText(2))
        else:
            self.z_attr = str(self.z_attr_cb.itemText(0))

        if self.data.domain.classVar and self.data.domain.classVar.varType in [Discrete, Continuous]:
            self.color_attr = self.data.domain.classVar.name
        else:
            self.color_attr = ''

        self.symbol_attr = self.size_attr = self.label_attr = ''
        self.shown_attrs = [self.x_attr, self.y_attr, self.z_attr, self.color_attr]
Ejemplo n.º 13
0
    def onDataInput(self, data):
        self.closeContext()
        if data and self.isDataWithClass(data, orange.VarTypes.Continuous, checkMissing=True):
            orngPade.makeBasicCache(data, self)

            icons = OWGUI.getAttributeIcons()
            self.outputLB.clear()
            for attr in self.contAttributes:
                self.outputLB.addItem(icons[attr.varType], attr.name)

            self.dimensions = range(len(self.attributes))
        else:
            orngPade.makeEmptyCache(self)
            self.dimensions = []

        self.openContext("", data)
        self.dimensionsChanged()
 def __init__(self, var, parent):
     QWidget.__init__(self, parent)
     self.var = var
     layout = QHBoxLayout()
     self._attrs = OWGUI.getAttributeIcons()
     self.type_cb = QComboBox(self)
     for attr, icon in self._attrs.items():
         if attr != -1:
             self.type_cb.addItem(icon, str(attr))
     layout.addWidget(self.type_cb)
     
     self.name_le = QLineEdit(self)
     layout.addWidget(self.name_le)
     
     self.setLayout(layout)
     
     self.connect(self.type_cb, SIGNAL("currentIndexChanged(int)"), self.edited)
     self.connect(self.name_le, SIGNAL("editingFinished()"), self.edited)
Ejemplo n.º 15
0
 def __init__(self, var, parent):
     QWidget.__init__(self, parent)
     self.var = var
     layout = QHBoxLayout()
     self._attrs = OWGUI.getAttributeIcons()
     self.type_cb = QComboBox(self)
     for attr, icon in self._attrs.items():
         if attr != -1:
             self.type_cb.addItem(icon, str(attr))
     layout.addWidget(self.type_cb)
     
     self.name_le = QLineEdit(self)
     layout.addWidget(self.name_le)
     
     self.setLayout(layout)
     
     self.connect(self.type_cb, SIGNAL("currentIndexChanged(int)"), self.edited)
     self.connect(self.name_le, SIGNAL("editingFinished()"), self.edited)
Ejemplo n.º 16
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, title='Combo box')

        self.chosenColor = 1
        self.chosenAttribute = ""

        box = OWGUI.widgetBox(self.controlArea, "Color &  Attribute")
        OWGUI.comboBox(box, self, "chosenColor", label="Color: ", items=["Red", "Green", "Blue"])
        self.attrCombo = OWGUI.comboBox(box, self, "chosenAttribute", label="Attribute: ", sendSelectedValue = 1, emptyString="(none)")

        self.adjustSize()

        # Something like this happens later, in a function which receives an example table
        import orange
        self.data = orange.ExampleTable(r"..\datasets\horse-colic.tab")

        self.attrCombo.clear()
        self.attrCombo.addItem("(none)")
        icons = OWGUI.getAttributeIcons()
        for attr in self.data.domain:
            self.attrCombo.addItem(icons[attr.varType], attr.name)

        self.chosenAttribute = self.data.domain[0].name
Ejemplo n.º 17
0
    def setData(self, data=None):
        self.closeContext("")
        self.data = data
        self.xAttrCB.clear()
        self.yAttrCB.clear()
        self.zAttrCB.clear()
        self.colorAttrCB.clear()
        self.sizeAttrCB.clear()
        if self.data is not None:
            self.allAttrs = data.domain.variables + list(
                data.domain.getmetas().values())
            self.axisCandidateAttrs = [
                attr for attr in self.allAttrs if attr.varType in
                [orange.VarTypes.Continuous, orange.VarTypes.Discrete]
            ]

            self.colorAttrCB.addItem("<None>")
            self.sizeAttrCB.addItem("<None>")
            icons = OWGUI.getAttributeIcons()
            for attr in self.axisCandidateAttrs:
                self.xAttrCB.addItem(icons[attr.varType], attr.name)
                self.yAttrCB.addItem(icons[attr.varType], attr.name)
                self.zAttrCB.addItem(icons[attr.varType], attr.name)
                self.colorAttrCB.addItem(icons[attr.varType], attr.name)
                self.sizeAttrCB.addItem(icons[attr.varType], attr.name)

            array, c, w = self.data.toNumpyMA()
            if len(c):
                array = numpy.hstack((array, c.reshape(-1, 1)))
            self.dataArray = array

            self.xAttr, self.yAttr, self.zAttr = numpy.min(
                [[0, 1, 2], [len(self.axisCandidateAttrs) - 1] * 3], axis=0)
            self.colorAttr = max(len(self.axisCandidateAttrs) - 1, 0)

            self.openContext("", data)
Ejemplo n.º 18
0
 def createAttributeIconDict(self):
     return OWGUI.getAttributeIcons()
Ejemplo n.º 19
0
 def createAttributeIconDict(self):
     return OWGUI.getAttributeIcons()