Skip to content

Commit 52ea6a2

Browse files
committed
OWConfusionMatrix: Nicer layout
1 parent dd60435 commit 52ea6a2

File tree

1 file changed

+30
-32
lines changed

1 file changed

+30
-32
lines changed

Orange/widgets/evaluate/owconfusionmatrix.py

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@
33
from math import isnan, isinf
44
import unicodedata
55

6-
from AnyQt.QtWidgets import (
7-
QGridLayout, QTableView,QHeaderView, QStyledItemDelegate
8-
)
9-
from AnyQt.QtGui import (
10-
QFont, QBrush, QColor, QStandardItemModel, QStandardItem
11-
)
12-
from AnyQt.QtCore import (
13-
Qt, QSize, QItemSelectionModel, QItemSelection, QT_VERSION
14-
)
6+
from AnyQt.QtWidgets import QTableView, QHeaderView, QStyledItemDelegate, \
7+
QSizePolicy
8+
from AnyQt.QtGui import QFont, QBrush, QColor, QStandardItemModel, QStandardItem
9+
from AnyQt.QtCore import Qt, QSize, QItemSelectionModel, QItemSelection
1510
import numpy as np
1611
import sklearn.metrics as skl_metrics
1712

@@ -128,37 +123,31 @@ def __init__(self):
128123
self.learners = []
129124
self.headers = []
130125

131-
box = gui.vBox(self.controlArea, "Learners")
132-
133126
self.learners_box = gui.listBox(
134-
box, self, "selected_learner", "learners",
127+
self.controlArea, self, "selected_learner", "learners", box=True,
135128
callback=self._learner_changed
136129
)
137-
box = gui.vBox(self.controlArea, "Show")
138-
139-
gui.comboBox(box, self, "selected_quantity", items=self.quantities,
140-
callback=self._update)
141-
142-
box = gui.vBox(self.controlArea, "Select")
143-
144-
gui.button(box, self, "Select Correct",
145-
callback=self.select_correct, autoDefault=False)
146-
gui.button(box, self, "Select Misclassified",
147-
callback=self.select_wrong, autoDefault=False)
148-
gui.button(box, self, "Clear Selection",
149-
callback=self.select_none, autoDefault=False)
150130

151-
self.outputbox = box = gui.vBox(self.controlArea, "Output")
131+
self.outputbox = gui.vBox(self.controlArea, "Output")
132+
box = gui.hBox(self.outputbox)
152133
gui.checkBox(box, self, "append_predictions",
153134
"Predictions", callback=self._invalidate)
154135
gui.checkBox(box, self, "append_probabilities",
155136
"Probabilities",
156137
callback=self._invalidate)
157138

158-
gui.auto_commit(self.controlArea, self, "autocommit",
159-
"Send Selected", "Send Automatically")
139+
gui.auto_commit(self.outputbox, self, "autocommit",
140+
"Send Selected", "Send Automatically", box=False)
160141

161-
grid = QGridLayout()
142+
self.mainArea.layout().setContentsMargins(0, 0, 0, 0)
143+
144+
box = gui.vBox(self.mainArea, box=True)
145+
146+
sbox = gui.hBox(box)
147+
gui.rubber(sbox)
148+
gui.comboBox(sbox, self, "selected_quantity",
149+
items=self.quantities, label="Show: ",
150+
orientation=Qt.Horizontal, callback=self._update)
162151

163152
self.tablemodel = QStandardItemModel(self)
164153
view = self.tableview = QTableView(
@@ -170,13 +159,22 @@ def __init__(self):
170159
view.selectionModel().selectionChanged.connect(self._invalidate)
171160
view.setShowGrid(False)
172161
view.setItemDelegate(BorderedItemDelegate(Qt.white))
162+
view.setSizePolicy(QSizePolicy.MinimumExpanding,
163+
QSizePolicy.MinimumExpanding)
173164
view.clicked.connect(self.cell_clicked)
174-
grid.addWidget(view, 0, 0)
175-
self.mainArea.layout().addLayout(grid)
165+
box.layout().addWidget(view)
166+
167+
selbox = gui.hBox(box)
168+
gui.button(selbox, self, "Select Correct",
169+
callback=self.select_correct, autoDefault=False)
170+
gui.button(selbox, self, "Select Misclassified",
171+
callback=self.select_wrong, autoDefault=False)
172+
gui.button(selbox, self, "Clear Selection",
173+
callback=self.select_none, autoDefault=False)
176174

177175
def sizeHint(self):
178176
"""Initial size"""
179-
return QSize(750, 490)
177+
return QSize(750, 340)
180178

181179
def _item(self, i, j):
182180
return self.tablemodel.item(i, j) or QStandardItem()

0 commit comments

Comments
 (0)