source: orange/orange/doc/extend-widgets/gui_stopper.py @ 9398:a6b3d9c13ee0

Revision 9398:a6b3d9c13ee0, 1.8 KB checked in by mitar, 2 years ago (diff)

Renaming documentation for widgets developers.

Line 
1from OWWidget import *
2import OWGUI
3
4class OWXLearner(OWWidget):
5    settingsList = ["method", "maxi", "cheat", "autoApply"]
6    def __init__(self, parent=None):
7        OWWidget.__init__(self, parent, title='X Learner')
8
9        self.method= 0
10        self.maxi = 1
11        self.cheat = 0
12        self.autoApply = True
13
14        self.settingsChanged = False
15       
16        OWGUI.radioButtonsInBox(self.controlArea, self, "method",
17                       ["Vanishing", "Disappearing", "Invisibilisation"],
18                       box="Minimization technique", 
19                       callback = self.applyIf)
20        OWGUI.separator(self.controlArea)
21
22        box = OWGUI.widgetBox(self.controlArea, "Settings")
23        OWGUI.checkBox(box, self, "maxi", "Post-maximize", callback = self.applyIf)
24        OWGUI.checkBox(box, self, "cheat", "Quasi-cheating", callback = self.applyIf)
25        OWGUI.separator(self.controlArea)
26
27        box = OWGUI.widgetBox(self.controlArea, "Apply")
28        applyButton = OWGUI.button(box, self, "Apply", callback = self.apply)
29        autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Apply automatically")
30
31        OWGUI.setStopper(self, applyButton, autoApplyCB, "settingsChanged", self.apply)       
32       
33        self.adjustSize()
34
35    def applyIf(self):
36        if self.autoApply:
37            self.apply()
38        else:
39            self.settingsChanged = True
40           
41    def apply(self):
42        # Constructs and sends the learner; here we shall just show a message box
43        QMessageBox.information(self, "Applied", "New settings applied")
44        self.settingsChanged = False
45       
46
47##############################################################################
48# Test the widget, run from prompt
49
50if __name__=="__main__":
51    appl = QApplication(sys.argv)
52    ow = OWXLearner()
53    ow.show()
54    appl.exec_()
Note: See TracBrowser for help on using the repository browser.