Repository: biolab/orange3

Issue:
GUI: Long labels fall out of controlArea
<!-- 
Thanks for taking the time to report a bug!
If you're raising an issue about an add-on (i.e., installed via Options > Add-ons), raise an issue in the relevant add-on's issue tracker instead. See: https://github.com/biolab?q=orange3
To fix the bug, we need to be able to reproduce it. Please answer the following questions to the best of your ability.
-->


**What's wrong?**
<!-- Be specific, clear, and concise. Include screenshots if relevant. -->
<!-- If you're getting an error message, copy it, and enclose it with three backticks (```). -->
In case of large labels for sliders, info text and such, labels fall out view in controlArea.

Here's an example from Distributions
<img width="307" alt="Screen Shot 2021-10-29 at 14 15 40" src="https://user-images.githubusercontent.com/12524972/139432818-83fd9261-5f00-44aa-ac8f-93ae25a2bb85.png">



**How can we reproduce the problem?** 
Datasets (HDI) - Distributions (show GNI attribute)


**What's your environment?**
<!-- To find your Orange version, see "Help → About → Version" or `Orange.version.full_version` in code -->
- Operating system: OSX
- Orange version: 3.30.1
- How you installed Orange: dmg



Discussion:
Doesn't it bother you that the left value is completely missing? :)
No.
Btw, the number is not showing the max value, it is showing the current value on the slider.

Resolving patch:
diff --git a/Orange/widgets/visualize/owdistributions.py b/Orange/widgets/visualize/owdistributions.py
--- a/Orange/widgets/visualize/owdistributions.py
+++ b/Orange/widgets/visualize/owdistributions.py
@@ -6,7 +6,8 @@
 from scipy.stats import norm, rayleigh, beta, gamma, pareto, expon
 
 from AnyQt.QtWidgets import QGraphicsRectItem
-from AnyQt.QtGui import QColor, QPen, QBrush, QPainter, QPalette, QPolygonF
+from AnyQt.QtGui import QColor, QPen, QBrush, QPainter, QPalette, QPolygonF, \
+    QFontMetrics
 from AnyQt.QtCore import Qt, QRectF, QPointF, pyqtSignal as Signal
 from orangewidget.utils.listview import ListViewSearch
 import pyqtgraph as pg
@@ -498,14 +499,18 @@ def _set_smoothing_visibility(self):
 
     def _set_bin_width_slider_label(self):
         if self.number_of_bins < len(self.binnings):
-            text = reduce(
-                lambda s, rep: s.replace(*rep),
-                short_time_units.items(),
+            text = self._short_text(
                 self.binnings[self.number_of_bins].width_label)
         else:
             text = ""
         self.bin_width_label.setText(text)
 
+    @staticmethod
+    def _short_text(label):
+        return reduce(
+            lambda s, rep: s.replace(*rep),
+            short_time_units.items(), label)
+
     def _on_show_probabilities_changed(self):
         label = self.controls.fitted_distribution.label
         if self.show_probs:
@@ -879,12 +884,16 @@ def recompute_binnings(self):
             if np.any(np.isfinite(column)):
                 if self.var.is_time:
                     self.binnings = time_binnings(column, min_unique=5)
-                    self.bin_width_label.setFixedWidth(45)
                 else:
                     self.binnings = decimal_binnings(
                         column, min_width=self.min_var_resolution(self.var),
                         add_unique=10, min_unique=5)
-                    self.bin_width_label.setFixedWidth(35)
+                fm = QFontMetrics(self.font())
+                width = max(fm.size(Qt.TextSingleLine,
+                                    self._short_text(binning.width_label)
+                                    ).width()
+                            for binning in self.binnings)
+                self.bin_width_label.setFixedWidth(width)
                 max_bins = len(self.binnings) - 1
         else:
             self.binnings = []
diff --git a/Orange/widgets/visualize/owpythagorastree.py b/Orange/widgets/visualize/owpythagorastree.py
--- a/Orange/widgets/visualize/owpythagorastree.py
+++ b/Orange/widgets/visualize/owpythagorastree.py
@@ -96,9 +96,11 @@ def __init__(self):
 
         # Display settings area
         box_display = gui.widgetBox(self.controlArea, 'Display Settings')
+        # maxValue is set to a wide three-digit number to probably ensure the
+        # proper label width. The maximum is later set to match the tree depth
         self.depth_slider = gui.hSlider(
             box_display, self, 'depth_limit', label='Depth', ticks=False,
-            callback=self.update_depth)
+            maxValue=900, callback=self.update_depth)
         self.target_class_combo = gui.comboBox(
             box_display, self, 'target_class_index', label='Target class',
             orientation=Qt.Horizontal, items=[], contentsLength=8,
diff --git a/Orange/widgets/visualize/owpythagoreanforest.py b/Orange/widgets/visualize/owpythagoreanforest.py
--- a/Orange/widgets/visualize/owpythagoreanforest.py
+++ b/Orange/widgets/visualize/owpythagoreanforest.py
@@ -213,8 +213,11 @@ def __init__(self):
 
         # Display controls area
         box_display = gui.widgetBox(self.controlArea, 'Display')
+        # maxValue is set to a wide three-digit number to probably ensure the
+        # proper label width. The maximum is later set to match the tree depth
         self.ui_depth_slider = gui.hSlider(
             box_display, self, 'depth_limit', label='Depth', ticks=False,
+            maxValue=900
         )  # type: QSlider
         self.ui_target_class_combo = gui.comboBox(
             box_display, self, 'target_class_index', label='Target class',


Test patch: