Commits

Aleš Erjavec committed 1546cd0

Fixed widget layouts.

Comments (0)

Files changed (11)

Orange/OrangeWidgets/Classify/OWCN2.py

                   "MinCoverage", "BeamWidth", "Alpha", "Weight", "stepAlpha"]
     callbackDeposit=[]
     def __init__(self, parent=None, signalManager=None):
-        OWWidget.__init__(self,parent,signalManager,"CN2", wantMainArea = 0, resizingEnabled = 0)
+        OWWidget.__init__(self, parent, signalManager,"CN2",
+                          wantMainArea=False, resizingEnabled=False)
 
         self.inputs = [("Data", ExampleTable, self.dataset), ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
         self.outputs = [("Learner", orange.Learner),("Classifier",orange.Classifier),("Unordered CN2 Classifier", orngCN2.CN2UnorderedClassifier)]
         self.coveringAlgBG = OWGUI.widgetBox(self.controlArea, "Covering algorithm")
         self.coveringAlgBG.buttons = []
 
-        """
-        self.ruleQualityBG=OWGUI.radioButtonsInBox(self.ruleQualityGroup, self, "QualityButton",
-                            btnLabels=["Laplace","m-estimate","WRACC"],
-                            box="Rule quality", callback=self.qualityButtonPressed,
-                            tooltips=["Laplace rule evaluator", "m-estimate rule evaluator",
-                            "WRACC rule evaluator"])
-        self.mSpin=Spin=OWGUI.spin(self.ruleQualityGroup, self, "m", 0, 100, label="m",
-                orientation="horizontal", labelWidth=labelWidth-100, tooltip="m value for m estimate rule evaluator")
-        """
-
-        b1 = QRadioButton("Laplace", self.ruleQualityBG); self.ruleQualityBG.layout().addWidget(b1)
-        g = OWGUI.widgetBox(self.ruleQualityBG, orientation = "horizontal");
+        b1 = QRadioButton("Laplace", self.ruleQualityBG)
+        self.ruleQualityBG.layout().addWidget(b1)
+        g = OWGUI.widgetBox(self.ruleQualityBG, orientation="horizontal")
         b2 = QRadioButton("m-estimate", g)
         g.layout().addWidget(b2)
         self.mSpin = OWGUI.doubleSpin(g,self,"m",0,100)
         for i, button in enumerate([b1, b2, b3, b4]):
             self.connect(button, SIGNAL("clicked()"), lambda v=i: self.qualityButtonPressed(v))
 
-        OWGUI.doubleSpin(self.ruleValidationGroup, self, "Alpha", 0, 1,0.001, label="Alpha (vs. default rule)",
-                orientation="horizontal", labelWidth=labelWidth,
-                tooltip="Required significance of the difference between the class distribution on all example and covered examples")
-        OWGUI.doubleSpin(self.ruleValidationGroup, self, "stepAlpha", 0, 1,0.001, label="Stopping Alpha (vs. parent rule)",
-                orientation="horizontal", labelWidth=labelWidth,
-                tooltip="Required significance of each specialization of a rule.")
-        OWGUI.spin(self.ruleValidationGroup, self, "MinCoverage", 0, 100,label="Minimum coverage",
-                orientation="horizontal", labelWidth=labelWidth, tooltip=
-                "Minimum number of examples a rule must\ncover (use 0 for not setting the limit)")
-        OWGUI.checkWithSpin(self.ruleValidationGroup, self, "Maximal rule length", 0, 100, "useMaxRuleLength", "MaxRuleLength", labelWidth=labelWidth,
-                            tooltip="Maximal number of conditions in the left\npart of the rule (use 0 for don't care)")
+        form = QFormLayout(
+            labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft,
+            fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow
+        )
 
-        """
-        self.coveringAlgBG=OWGUI.radioButtonsInBox(self.coveringAlgGroup, self, "CoveringButton",
-                            btnLabels=["Exclusive covering ","Weighted Covering"],
-                            tooltips=["Each example will only be used once\n for the construction of a rule",
-                                      "Examples can take part in the construction\n of many rules(CN2-SD Algorithm)"],
-                            box="Covering algorithm", callback=self.coveringAlgButtonPressed)
-        self.weightSpin=OWGUI.doubleSpin(self.coveringAlgGroup, self, "Weight",0, 0.95,0.05,label= "Weight",
-                orientation="horizontal", labelWidth=labelWidth, tooltip=
-                "Multiplication constant by which the weight of\nthe example will be reduced")
-        """
+        self.ruleValidationGroup.layout().addLayout(form)
 
-        B1 = QRadioButton("Exclusive covering", self.coveringAlgBG); self.coveringAlgBG.layout().addWidget(B1)
-        g = OWGUI.widgetBox(self.coveringAlgBG, orientation = "horizontal")
-        B2 = QRadioButton("Weighted covering", g); g.layout().addWidget(B2)
+        alpha_spin = OWGUI.doubleSpin(
+            self.ruleValidationGroup, self, "Alpha", 0, 1, 0.001,
+            tooltip="Required significance of the difference between the " +
+                    "class distribution on all examples and covered examples")
+
+        step_alpha_spin = OWGUI.doubleSpin(
+            self.ruleValidationGroup, self, "stepAlpha", 0, 1, 0.001,
+            tooltip="Required significance of each specialization of a rule.")
+
+        min_coverage_spin = OWGUI.spin(
+            self.ruleValidationGroup, self, "MinCoverage", 0, 100,
+            tooltip="Minimum number of examples a rule must cover " +
+                    "(use 0 for not setting the limit)")
+
+        min_coverage_spin.setSpecialValueText("Unlimited")
+
+        # Check box needs to be in alayout for the form layout to center it
+        # in the vertical direction.
+        max_rule_box = OWGUI.widgetBox(self.ruleValidationGroup, "")
+        max_rule_cb = OWGUI.checkBox(
+            max_rule_box, self, "useMaxRuleLength", "Maximal rule length")
+
+        max_rule_spin = OWGUI.spin(
+            self.ruleValidationGroup, self, "MaxRuleLength", 0, 100,
+            tooltip="Maximal number of conditions in the left\n" +
+                    "part of the rule (use 0 for don't care)")
+        max_rule_spin.setSpecialValueText("Unlimited")
+        max_rule_cb.disables += [max_rule_spin]
+        max_rule_cb.makeConsistent()
+
+        form.addRow("Alpha (vs. default rule)", alpha_spin)
+        form.addRow("Stopping Alpha (vs. parent rule)", step_alpha_spin)
+        form.addRow("Minimum coverage", min_coverage_spin)
+        form.addRow(max_rule_box, max_rule_spin)
+
+        B1 = QRadioButton("Exclusive covering", self.coveringAlgBG)
+        self.coveringAlgBG.layout().addWidget(B1)
+        g = OWGUI.widgetBox(self.coveringAlgBG, orientation="horizontal")
+        B2 = QRadioButton("Weighted covering", g)
+        g.layout().addWidget(B2)
         self.coveringAlgBG.buttons = [B1, B2]
         self.weightSpin=OWGUI.doubleSpin(g,self,"Weight",0,0.95,0.05)
 

Orange/OrangeWidgets/Classify/OWEnsemble.py

                ("Bagging", orngEnsemble.BaggedLearner)]
     
     def __init__(self, parent=None, signalManager=None, name="Ensemble"):
-        OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False)
+        OWWidget.__init__(self, parent, signalManager, name,
+                          wantMainArea=False, resizingEnabled=False)
         
         self.inputs = [("Learner", orange.Learner, self.setLearner), ("Data", ExampleTable, self.setData)]
         self.outputs = [("Learner", orange.Learner), ("Classifier", orange.Classifier)]

Orange/OrangeWidgets/Classify/OWLoadClassifier.py

     settingsList = ["filenameHistory", "selectedFileIndex", "lastFile"]
     
     def __init__(self, parent=None, signalManager=None, name="Load Classifier"):
-        OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False)
+        OWWidget.__init__(self, parent, signalManager, name,
+                          wantMainArea=False, resizingEnabled=False)
         
         self.outputs = [("Classifier", orange.Classifier, Dynamic)]
         
                                          items = [os.path.basename(p) for p in self.filenameHistory],
                                          tooltip="Select a recent file", 
                                          callback=self.onRecentSelection)
-        
+        self.filesCombo.setMinimumWidth(200)
+
         self.browseButton = OWGUI.button(box, self, "...", callback=self.browse,
                                          tooltip = "Browse file system")
 

Orange/OrangeWidgets/Classify/OWLogisticRegression.py

 
         stepwiseCb = OWGUI.checkBox(box, self, "stepwiseLR", "Stepwise attribute selection")
         ibox = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(stepwiseCb))
-        addCritSpin = OWGUI.spin(ibox, self, "addCrit", 1, 50, label="Add threshold [%]", labelWidth=155, tooltip="Requested significance for adding an attribute")
-        remCritSpin = OWGUI.spin(ibox, self, "removeCrit", 1, 50, label="Remove threshold [%]", labelWidth=155, tooltip="Requested significance for removing an attribute")
-        limitAttSpin = OWGUI.checkWithSpin(ibox, self, "Limit number of attributes to ", 1, 100, "limitNumAttr", "numAttr", step=1, labelWidth=155, tooltip="Maximum number of attributes. Algorithm stops when it selects specified number of attributes.")
-        stepwiseCb.disables += [addCritSpin, remCritSpin, limitAttSpin]
+        form = QFormLayout(
+            spacing=8, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow,
+            labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft
+        )
+        ibox.layout().addLayout(form)
+
+        addCritSpin = OWGUI.spin(
+            ibox, self, "addCrit", 1, 50,
+            tooltip="Requested significance for adding an attribute"
+        )
+
+        addCritSpin.setSuffix(" %")
+
+        form.addRow("Add threshold", addCritSpin)
+
+        remCritSpin = OWGUI.spin(
+            ibox, self, "removeCrit", 1, 50,
+            tooltip="Requested significance for removing an attribute"
+        )
+        remCritSpin.setSuffix(" %")
+
+        form.addRow("Remove threshold", remCritSpin)
+
+        # Need to wrap the check box in a layout to force vertical centering
+        limitBox = OWGUI.widgetBox(ibox, "")
+        limitCb = OWGUI.checkBox(
+            limitBox, self, "limitNumAttr", "Limit number of attributes to",
+        )
+
+        limitAttSpin = OWGUI.spin(
+            ibox, self, "numAttr", 1, 100,
+            tooltip="Maximum number of attributes. Algorithm stops when it " +
+                    "selects specified number of attributes."
+        )
+
+        limitCb.disables += [limitAttSpin]
+        limitCb.makeConsistent()
+
+        form.addRow(limitBox, limitAttSpin)
+
+        stepwiseCb.disables += [ibox]
         stepwiseCb.makeConsistent()
-        
+
         OWGUI.separator(self.controlArea)
 
         self.imputationCombo = OWGUI.comboBox(self.controlArea, self, "imputation", box="Imputation of unknown values", items=self.imputationMethodsStr)

Orange/OrangeWidgets/Classify/OWNeuralNetwork.py

 """
 <name>Neural Network</name>
 <description>Neural network learner.</description>
-<priority>20<priority>
+<priority>20</priority>
 <icon>icons/NeuralNetwork.svg</icon>
 
 """
     def __init__(self, parent=None, signalManager=None,
                  title="Neural Network"):
         OWWidget.__init__(self, parent, signalManager, title,
-                          wantMainArea=False)
+                          wantMainArea=False, resizingEnabled=False)
 
         self.inputs = [("Data", Orange.data.Table, self.set_data),
                        ("Preprocess", PreprocessedLearner,
         box = OWGUI.widgetBox(self.controlArea, "Name", addSpace=True)
         OWGUI.lineEdit(box, self, "name")
 
-        box = OWGUI.widgetBox(self.controlArea, "Settings", addSpace=True)
-        OWGUI.spin(box, self, "n_mid", 2, 10000, 1,
-                   label="Hidden layer neurons",
-                   tooltip="Number of neurons in the hidden layer."
-                   )
+        box = OWGUI.widgetBox(self.controlArea, "Settings",
+                              addSpace=True)
 
-        OWGUI.doubleSpin(box, self, "reg_fact", 0.1, 10.0, 0.1,
-                         label="Regularization factor",
-                         )
+        form = QFormLayout(
+            spacing=8, formAlignment=Qt.AlignLeft, labelAlignment=Qt.AlignLeft,
+            fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow
+        )
+        box.layout().addLayout(form)
 
-        OWGUI.spin(box, self, "max_iter", 100, 10000, 1,
-                   label="Max iterations",
-                   tooltip="Maximal number of optimization iterations."
-                   )
+        form.addRow(
+            "Hidden layer neurons",
+            OWGUI.spin(box, self, "n_mid", 2, 10000, 1,
+                       tooltip="Number of neurons in the hidden layer.",
+                       addToLayout=False)
+        )
+
+        form.addRow(
+            "Regularization factor",
+            OWGUI.doubleSpin(box, self, "reg_fact", 0.1, 10.0, 0.1,
+                             addToLayout=False)
+        )
+
+        form.addRow(
+            "Max iterations",
+            OWGUI.spin(box, self, "max_iter", 100, 10000, 1,
+                       tooltip="Maximal number of optimization iterations.",
+                       addToLayout=False)
+        )
+
+        OWGUI.checkBox(box, self, 'normalize', 'Normalize the data')
 
         OWGUI.button(self.controlArea, self, "&Apply",
                      callback=self.apply,
                      tooltip="Create the learner and apply it on input data.",
-                     autoDefault=True
-                     )
-
-        OWGUI.checkBox(box, self, 'normalize', 'Normalize the data')
+                     autoDefault=True)
 
         self.data = None
         self.preprocessor = None

Orange/OrangeWidgets/Classify/OWSaveClassifier.py

 class OWSaveClassifier(OWWidget):
     settingsList = ["lastSaveFile", "filenameHistory"]
     def __init__(self, parent=None, signalManager=None, name="Save Classifier"):
-        OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False)
+        OWWidget.__init__(self, parent, signalManager, name,
+                          wantMainArea=False, resizingEnabled=False)
         
         self.inputs = [("Classifier", orange.Classifier, self.setClassifier)]
         
                                          items=[os.path.basename(f) for f in self.filenameHistory],
                                          tooltip="Select a recently saved file",
                                          callback=self.onRecentSelection)
-        
+        self.filesCombo.setMinimumWidth(200)
+
         self.browseButton = OWGUI.button(box, self, "...",
                                          tooltip="Browse local file system",
                                          callback=self.browse)

Orange/OrangeWidgets/Regression/OWLinearRegression.py

     def __init__(self, parent=None, signalManager=None,
                  title="Linear Regression"):
         OWWidget.__init__(self, parent, signalManager, title,
-                          wantMainArea=False)
+                          wantMainArea=False, resizingEnabled=False)
 
         self.inputs = [("Data", Orange.data.Table, self.set_data),
                        ("Preprocessor", PreprocessedLearner,

Orange/OrangeWidgets/Regression/OWMean.py

 
 class OWMean(OWMajority):
     def __init__(self, parent=None, signalManager=None, title="Mean"):
-        OWWidget.__init__(self, parent, signalManager, title, wantMainArea=False)
+        OWWidget.__init__(self, parent, signalManager, title,
+                          wantMainArea=False, resizingEnabled=False)
 
         self.inputs = [("Data", ExampleTable, self.setData),
                        ("Preprocess", PreprocessedLearner, self.setPreprocessor)]

Orange/OrangeWidgets/Regression/OWPLS.py

     settingsList = ["name", "n_comp", "deflation_mode", "mode", "algorithm"]
     
     def __init__(self, parent=None, signalManager=None, title="PLS Regression"):
-        OWWidget.__init__(self, parent, signalManager, title, wantMainArea=False)
+        OWWidget.__init__(self, parent, signalManager, title,
+                          wantMainArea=False, resizingEnabled=False)
         
         self.inputs = [("Data", Orange.data.Table, self.set_data),
                        ("Preprocessor", PreprocessedLearner, self.set_preprocessor)]

Orange/OrangeWidgets/Regression/OWSVMRegression.py

     settingsList = OWSVM.settingsList + ["C_epsilon", "C_nu"]
 
     def __init__(self, parent=None, signalManager=None, title="SVM Regression"):
-        OWWidget.__init__(self, parent, signalManager, title, wantMainArea=False)
+        OWWidget.__init__(self, parent, signalManager, title,
+                          wantMainArea=False, resizingEnabled=False)
 
         self.inputs=[("Data", Orange.data.Table, self.setData), 
                      ("Preprocess", PreprocessedLearner, self.setPreprocessor)]

Orange/OrangeWidgets/Unsupervised/OWDistanceFilter.py

 class OWDistanceFilter(OWWidget):
     
     def __init__(self, parent=None, signalManager = None, name='Distance Matrix Filter'):
-        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)
+        OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0)
         
         self.inputs = [("Distances", orange.SymMatrix, self.setSymMatrix, Default), ("Data Subset", ExampleTable, self.setExampleSubset)]
         self.outputs = [("Distances", orange.SymMatrix)]