1111from AnyQt .QtWidgets import (
1212 QGraphicsWidget , QGraphicsObject , QGraphicsLinearLayout , QGraphicsPathItem ,
1313 QGraphicsScene , QGraphicsView , QGridLayout , QFormLayout , QSizePolicy ,
14- QGraphicsSimpleTextItem ,
15- QGraphicsLayoutItem , QAction ,
14+ QGraphicsSimpleTextItem , QGraphicsLayoutItem , QAction , QComboBox
1615)
1716from AnyQt .QtGui import (
1817 QTransform , QPainterPath , QPainterPathStroker , QColor , QBrush , QPen ,
3231 leaves , prune , top_clusters
3332
3433from Orange .widgets import widget , gui , settings
35- from Orange .widgets .utils import colorpalette , itemmodels
34+ from Orange .widgets .utils import colorpalette , itemmodels , combobox
3635from Orange .widgets .utils .annotated_data import (create_annotated_table ,
3736 ANNOTATED_DATA_SIGNAL_NAME )
3837from Orange .widgets .widget import Input , Output , Msg
@@ -825,9 +824,18 @@ def __init__(self):
825824
826825 model = itemmodels .VariableListModel ()
827826 model [:] = self .basic_annotations
828- self .label_cb = gui .comboBox (
829- self .controlArea , self , "annotation" , box = "Annotation" ,
830- model = model , callback = self ._update_labels , contentsLength = 12 )
827+
828+ box = gui .widgetBox (self .controlArea , "Annotations" )
829+ self .label_cb = combobox .ComboBoxSearch (
830+ minimumContentsLength = 14 ,
831+ sizeAdjustPolicy = QComboBox .AdjustToMinimumContentsLengthWithIcon
832+ )
833+ box .layout ().addWidget (self .label_cb )
834+ self .label_cb .activated [int ].connect (
835+ lambda idx : setattr (self , "annotation" , model [idx ])
836+ )
837+ self .label_cb .activated .connect (self ._update_labels )
838+ self .label_cb .setModel (model )
831839
832840 box = gui .radioButtons (
833841 self .controlArea , self , "pruning" , box = "Pruning" ,
@@ -1052,6 +1060,7 @@ def _set_items(self, items, axis=1):
10521060 else :
10531061 self .annotation = "Enumeration"
10541062 self .openContext (items .domain )
1063+ self .label_cb .setCurrentIndex (model .indexOf (self .annotation ))
10551064 else :
10561065 name_option = bool (
10571066 items is not None and (
@@ -1711,7 +1720,7 @@ def clusters_at_height(root, height):
17111720 return cluster_list
17121721
17131722
1714- def main (argv = None ):
1723+ def main (argv = None ): # pragma: no cover
17151724 from AnyQt .QtWidgets import QApplication
17161725 import sip
17171726 import Orange .distance as distance
@@ -1737,12 +1746,13 @@ def main(argv=None):
17371746 rval = app .exec_ ()
17381747 w .set_distances (None )
17391748 w .handleNewSignals ()
1740-
1749+ w . saveSettings ()
17411750 w .onDeleteWidget ()
17421751 sip .delete (w )
17431752 del w
17441753 app .processEvents ()
17451754 return rval
17461755
1747- if __name__ == "__main__" :
1756+
1757+ if __name__ == "__main__" : # pragma: no cover
17481758 sys .exit (main ())
0 commit comments