Exemple #1
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Survey Plot", TRUE)

        self.inputs = [("Data", ExampleTable, self.setData, Default),
                       ("Features", AttributeList, self.setShownAttributes)]
        self.outputs = [("Features", AttributeList)]

        #add a graph widget
        self.graph = OWSurveyPlotGraph(self.mainArea)
        self.mainArea.layout().addWidget(self.graph)
        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)

        #set default settings
        self.data = None
        self.showAllAttributes = 0
        self.graph.exampleTracking = 0
        self.graph.enabledLegend = 1
        self.graph.tooltipKind = 1
        self.attributeSelectionList = None
        self.graphCanvasColor = str(QColor(Qt.white).name())
        self.primaryAttribute = "(None)"
        self.secondaryAttribute = "(None)"
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        #load settings
        self.loadSettings()

        #GUI
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        #add controls to self.controlArea widget
        self.sortingAttrGB = OWGUI.widgetBox(self.GeneralTab, "Sorting")
        self.primaryAttrCombo = OWGUI.comboBoxWithCaption(
            self.sortingAttrGB,
            self,
            "primaryAttribute",
            label='1st:',
            items=["(None)"],
            sendSelectedValue=1,
            valueType=str,
            callback=self.sortingClick,
            labelWidth=25)
        self.secondaryAttrCombo = OWGUI.comboBoxWithCaption(
            self.sortingAttrGB,
            self,
            "secondaryAttribute",
            label='2nd:',
            items=["(None)"],
            sendSelectedValue=1,
            valueType=str,
            callback=self.sortingClick,
            labelWidth=25)

        self.createShowHiddenLists(self.GeneralTab, callback=self.updateGraph)

        # ##################################
        # survey plot settings
        box = OWGUI.widgetBox(self.SettingsTab, "Visual settings")
        OWGUI.checkBox(box,
                       self,
                       "graph.exampleTracking",
                       "Example tracking",
                       callback=self.updateGraph)
        OWGUI.checkBox(box,
                       self,
                       "graph.enabledLegend",
                       "Show legend",
                       callback=self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Tooltips settings")
        OWGUI.comboBox(box,
                       self,
                       "graph.tooltipKind",
                       items=[
                           "Don't Show Tooltips", "Show Visible Attributes",
                           "Show All Attributes"
                       ],
                       callback=self.updateGraph)

        self.colorButtonsBox = OWGUI.widgetBox(self.SettingsTab,
                                               "Colors",
                                               orientation="horizontal")
        OWGUI.button(
            self.colorButtonsBox,
            self,
            "Set Colors",
            self.setColors,
            tooltip=
            "Set the canvas background color, grid color and color palette for coloring continuous variables",
            debuggingEnabled=0)
        self.SettingsTab.layout().addStretch(100)

        self.icons = self.createAttributeIconDict()

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")
        self.graph.setCanvasBackground(dlg.getColor("Canvas"))
        self.graph.gridCurve.setPen(QPen(dlg.getColor("Grid")))

        #self.graph.setCanvasBackground(QColor(self.graphCanvasColor))
        self.cbShowAllAttributes()
        self.resize(750, 700)