Skip to content

Commit 3e3cd4b

Browse files
committed
Scoring Sheet Viewer: Cosmetic changes (shorter slider, lint)
1 parent d12c8cd commit 3e3cd4b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Orange/widgets/visualize/owscoringsheetviewer.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
QToolTip,
1515
QStyleOptionSlider,
1616
)
17-
from AnyQt.QtCore import Qt, QRect
17+
from AnyQt.QtCore import Qt, QRect, pyqtSignal as Signal
1818
from AnyQt.QtGui import QPainter, QFontMetrics, QPalette
1919

2020
from Orange.widgets import gui
@@ -31,6 +31,8 @@
3131

3232

3333
class ScoringSheetTable(QTableWidget):
34+
state_changed = Signal(int)
35+
3436
def __init__(self, main_widget, parent=None):
3537
"""
3638
Initialize the ScoringSheetTable.
@@ -88,7 +90,7 @@ def handle_item_changed(self, item):
8890
It updates the slider value depending on the collected points.
8991
"""
9092
if item.column() == 2:
91-
self.main_widget._update_slider_value()
93+
self.state_changed.emit(item.row())
9294

9395

9496
class CustomSliderStyle(QProxyStyle):
@@ -101,7 +103,8 @@ class CustomSliderStyle(QProxyStyle):
101103

102104
def drawComplexControl(self, cc, opt, painter, widget=None):
103105
if cc != QStyle.CC_Slider:
104-
return super().drawComplexControl(cc, opt, painter, widget)
106+
super().drawComplexControl(cc, opt, painter, widget)
107+
return
105108

106109
# Make a copy of the style option and remove the handle subcontrol.
107110
slider_opt = QStyleOptionSlider(opt)
@@ -115,9 +118,11 @@ def drawComplexControl(self, cc, opt, painter, widget=None):
115118
painter.save()
116119
painter.setPen(Qt.NoPen)
117120
painter.setBrush(QPalette().color(QPalette.WindowText))
121+
h = handle_rect.height()
118122
painter.drawRoundedRect(
119123
QRect(
120-
handle_rect.center().x() - 1, handle_rect.y(), 3, handle_rect.height()
124+
handle_rect.center().x() - 2, handle_rect.y() + int(0.2 * h),
125+
4, int(0.6 * h)
121126
),
122127
3,
123128
3,
@@ -303,7 +308,8 @@ def handle_hover_event(self, pos):
303308
probability = self.probabilities[value]
304309
tooltip = str(
305310
f"<b>{self.target_class}</b>\n "
306-
f"<hr style='margin: 0px; padding: 0px; border: 0px; height: 1px; background-color: #000000'>"
311+
"<hr style='margin: 0px; padding: 0px; border: 0px; "
312+
"height: 1px; background-color: #000000'>"
307313
f"<b>Points:</b> {int(points)}<br>"
308314
f"<b>Probability:</b> {probability:.1f}%"
309315
)
@@ -402,6 +408,7 @@ def _setup_gui(self):
402408

403409
self.coefficient_table = ScoringSheetTable(main_widget=self, parent=self)
404410
gui.widgetBox(self.mainArea).layout().addWidget(self.coefficient_table)
411+
self.coefficient_table.state_changed.connect(self._update_slider_value)
405412

406413
self.risk_slider = RiskSlider([], [], self)
407414
gui.widgetBox(self.mainArea).layout().addWidget(self.risk_slider)

0 commit comments

Comments
 (0)