source: orange/Orange/doc/extend-widgets/gui_listbox.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='Listbox')
8
9        self.colors = ["Red", "Green", "Blue"]
10        self.chosenColor = [2]
11        self.numbers = ["One", "Two", "Three", "Four"]
12        self.chosenNumbers = [0, 2, 3]
13
14        OWGUI.listBox(self.controlArea, self, "chosenColor", "colors", box="Color", callback=self.checkAll)
15        OWGUI.listBox(self.controlArea, self, "chosenNumbers", "numbers", box="Number", selectionMode=QListWidget.MultiSelection, callback=self.checkAll)
16
17        OWGUI.separator(self.controlArea)
18       
19        box = OWGUI.widgetBox(self.controlArea, "Debug info")
20        OWGUI.label(box, self, "Color: %(chosenColor)s")
21        OWGUI.label(box, self, "Numbers: %(chosenNumbers)s", labelWidth=100)
22
23        self.setFixedSize(110, 280)
24
25    def checkAll(self):
26        if len(self.chosenNumbers) == len(self.numbers) and self.chosenColor != [0]:
27            self.chosenColor = [0]
28
29##############################################################################
30# Test the widget, run from prompt
31
32if __name__=="__main__":
33    appl = QApplication(sys.argv)
34    ow = Test()
35    ow.show()
36    appl.exec_()
Note: See TracBrowser for help on using the repository browser.