source: orange/Orange/doc/extend-widgets/gui_combobox.py @ 9671:a7b056375472

Revision 9671:a7b056375472, 1.3 KB checked in by anze <anze.staric@…>, 2 years ago (diff)

Moved orange to Orange (part 2)

Line 
1from OWWidget import *
2import OWGUI
3
4class Test(OWWidget):
5    settingsList = ["colors", "chosenColor", "numbers", "chosenNumbers"]
6    def __init__(self, parent=None):
7        OWWidget.__init__(self, parent, title='Combo box')
8
9        self.chosenColor = 1
10        self.chosenAttribute = ""
11
12        box = OWGUI.widgetBox(self.controlArea, "Color &  Attribute")
13        OWGUI.comboBox(box, self, "chosenColor", label="Color: ", items=["Red", "Green", "Blue"])
14        self.attrCombo = OWGUI.comboBox(box, self, "chosenAttribute", label="Attribute: ", sendSelectedValue = 1, emptyString="(none)")
15
16        self.adjustSize()
17
18        # Something like this happens later, in a function which receives an example table
19        import orange
20        self.data = orange.ExampleTable(r"..\datasets\horse-colic.tab")
21
22        self.attrCombo.clear()
23        self.attrCombo.addItem("(none)")
24        icons = OWGUI.getAttributeIcons()
25        for attr in self.data.domain:
26            self.attrCombo.addItem(icons[attr.varType], attr.name)
27
28        self.chosenAttribute = self.data.domain[0].name
29
30
31##############################################################################
32# Test the widget, run from prompt
33
34if __name__=="__main__":
35    appl = QApplication(sys.argv)
36    ow = Test()
37    ow.show()
38    appl.exec_()
Note: See TracBrowser for help on using the repository browser.