Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Searchable combo boxes in all visualize widgets #4563

Merged
merged 9 commits into from
Apr 10, 2020
1 change: 1 addition & 0 deletions Orange/widgets/visualize/owdistributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def __init__(self):
box = gui.vBox(self.controlArea, "Columns")
gui.comboBox(
box, self, "cvar", label="Split by", orientation=Qt.Horizontal,
searchable=True,
model=DomainModel(placeholder="(None)",
valid_types=(DiscreteVariable), ),
callback=self._on_cvar_changed, contentsLength=18)
Expand Down
2 changes: 1 addition & 1 deletion Orange/widgets/visualize/owheatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _(idx, cb=cb):
valid_types=(Orange.data.DiscreteVariable,),
parent=self,
)
self.row_split_cb = cb = ComboBox(
self.row_split_cb = cb = ComboBoxSearch(
enabled=not self.merge_kmeans,
sizeAdjustPolicy=ComboBox.AdjustToMinimumContentsLengthWithIcon,
minimumContentsLength=14,
Expand Down
2 changes: 2 additions & 0 deletions Orange/widgets/visualize/owmosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ def __init__(self):
gui.comboBox(
box, self, value="variable{}".format(i),
orientation=Qt.Horizontal, contentsLength=12,
searchable=True,
callback=self.attr_changed,
model=self.model_1 if i == 1 else self.model_234)
for i in range(1, 5)]
Expand All @@ -355,6 +356,7 @@ def __init__(self):
self.cb_attr_color = gui.comboBox(
box2, self, value="variable_color",
orientation=Qt.Horizontal, contentsLength=12, labelWidth=50,
searchable=True,
callback=self.set_color_data, model=self.color_model)
self.bar_button = gui.checkBox(
box2, self, 'use_boxes', label='Compare with total',
Expand Down
2 changes: 1 addition & 1 deletion Orange/widgets/visualize/ownomogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def __init__(self):
box = gui.vBox(self.controlArea, "Target class")
self.class_combo = gui.comboBox(
box, self, "target_class_index", callback=self._class_combo_changed,
contentsLength=12)
contentsLength=12, searchable=True)
self.norm_check = gui.checkBox(
box, self, "normalize_probabilities", "Normalize probabilities",
hidden=True, callback=self.update_scene,
Expand Down
1 change: 1 addition & 0 deletions Orange/widgets/visualize/owpythagorastree.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def __init__(self):
self.target_class_combo = gui.comboBox(
box_display, self, 'target_class_index', label='Target class',
orientation=Qt.Horizontal, items=[], contentsLength=8,
searchable=True,
callback=self.update_colors)
self.size_calc_combo = gui.comboBox(
box_display, self, 'size_calc_idx', label='Size',
Expand Down
1 change: 1 addition & 0 deletions Orange/widgets/visualize/owpythagoreanforest.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def __init__(self):
self.ui_target_class_combo = gui.comboBox(
box_display, self, 'target_class_index', label='Target class',
orientation=Qt.Horizontal, items=[], contentsLength=8,
searchable=True
) # type: gui.OrangeComboBox
self.ui_size_calc_combo = gui.comboBox(
box_display, self, 'size_calc_idx', label='Size',
Expand Down
4 changes: 2 additions & 2 deletions Orange/widgets/visualize/owsieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def __init__(self):
self.domain_model = DomainModel(valid_types=DomainModel.PRIMITIVE)
combo_args = dict(
widget=self.attr_box, master=self, contentsLength=12,
callback=self.attr_changed, sendSelectedValue=True,
model=self.domain_model)
searchable=True, sendSelectedValue=True,
callback=self.attr_changed, model=self.domain_model)
fixed_size = (QSizePolicy.Fixed, QSizePolicy.Fixed)
gui.comboBox(value="attr_x", **combo_args)
gui.widgetLabel(self.attr_box, "\u2715", sizePolicy=fixed_size)
Expand Down
2 changes: 1 addition & 1 deletion Orange/widgets/visualize/owsilhouetteplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def __init__(self):
box = gui.vBox(self.controlArea, "Cluster Label")
self.cluster_var_cb = gui.comboBox(
box, self, "cluster_var_idx", contentsLength=14, addSpace=4,
callback=self._invalidate_scores
searchable=True, callback=self._invalidate_scores
)
gui.checkBox(
box, self, "group_by_cluster", "Group by cluster",
Expand Down
4 changes: 2 additions & 2 deletions Orange/widgets/visualize/owtreeviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
)
from AnyQt.QtGui import QColor, QBrush, QPen, QFontMetrics
from AnyQt.QtCore import Qt, QPointF, QSizeF, QRectF
from orangewidget.utils.combobox import ComboBoxSearch

from Orange.base import TreeModel, SklModel
from Orange.widgets.utils.signals import Input, Output
Expand All @@ -18,7 +19,6 @@

from Orange.widgets.settings import ContextSetting, ClassValuesContextHandler, \
Setting
from Orange.widgets import gui
from Orange.widgets.utils.annotated_data import (create_annotated_table,
ANNOTATED_DATA_SIGNAL_NAME)
from Orange.widgets.visualize.utils.tree.skltreeadapter import SklTreeAdapter
Expand Down Expand Up @@ -190,7 +190,7 @@ def __init__(self):
self.tree_adapter = None

self.color_label = QLabel("Target class: ")
combo = self.color_combo = gui.OrangeComboBox()
combo = self.color_combo = ComboBoxSearch()
combo.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)
combo.setSizeAdjustPolicy(
QComboBox.AdjustToMinimumContentsLengthWithIcon)
Expand Down
4 changes: 4 additions & 0 deletions Orange/widgets/visualize/tests/test_owpythagorastree.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,7 @@ def test_changing_data_restores_depth_from_previous_settings(self):
# The domain is still the same, so restore the depth limit from before
self.send_signal(self.widget.Inputs.tree, forest.trees[1])
self.assertEqual(self.widget.ptree._depth_limit, 1)


if __name__ == "__main__":
unittest.main()