|
14 | 14 | QGraphicsEllipseItem, QGraphicsLinearLayout, QGridLayout, QLabel, QFrame, |
15 | 15 | QSizePolicy |
16 | 16 | ) |
17 | | -from AnyQt.QtGui import QColor, QPainter, QFont, QPen, QBrush |
| 17 | +from AnyQt.QtGui import QColor, QPainter, QFont, QPen, QBrush, QFontMetrics |
18 | 18 | from AnyQt.QtCore import Qt, QRectF, QSize, QPropertyAnimation, QObject, \ |
19 | 19 | pyqtProperty |
20 | 20 |
|
@@ -784,7 +784,7 @@ def is_resizing(self): |
784 | 784 | return self._is_resizing |
785 | 785 |
|
786 | 786 | def sizeHint(self): |
787 | | - return QSize(400, 200) |
| 787 | + return QSize(500, 200) |
788 | 788 |
|
789 | 789 | class FixedSizeGraphicsView(_GraphicsView): |
790 | 790 | def __init__(self, scene, parent): |
@@ -949,11 +949,20 @@ def update_scene(self): |
949 | 949 | attr_inds, attributes = zip(*self.get_ordered_attributes()[:n_attrs]) |
950 | 950 | self.Outputs.features.send(AttributeList(attributes)) |
951 | 951 |
|
952 | | - name_items = [QGraphicsTextItem(attr.name) for attr in attributes] |
953 | 952 | point_text = QGraphicsTextItem("Points") |
| 953 | + metric = QFontMetrics(point_text.font()) |
| 954 | + |
| 955 | + def text_item(text): |
| 956 | + elided_text = metric.elidedText(text, Qt.ElideRight, 200) |
| 957 | + item = QGraphicsTextItem(elided_text) |
| 958 | + item.setToolTip(text) |
| 959 | + return item |
| 960 | + |
| 961 | + name_items = [text_item(attr.name) for attr in attributes] |
| 962 | + |
954 | 963 | probs_text = QGraphicsTextItem("Probabilities (%)") |
955 | 964 | all_items = name_items + [point_text, probs_text] |
956 | | - name_offset = -max(t.boundingRect().width() for t in all_items) - 10 |
| 965 | + name_offset = -max(t.boundingRect().width() for t in all_items) - 30 |
957 | 966 | w = self.view.viewport().rect().width() |
958 | 967 | max_width = w + name_offset - 30 |
959 | 968 |
|
|
0 commit comments