Changeset 7867:6f1f43d43516 in orange


Ignore:
Timestamp:
04/20/11 16:25:20 (3 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
d453b66e252d54634279b5ebbafa1b1287697d4a
Message:

Setting default buttons (clicked when pressing enter) on all widgets where applicable.

Location:
orange/OrangeWidgets
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Classify/OWC45Tree.py

    r6949 r7867  
    7171        OWGUI.separator(self.controlArea) 
    7272 
    73         OWGUI.button(self.controlArea, self, "&Apply", callback = self.setLearner, disabled=0) 
     73        OWGUI.button(self.controlArea, self, "&Apply", callback = self.setLearner, disabled=0, default=True) 
    7474 
    7575        OWGUI.rubber(self.controlArea) 
  • orange/OrangeWidgets/Classify/OWCN2.py

    r6949 r7867  
    122122 
    123123        OWGUI.separator(self.controlArea) 
    124         self.btnApply = OWGUI.button(self.controlArea, self, "&Apply", callback=self.applySettings) 
     124        self.btnApply = OWGUI.button(self.controlArea, self, "&Apply", callback=self.applySettings, default=True) 
    125125 
    126126        self.Alpha=float(self.Alpha) 
  • orange/OrangeWidgets/Classify/OWCN2RulesViewer.py

    r7063 r7867  
    132132         
    133133        box = OWGUI.widgetBox(self.controlArea, "Show Info", addSpace=True) 
     134        box.layout().setSpacing(3) 
    134135        self.headers = ["Rule length", 
    135136                        "Rule quality", 
     
    145146             
    146147        box = OWGUI.widgetBox(self.controlArea, "Output") 
     148        box.layout().setSpacing(3) 
    147149        cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on any change", 
    148150                            callback=self.commitIf) 
     
    152154                       callback=self.commitIf) 
    153155         
    154         b = OWGUI.button(box, self, "Commit", callback=self.commit) 
     156        b = OWGUI.button(box, self, "Commit", callback=self.commit, default=True) 
    155157        OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.commit) 
    156158         
  • orange/OrangeWidgets/Classify/OWClassificationTree.py

    r7039 r7867  
    8181 
    8282        OWGUI.separator(self.controlArea) 
    83         self.btnApply = OWGUI.button(self.controlArea, self, "&Apply", callback = self.setLearner, disabled=0) 
     83        self.btnApply = OWGUI.button(self.controlArea, self, "&Apply", callback = self.setLearner, disabled=0, default=True) 
    8484         
    8585        OWGUI.rubber(self.controlArea) 
  • orange/OrangeWidgets/Classify/OWKNN.py

    r6949 r7867  
    6060        OWGUI.separator(self.controlArea) 
    6161 
    62         OWGUI.button(self.controlArea, self, "&Apply", callback = self.setLearner, disabled=0) 
     62        OWGUI.button(self.controlArea, self, "&Apply", callback=self.setLearner, disabled=0, default=True) 
    6363         
    6464        OWGUI.rubber(self.controlArea) 
  • orange/OrangeWidgets/Classify/OWLogisticRegression.py

    r7039 r7867  
    6161        OWGUI.separator(self.controlArea) 
    6262 
    63         applyButton = OWGUI.button(self.controlArea, self, "&Apply", callback = self.applyLearner) 
     63        applyButton = OWGUI.button(self.controlArea, self, "&Apply", callback=self.applyLearner, default=True) 
    6464 
    6565        OWGUI.rubber(self.controlArea) 
  • orange/OrangeWidgets/Classify/OWMajority.py

    r6949 r7867  
    3232        OWGUI.separator(self.controlArea) 
    3333 
    34         OWGUI.button(self.controlArea, self, "&Apply", callback = self.setLearner, disabled=0) 
     34        OWGUI.button(self.controlArea, self, "&Apply", callback=self.setLearner, disabled=0, default=True) 
    3535         
    3636        OWGUI.rubber(self.controlArea) 
  • orange/OrangeWidgets/Classify/OWNaiveBayes.py

    r7039 r7867  
    9393 
    9494        OWGUI.separator(self.controlArea) 
    95         box = OWGUI.widgetBox(self.controlArea, "Apply", orientation=1) 
    96         applyButton = OWGUI.button(box, self, "&Apply", callback=self.applyLearner) 
     95#        box = OWGUI.widgetBox(self.controlArea, "Apply", orientation=1) 
     96        applyButton = OWGUI.button(self.controlArea, self, "&Apply", callback=self.applyLearner, default=True) 
    9797 
    9898        OWGUI.rubber(self.controlArea) 
  • orange/OrangeWidgets/Classify/OWRandomForest.py

    r7687 r7867  
    1717 
    1818    def __init__(self, parent=None, signalManager = None, name='Random Forest'): 
    19         OWWidget.__init__(self, parent, signalManager, name) 
     19        OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False, resizingEnabled=False) 
    2020 
    2121        self.inputs = [("Examples", ExampleTable, self.setData), ("Preprocess", PreprocessedLearner, self.setPreprocessor)] 
     
    6868        OWGUI.separator(self.controlArea) 
    6969 
    70         self.btnApply = OWGUI.button(self.controlArea, self, "&Apply Changes", callback = self.doBoth, disabled=0) 
     70        self.btnApply = OWGUI.button(self.controlArea, self, "&Apply Changes", callback = self.doBoth, disabled=0, default=True) 
    7171 
    7272        self.resize(100,200) 
  • orange/OrangeWidgets/Classify/OWSVM.py

    r6949 r7867  
    7474 
    7575        self.paramButton=OWGUI.button(self.controlArea, self, "Automatic parameter search", callback=self.parameterSearch, 
    76                                       tooltip="Automaticaly searches for parameters that optimize classifier acuracy", debuggingEnabled=0) 
     76                                      tooltip="Automatically searches for parameters that optimize classifier accuracy", debuggingEnabled=0) 
    7777        self.paramButton.setDisabled(True) 
    7878 
    79         OWGUI.button(self.controlArea, self,"&Apply", callback=self.applySettings) 
     79        OWGUI.button(self.controlArea, self,"&Apply", callback=self.applySettings, default=True) 
    8080         
    8181        OWGUI.rubber(self.controlArea) 
  • orange/OrangeWidgets/Data/OWConcatenate.py

    r7169 r7867  
    3636 
    3737        OWGUI.separator(self.controlArea) 
    38         box = OWGUI.widgetBox(self.controlArea, "Data source IDs") 
     38        box = OWGUI.widgetBox(self.controlArea, "Data source IDs", addSpace=True) 
    3939        cb = OWGUI.checkBox(box, self, "dataSourceSelected", "Append data source IDs") 
    4040        self.classificationBox = ib = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(cb)) 
     
    4444        cb.disables.append(ib) 
    4545        cb.makeConsistent() 
    46         OWGUI.separator(box) 
    47         OWGUI.button(box, self, "Apply Changes", callback = self.apply) 
     46         
     47        OWGUI.button(self.controlArea, self, "Apply Changes", callback = self.apply, default=True) 
    4848         
    4949        OWGUI.rubber(self.controlArea) 
  • orange/OrangeWidgets/Data/OWContinuize.py

    r7039 r7867  
    8282 
    8383        snbox = OWGUI.widgetBox(self.controlArea, "Send data") 
    84         OWGUI.button(snbox, self, "Send data", callback=self.sendData) 
     84        OWGUI.button(snbox, self, "Send data", callback=self.sendData, default=True) 
    8585        OWGUI.checkBox(snbox, self, "autosend", "Send automatically", callback=self.enableAuto) 
    8686        self.data = None 
  • orange/OrangeWidgets/Data/OWDataDomain.py

    r6610 r7867  
    9393        boxApply = OWGUI.widgetBox(self, addToLayout = 0, orientation = "horizontal", addSpace = 1) 
    9494        grid.addWidget(boxApply, 3, 0, 3, 3) 
    95         self.applyButton = OWGUI.button(boxApply, self, "Apply", callback = self.setOutput) 
     95        self.applyButton = OWGUI.button(boxApply, self, "Apply", callback = self.setOutput, default=True) 
    9696        self.applyButton.setEnabled(False) 
    9797        self.applyButton.setMaximumWidth(applyButtonWidth) 
  • orange/OrangeWidgets/Data/OWDataSampler.py

    r7039 r7867  
    106106        # Select Data Button 
    107107        OWGUI.rubber(self.controlArea) 
    108         self.sampleButton = OWGUI.button(self.controlArea, self, 'Sample &Data', callback = self.process, addToLayout=False) 
     108        self.sampleButton = OWGUI.button(self.controlArea, self, 'Sample &Data', callback = self.process, addToLayout=False, default=True) 
    109109        self.buttonBackground.layout().setDirection(QBoxLayout.TopToBottom) 
    110110        self.buttonBackground.layout().insertWidget(0, self.sampleButton) 
  • orange/OrangeWidgets/Data/OWDataTable.py

    r7845 r7867  
    170170        colBox = OWGUI.indentedBox(boxSettings, sep=OWGUI.checkButtonOffsetHint(self.cbShowDistributions), orientation = "horizontal") 
    171171        OWGUI.widgetLabel(colBox, "Color: ") 
    172         self.colButton = OWGUI.toolButton(colBox, self, self.changeColor, width=20, height=20, debuggingEnabled = 0) 
     172        self.colButton = OWGUI.toolButton(colBox, self, callback=self.changeColor, width=20, height=20, debuggingEnabled = 0) 
    173173        OWGUI.rubber(colBox) 
    174174 
    175175        resizeColsBox = OWGUI.widgetBox(boxSettings, 0, "horizontal", 0) 
    176176        OWGUI.label(resizeColsBox, self, "Resize columns: ") 
    177         OWGUI.toolButton(resizeColsBox, self, self.increaseColWidth, tooltip = "Increase the width of the columns", width=20, height=20).setText("+") 
    178         OWGUI.toolButton(resizeColsBox, self, self.decreaseColWidth, tooltip = "Decrease the width of the columns", width=20, height=20).setText("-") 
     177        OWGUI.toolButton(resizeColsBox, self, "+", self.increaseColWidth, tooltip = "Increase the width of the columns", width=20, height=20) 
     178        OWGUI.toolButton(resizeColsBox, self, "-", self.decreaseColWidth, tooltip = "Decrease the width of the columns", width=20, height=20) 
    179179        OWGUI.rubber(resizeColsBox) 
    180180 
     
    183183        OWGUI.separator(self.controlArea) 
    184184        selectionBox = OWGUI.widgetBox(self.controlArea, "Selection") 
    185         self.sendButton = OWGUI.button(selectionBox, self, "Send selections", self.commit) 
     185        self.sendButton = OWGUI.button(selectionBox, self, "Send selections", self.commit, default=True) 
    186186        cb = OWGUI.checkBox(selectionBox, self, "autoCommit", "Commit on any change", callback=self.commitIf) 
    187187        OWGUI.setStopper(self, self.sendButton, cb, "selectionChangedFlag", self.commit) 
  • orange/OrangeWidgets/Data/OWDiscretize.py

    r7039 r7867  
    493493 
    494494        box = OWGUI.widgetBox(vbox, "Commit") 
    495         applyButton = OWGUI.button(box, self, "Commit", callback = self.commit) 
     495        applyButton = OWGUI.button(box, self, "Commit", callback = self.commit, default=True) 
    496496        autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Commit automatically", callback=[self.clearLineEditFocus]) 
    497497        OWGUI.setStopper(self, applyButton, autoApplyCB, "dataChanged", self.commit) 
     
    561561            le.setFixedWidth(110) 
    562562            self.customLineEdits.append(le) 
    563             OWGUI.button(hbox, self, "CC", width=30, callback = lambda w=i: self.copyToCustom(w)) 
     563            OWGUI.toolButton(hbox, self, "CC", width=30, callback = lambda w=i: self.copyToCustom(w)) 
    564564            OWGUI.rubber(hbox) 
    565565        OWGUI.rubber(box) 
  • orange/OrangeWidgets/Data/OWFile.py

    r7149 r7867  
    7070        button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) 
    7171         
    72         self.reloadBtn = OWGUI.button(box, self, "Reload", callback = self.reload) 
     72        self.reloadBtn = OWGUI.button(box, self, "Reload", callback = self.reload, default=True) 
    7373        self.reloadBtn.setIcon(self.style().standardIcon(QStyle.SP_BrowserReload)) 
    7474        self.reloadBtn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) 
  • orange/OrangeWidgets/Data/OWImpute.py

    r6872 r7867  
    102102        OWGUI.separator(self.controlArea) 
    103103        snbox = OWGUI.widgetBox(self.controlArea, "Send data and imputer") 
    104         self.btApply = OWGUI.button(snbox, self, "Apply", callback=self.sendDataAndImputer) 
     104        self.btApply = OWGUI.button(snbox, self, "Apply", callback=self.sendDataAndImputer, default=True) 
    105105        OWGUI.checkBox(snbox, self, "autosend", "Send automatically", callback=self.enableAuto, disables = [(-1, self.btApply)]) 
    106106 
  • orange/OrangeWidgets/Data/OWPreprocess.py

    r7794 r7867  
    568568        box = OWGUI.widgetBox(self.controlArea, "Output") 
    569569        cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on any change", callback=self.commitIf) 
    570         b = OWGUI.button(box, self, "Commit", callback=self.commit) 
     570        b = OWGUI.button(box, self, "Commit", callback=self.commit, default=True) 
    571571        OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.commitIf) 
    572572         
  • orange/OrangeWidgets/Data/OWPurgeDomain.py

    r7629 r7867  
    5959         
    6060        box2 = OWGUI.widgetBox(self.controlArea, "Send") 
    61         btSend = OWGUI.button(box2, self, "Send data", callback = self.process) 
     61        btSend = OWGUI.button(box2, self, "Send data", callback = self.process, default=True) 
    6262        cbAutoSend = OWGUI.checkBox(box2, self, "autoSend", "Send automatically") 
    6363 
  • orange/OrangeWidgets/Data/OWRank.py

    r6835 r7867  
    8080        wl = OWGUI.widgetLabel(box, "Color: ") 
    8181        OWGUI.separator(box) 
    82         self.colButton = OWGUI.toolButton(box, self, self.changeColor, width=20, height=20, debuggingEnabled = 0) 
     82        self.colButton = OWGUI.toolButton(box, self, callback=self.changeColor, width=20, height=20, debuggingEnabled = 0) 
    8383        self.cbShowDistributions.disables.extend([wl, self.colButton]) 
    8484        self.cbShowDistributions.makeConsistent() 
     
    105105        OWGUI.separator(selMethBox) 
    106106 
    107         applyButton = OWGUI.button(selMethBox, self, "Commit", callback = self.apply) 
     107        applyButton = OWGUI.button(selMethBox, self, "Commit", callback = self.apply, default=True) 
    108108        autoApplyCB = OWGUI.checkBox(selMethBox, self, "autoApply", "Commit automatically") 
    109109        OWGUI.setStopper(self, applyButton, autoApplyCB, "dataChanged", self.apply) 
  • orange/OrangeWidgets/Data/OWSave.py

    r7039 r7867  
    5858 
    5959        fbox = OWGUI.widgetBox(self.controlArea, "Save") 
    60         self.save = OWGUI.button(fbox, self, "Save current data", callback = self.saveFile) 
     60        self.save = OWGUI.button(fbox, self, "Save current data", callback = self.saveFile, default=True) 
    6161        self.save.setDisabled(1) 
    6262         
  • orange/OrangeWidgets/Data/OWSelectData.py

    r7823 r7867  
    172172        self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings, sep=OWGUI.checkButtonOffsetHint(cb)), self, "purgeClasses", "Remove unused classes", callback=self.OnPurgeChange) 
    173173        OWGUI.checkBox(boxSettings, self, "updateOnChange", "Commit on change", box=None) 
    174         btnUpdate = OWGUI.button(boxSettings, self, "Commit", self.setOutput) 
     174        btnUpdate = OWGUI.button(boxSettings, self, "Commit", self.setOutput, default=True) 
    175175 
    176176        self.icons = self.createAttributeIconDict() 
  • orange/OrangeWidgets/OWGUI.py

    r7864 r7867  
    328328 
    329329def checkBox(widget, master, value, label, box=None, tooltip=None, callback=None, getwidget=None, id=None, disabled=0, labelWidth=None, disables = [], addToLayout = 1, debuggingEnabled = 1): 
    330     b = widgetBox(widget, box, orientation=None) 
     330    if box: 
     331        b = widgetBox(widget, box, orientation=None) 
     332    else: 
     333        b = widget 
    331334    wa = QCheckBox(label, b) 
    332     if addToLayout and b.layout() is not None: b.layout().addWidget(wa) 
     335    if addToLayout and b.layout() is not None: 
     336        b.layout().addWidget(wa) 
    333337 
    334338    if labelWidth: 
     
    463467 
    464468 
    465 def button(widget, master, label, callback = None, disabled=0, tooltip=None, debuggingEnabled = 1, width = None, height = None, toggleButton = False, value = "", addToLayout = 1): 
     469def button(widget, master, label, callback = None, disabled=0, tooltip=None, 
     470           debuggingEnabled = 1, width = None, height = None, toggleButton = False, 
     471           value = "", addToLayout = 1, default=False, autoDefault=False): 
    466472    btn = QPushButton(label, widget) 
    467473    if addToLayout and widget.layout() is not None: 
     
    479485        btn.setCheckable(True) 
    480486         
     487    btn.setDefault(default) 
     488    btn.setAutoDefault(autoDefault) 
     489         
    481490    if value: 
    482491        btn.setChecked(getdeepattr(master, value)) 
     
    490499    return btn 
    491500 
    492 def toolButton(widget, master, callback = None, width = None, height = None, tooltip = None, addToLayout = 1, debuggingEnabled = 1): 
     501def toolButton(widget, master, label="", callback = None, width = None, height = None, tooltip = None, addToLayout = 1, debuggingEnabled = 1): 
     502    if not isinstance(label, basestring) and hasattr(label, "__call__"): 
     503        import warnings 
     504        warnings.warn("Third positional argument to 'OWGUI.toolButton' must be a string.", DeprecationWarning) 
     505        label, callback = "", label 
     506         
    493507    btn = QToolButton(widget) 
    494508    if addToLayout and widget.layout() is not None: 
    495509        widget.layout().addWidget(btn) 
    496     if width != None: btn.setFixedWidth(width) 
    497     if height!= None: btn.setFixedHeight(height) 
    498     if tooltip != None: btn.setToolTip(tooltip) 
     510    if label: 
     511        btn.setText(label) 
     512    if width != None: 
     513        btn.setFixedWidth(width) 
     514    if height!= None: 
     515        btn.setFixedHeight(height) 
     516    if tooltip != None: 
     517        btn.setToolTip(tooltip) 
    499518    if callback: 
    500519        QObject.connect(btn, SIGNAL("clicked()"), callback) 
Note: See TracChangeset for help on using the changeset viewer.