lazylabel-gui 1.1.2__py3-none-any.whl → 1.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lazylabel/__init__.py +9 -9
- lazylabel/config/__init__.py +7 -7
- lazylabel/config/hotkeys.py +96 -57
- lazylabel/config/paths.py +40 -41
- lazylabel/config/settings.py +65 -66
- lazylabel/core/__init__.py +7 -7
- lazylabel/core/file_manager.py +122 -106
- lazylabel/core/model_manager.py +95 -97
- lazylabel/core/segment_manager.py +183 -171
- lazylabel/main.py +37 -36
- lazylabel/models/__init__.py +5 -5
- lazylabel/models/sam_model.py +200 -195
- lazylabel/ui/__init__.py +8 -8
- lazylabel/ui/control_panel.py +245 -241
- lazylabel/ui/editable_vertex.py +64 -64
- lazylabel/ui/hotkey_dialog.py +416 -384
- lazylabel/ui/hoverable_pixelmap_item.py +22 -22
- lazylabel/ui/hoverable_polygon_item.py +38 -39
- lazylabel/ui/main_window.py +1860 -1659
- lazylabel/ui/numeric_table_widget_item.py +9 -9
- lazylabel/ui/photo_viewer.py +51 -54
- lazylabel/ui/reorderable_class_table.py +60 -61
- lazylabel/ui/right_panel.py +332 -315
- lazylabel/ui/widgets/__init__.py +8 -8
- lazylabel/ui/widgets/adjustments_widget.py +108 -108
- lazylabel/ui/widgets/model_selection_widget.py +101 -94
- lazylabel/ui/widgets/settings_widget.py +113 -106
- lazylabel/ui/widgets/status_bar.py +109 -109
- lazylabel/utils/__init__.py +6 -6
- lazylabel/utils/custom_file_system_model.py +133 -132
- lazylabel/utils/utils.py +12 -12
- {lazylabel_gui-1.1.2.dist-info → lazylabel_gui-1.1.4.dist-info}/METADATA +243 -197
- lazylabel_gui-1.1.4.dist-info/RECORD +37 -0
- {lazylabel_gui-1.1.2.dist-info → lazylabel_gui-1.1.4.dist-info}/licenses/LICENSE +21 -21
- lazylabel_gui-1.1.2.dist-info/RECORD +0 -37
- {lazylabel_gui-1.1.2.dist-info → lazylabel_gui-1.1.4.dist-info}/WHEEL +0 -0
- {lazylabel_gui-1.1.2.dist-info → lazylabel_gui-1.1.4.dist-info}/entry_points.txt +0 -0
- {lazylabel_gui-1.1.2.dist-info → lazylabel_gui-1.1.4.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,9 @@
|
|
1
|
-
from PyQt6.QtWidgets import QTableWidgetItem
|
2
|
-
|
3
|
-
|
4
|
-
class NumericTableWidgetItem(QTableWidgetItem):
|
5
|
-
def __lt__(self, other):
|
6
|
-
try:
|
7
|
-
return int(self.text()) < int(other.text())
|
8
|
-
except (ValueError, TypeError):
|
9
|
-
return super().__lt__(other)
|
1
|
+
from PyQt6.QtWidgets import QTableWidgetItem
|
2
|
+
|
3
|
+
|
4
|
+
class NumericTableWidgetItem(QTableWidgetItem):
|
5
|
+
def __lt__(self, other):
|
6
|
+
try:
|
7
|
+
return int(self.text()) < int(other.text())
|
8
|
+
except (ValueError, TypeError):
|
9
|
+
return super().__lt__(other)
|
lazylabel/ui/photo_viewer.py
CHANGED
@@ -1,54 +1,51 @@
|
|
1
|
-
from PyQt6.QtCore import
|
2
|
-
from PyQt6.QtGui import
|
3
|
-
from PyQt6.QtWidgets import
|
4
|
-
|
5
|
-
|
6
|
-
class PhotoViewer(QGraphicsView):
|
7
|
-
def __init__(self, parent=None):
|
8
|
-
super().__init__(parent)
|
9
|
-
self._scene = QGraphicsScene(self)
|
10
|
-
self._pixmap_item = QGraphicsPixmapItem()
|
11
|
-
self._scene.addItem(self._pixmap_item)
|
12
|
-
self.setScene(self._scene)
|
13
|
-
|
14
|
-
self.setTransformationAnchor(QGraphicsView.ViewportAnchor.AnchorUnderMouse)
|
15
|
-
self.setResizeAnchor(QGraphicsView.ViewportAnchor.AnchorViewCenter)
|
16
|
-
self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
17
|
-
self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
18
|
-
self.setDragMode(QGraphicsView.DragMode.NoDrag)
|
19
|
-
|
20
|
-
def fitInView(self, scale=True):
|
21
|
-
rect = QRectF(self._pixmap_item.pixmap().rect())
|
22
|
-
if not rect.isNull():
|
23
|
-
self.setSceneRect(rect)
|
24
|
-
self.resetTransform()
|
25
|
-
viewrect = self.viewport().rect()
|
26
|
-
scenerect = self.transform().mapRect(rect)
|
27
|
-
factor = min(
|
28
|
-
viewrect.width() / scenerect.width(),
|
29
|
-
viewrect.height() / scenerect.height(),
|
30
|
-
)
|
31
|
-
self.scale(factor, factor)
|
32
|
-
self.centerOn(self._pixmap_item)
|
33
|
-
|
34
|
-
def set_photo(self, pixmap):
|
35
|
-
if pixmap and not pixmap.isNull():
|
36
|
-
self._pixmap_item.setPixmap(pixmap)
|
37
|
-
self.fitInView()
|
38
|
-
else:
|
39
|
-
self._pixmap_item.setPixmap(QPixmap())
|
40
|
-
|
41
|
-
def set_cursor(self, cursor_shape):
|
42
|
-
self.viewport().setCursor(QCursor(cursor_shape))
|
43
|
-
|
44
|
-
def resizeEvent(self, event):
|
45
|
-
self.fitInView()
|
46
|
-
super().resizeEvent(event)
|
47
|
-
|
48
|
-
def wheelEvent(self, event):
|
49
|
-
if not self._pixmap_item.pixmap().isNull():
|
50
|
-
if event.angleDelta().y() > 0
|
51
|
-
|
52
|
-
else:
|
53
|
-
factor = 0.8
|
54
|
-
self.scale(factor, factor)
|
1
|
+
from PyQt6.QtCore import QRectF, Qt
|
2
|
+
from PyQt6.QtGui import QCursor, QPixmap
|
3
|
+
from PyQt6.QtWidgets import QGraphicsPixmapItem, QGraphicsScene, QGraphicsView
|
4
|
+
|
5
|
+
|
6
|
+
class PhotoViewer(QGraphicsView):
|
7
|
+
def __init__(self, parent=None):
|
8
|
+
super().__init__(parent)
|
9
|
+
self._scene = QGraphicsScene(self)
|
10
|
+
self._pixmap_item = QGraphicsPixmapItem()
|
11
|
+
self._scene.addItem(self._pixmap_item)
|
12
|
+
self.setScene(self._scene)
|
13
|
+
|
14
|
+
self.setTransformationAnchor(QGraphicsView.ViewportAnchor.AnchorUnderMouse)
|
15
|
+
self.setResizeAnchor(QGraphicsView.ViewportAnchor.AnchorViewCenter)
|
16
|
+
self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
17
|
+
self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
18
|
+
self.setDragMode(QGraphicsView.DragMode.NoDrag)
|
19
|
+
|
20
|
+
def fitInView(self, scale=True):
|
21
|
+
rect = QRectF(self._pixmap_item.pixmap().rect())
|
22
|
+
if not rect.isNull():
|
23
|
+
self.setSceneRect(rect)
|
24
|
+
self.resetTransform()
|
25
|
+
viewrect = self.viewport().rect()
|
26
|
+
scenerect = self.transform().mapRect(rect)
|
27
|
+
factor = min(
|
28
|
+
viewrect.width() / scenerect.width(),
|
29
|
+
viewrect.height() / scenerect.height(),
|
30
|
+
)
|
31
|
+
self.scale(factor, factor)
|
32
|
+
self.centerOn(self._pixmap_item)
|
33
|
+
|
34
|
+
def set_photo(self, pixmap):
|
35
|
+
if pixmap and not pixmap.isNull():
|
36
|
+
self._pixmap_item.setPixmap(pixmap)
|
37
|
+
self.fitInView()
|
38
|
+
else:
|
39
|
+
self._pixmap_item.setPixmap(QPixmap())
|
40
|
+
|
41
|
+
def set_cursor(self, cursor_shape):
|
42
|
+
self.viewport().setCursor(QCursor(cursor_shape))
|
43
|
+
|
44
|
+
def resizeEvent(self, event):
|
45
|
+
self.fitInView()
|
46
|
+
super().resizeEvent(event)
|
47
|
+
|
48
|
+
def wheelEvent(self, event):
|
49
|
+
if not self._pixmap_item.pixmap().isNull():
|
50
|
+
factor = 1.25 if event.angleDelta().y() > 0 else 0.8
|
51
|
+
self.scale(factor, factor)
|
@@ -1,61 +1,60 @@
|
|
1
|
-
from PyQt6.QtWidgets import
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
self.
|
9
|
-
self.
|
10
|
-
self.
|
11
|
-
self.
|
12
|
-
self.
|
13
|
-
self.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
drop_row
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
super().dropEvent(event)
|
1
|
+
from PyQt6.QtWidgets import QAbstractItemView, QTableWidget
|
2
|
+
|
3
|
+
|
4
|
+
class ReorderableClassTable(QTableWidget):
|
5
|
+
def __init__(self, *args, **kwargs):
|
6
|
+
super().__init__(*args, **kwargs)
|
7
|
+
self.setDragEnabled(True)
|
8
|
+
self.setAcceptDrops(True)
|
9
|
+
self.setDropIndicatorShown(True)
|
10
|
+
self.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
|
11
|
+
self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
|
12
|
+
self.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove)
|
13
|
+
self.scroll_margin = 40
|
14
|
+
|
15
|
+
def dragMoveEvent(self, event):
|
16
|
+
pos = event.position().toPoint()
|
17
|
+
rect = self.viewport().rect()
|
18
|
+
|
19
|
+
if pos.y() < rect.top() + self.scroll_margin:
|
20
|
+
self.verticalScrollBar().setValue(self.verticalScrollBar().value() - 1)
|
21
|
+
elif pos.y() > rect.bottom() - self.scroll_margin:
|
22
|
+
self.verticalScrollBar().setValue(self.verticalScrollBar().value() + 1)
|
23
|
+
|
24
|
+
super().dragMoveEvent(event)
|
25
|
+
|
26
|
+
def dropEvent(self, event):
|
27
|
+
if not event.isAccepted() and event.source() == self:
|
28
|
+
drop_row = self.rowAt(event.position().toPoint().y())
|
29
|
+
if drop_row < 0:
|
30
|
+
drop_row = self.rowCount()
|
31
|
+
|
32
|
+
selected_rows = sorted(
|
33
|
+
{index.row() for index in self.selectedIndexes()}, reverse=True
|
34
|
+
)
|
35
|
+
|
36
|
+
dragged_rows_data = []
|
37
|
+
for row in selected_rows:
|
38
|
+
# Take all items from the row
|
39
|
+
row_data = [
|
40
|
+
self.takeItem(row, col) for col in range(self.columnCount())
|
41
|
+
]
|
42
|
+
dragged_rows_data.insert(0, row_data)
|
43
|
+
# Then remove the row itself
|
44
|
+
self.removeRow(row)
|
45
|
+
|
46
|
+
# Adjust drop row if it was shifted by the removal
|
47
|
+
for row in selected_rows:
|
48
|
+
if row < drop_row:
|
49
|
+
drop_row -= 1
|
50
|
+
|
51
|
+
# Insert rows and their items at the new location
|
52
|
+
for row_data in dragged_rows_data:
|
53
|
+
self.insertRow(drop_row)
|
54
|
+
for col, item in enumerate(row_data):
|
55
|
+
self.setItem(drop_row, col, item)
|
56
|
+
self.selectRow(drop_row)
|
57
|
+
drop_row += 1
|
58
|
+
|
59
|
+
event.accept()
|
60
|
+
super().dropEvent(event)
|