lazylabel-gui 1.0.6__tar.gz → 1.0.8__tar.gz
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_gui-1.0.6 → lazylabel_gui-1.0.8}/PKG-INFO +2 -2
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/README.md +1 -1
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/pyproject.toml +1 -1
- lazylabel_gui-1.0.8/src/lazylabel/controls.py +261 -0
- lazylabel_gui-1.0.8/src/lazylabel/custom_file_system_model.py +72 -0
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/src/lazylabel/editable_vertex.py +7 -3
- lazylabel_gui-1.0.8/src/lazylabel/hoverable_pixelmap_item.py +22 -0
- lazylabel_gui-1.0.8/src/lazylabel/main.py +1258 -0
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/src/lazylabel/numeric_table_widget_item.py +0 -1
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/src/lazylabel/photo_viewer.py +6 -3
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/src/lazylabel/reorderable_class_table.py +10 -7
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/src/lazylabel/utils.py +2 -2
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/src/lazylabel_gui.egg-info/PKG-INFO +2 -2
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/src/lazylabel_gui.egg-info/SOURCES.txt +1 -0
- lazylabel_gui-1.0.6/src/lazylabel/controls.py +0 -108
- lazylabel_gui-1.0.6/src/lazylabel/custom_file_system_model.py +0 -57
- lazylabel_gui-1.0.6/src/lazylabel/main.py +0 -794
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/LICENSE +0 -0
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/setup.cfg +0 -0
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/src/lazylabel/hoverable_polygon_item.py +0 -0
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/src/lazylabel/sam_model.py +0 -0
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/src/lazylabel_gui.egg-info/dependency_links.txt +0 -0
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/src/lazylabel_gui.egg-info/entry_points.txt +0 -0
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/src/lazylabel_gui.egg-info/requires.txt +0 -0
- {lazylabel_gui-1.0.6 → lazylabel_gui-1.0.8}/src/lazylabel_gui.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: lazylabel-gui
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.8
|
4
4
|
Summary: An image segmentation GUI for generating mask tensors.
|
5
5
|
Author-email: "Deniz N. Cakan" <deniz.n.cakan@gmail.com>
|
6
6
|
License: MIT License
|
@@ -48,7 +48,7 @@ Requires-Dist: tqdm>=4.67.1
|
|
48
48
|
Dynamic: license-file
|
49
49
|
|
50
50
|
# <img src="https://raw.githubusercontent.com/dnzckn/LazyLabel/main/src/lazylabel/demo_pictures/logo2.png" alt="LazyLabel Logo" style="height:60px; vertical-align:middle;" /> <img src="https://raw.githubusercontent.com/dnzckn/LazyLabel/main/src/lazylabel/demo_pictures/logo_black.png" alt="LazyLabel Cursive" style="height:60px; vertical-align:middle;" />
|
51
|
-
LazyLabel is an intuitive, AI-assisted image segmentation tool. It uses Meta's Segment Anything Model (SAM) for quick, precise mask generation, alongside advanced polygon editing for fine-tuned control. Outputs are saved in a clean, one-hot encoded format for easy machine learning integration.
|
51
|
+
LazyLabel is an intuitive, AI-assisted image segmentation tool. It uses Meta's Segment Anything Model (SAM) for quick, precise mask generation, alongside advanced polygon editing for fine-tuned control. Outputs are saved in a clean, one-hot encoded `.npz` format for easy machine learning integration and in YOLO `.txt` format.
|
52
52
|
|
53
53
|
Inspired by [LabelMe](https://github.com/wkentaro/labelme?tab=readme-ov-file#installation) and [Segment-Anything-UI](https://github.com/branislavhesko/segment-anything-ui/tree/main).
|
54
54
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# <img src="https://raw.githubusercontent.com/dnzckn/LazyLabel/main/src/lazylabel/demo_pictures/logo2.png" alt="LazyLabel Logo" style="height:60px; vertical-align:middle;" /> <img src="https://raw.githubusercontent.com/dnzckn/LazyLabel/main/src/lazylabel/demo_pictures/logo_black.png" alt="LazyLabel Cursive" style="height:60px; vertical-align:middle;" />
|
2
|
-
LazyLabel is an intuitive, AI-assisted image segmentation tool. It uses Meta's Segment Anything Model (SAM) for quick, precise mask generation, alongside advanced polygon editing for fine-tuned control. Outputs are saved in a clean, one-hot encoded format for easy machine learning integration.
|
2
|
+
LazyLabel is an intuitive, AI-assisted image segmentation tool. It uses Meta's Segment Anything Model (SAM) for quick, precise mask generation, alongside advanced polygon editing for fine-tuned control. Outputs are saved in a clean, one-hot encoded `.npz` format for easy machine learning integration and in YOLO `.txt` format.
|
3
3
|
|
4
4
|
Inspired by [LabelMe](https://github.com/wkentaro/labelme?tab=readme-ov-file#installation) and [Segment-Anything-UI](https://github.com/branislavhesko/segment-anything-ui/tree/main).
|
5
5
|
|
@@ -0,0 +1,261 @@
|
|
1
|
+
from PyQt6.QtWidgets import (
|
2
|
+
QWidget,
|
3
|
+
QVBoxLayout,
|
4
|
+
QPushButton,
|
5
|
+
QLabel,
|
6
|
+
QFrame,
|
7
|
+
QTableWidget,
|
8
|
+
QTreeView,
|
9
|
+
QAbstractItemView,
|
10
|
+
QHBoxLayout,
|
11
|
+
QComboBox,
|
12
|
+
QHeaderView,
|
13
|
+
QCheckBox,
|
14
|
+
QSlider,
|
15
|
+
QGroupBox,
|
16
|
+
QSplitter,
|
17
|
+
)
|
18
|
+
from PyQt6.QtCore import Qt
|
19
|
+
from .reorderable_class_table import ReorderableClassTable
|
20
|
+
|
21
|
+
|
22
|
+
class ControlPanel(QWidget):
|
23
|
+
def __init__(self, parent=None):
|
24
|
+
super().__init__(parent)
|
25
|
+
layout = QVBoxLayout(self)
|
26
|
+
layout.setAlignment(Qt.AlignmentFlag.AlignTop)
|
27
|
+
|
28
|
+
toggle_layout = QHBoxLayout()
|
29
|
+
self.btn_toggle_visibility = QPushButton("< Hide")
|
30
|
+
self.btn_toggle_visibility.setToolTip("Hide this panel")
|
31
|
+
toggle_layout.addWidget(self.btn_toggle_visibility)
|
32
|
+
toggle_layout.addStretch()
|
33
|
+
layout.addLayout(toggle_layout)
|
34
|
+
|
35
|
+
self.main_controls_widget = QWidget()
|
36
|
+
main_layout = QVBoxLayout(self.main_controls_widget)
|
37
|
+
main_layout.setContentsMargins(0, 0, 0, 0)
|
38
|
+
|
39
|
+
self.mode_label = QLabel("Mode: Points")
|
40
|
+
font = self.mode_label.font()
|
41
|
+
font.setPointSize(14)
|
42
|
+
font.setBold(True)
|
43
|
+
self.mode_label.setFont(font)
|
44
|
+
main_layout.addWidget(self.mode_label)
|
45
|
+
|
46
|
+
self.btn_sam_mode = QPushButton("Point Mode (1)")
|
47
|
+
self.btn_sam_mode.setToolTip("Switch to Point Mode for AI segmentation (1)")
|
48
|
+
self.btn_polygon_mode = QPushButton("Polygon Mode (2)")
|
49
|
+
self.btn_polygon_mode.setToolTip("Switch to Polygon Drawing Mode (2)")
|
50
|
+
self.btn_selection_mode = QPushButton("Selection Mode (E)")
|
51
|
+
self.btn_selection_mode.setToolTip("Toggle segment selection (E)")
|
52
|
+
main_layout.addWidget(self.btn_sam_mode)
|
53
|
+
main_layout.addWidget(self.btn_polygon_mode)
|
54
|
+
main_layout.addWidget(self.btn_selection_mode)
|
55
|
+
|
56
|
+
main_layout.addSpacing(20)
|
57
|
+
line1 = QFrame()
|
58
|
+
line1.setFrameShape(QFrame.Shape.HLine)
|
59
|
+
main_layout.addWidget(line1)
|
60
|
+
main_layout.addSpacing(10)
|
61
|
+
|
62
|
+
self.btn_fit_view = QPushButton("Fit View (.)")
|
63
|
+
self.btn_fit_view.setToolTip("Reset image zoom and pan to fit the view (.)")
|
64
|
+
self.btn_clear_points = QPushButton("Clear Clicks (C)")
|
65
|
+
self.btn_clear_points.setToolTip("Clear current temporary points/vertices (C)")
|
66
|
+
main_layout.addWidget(self.btn_fit_view)
|
67
|
+
main_layout.addWidget(self.btn_clear_points)
|
68
|
+
|
69
|
+
main_layout.addSpacing(10)
|
70
|
+
|
71
|
+
settings_group = QGroupBox("Settings")
|
72
|
+
settings_layout = QVBoxLayout()
|
73
|
+
|
74
|
+
self.chk_auto_save = QCheckBox("Auto-Save on Navigate")
|
75
|
+
self.chk_auto_save.setToolTip(
|
76
|
+
"Automatically save work when using arrow keys to change images."
|
77
|
+
)
|
78
|
+
self.chk_auto_save.setChecked(True)
|
79
|
+
settings_layout.addWidget(self.chk_auto_save)
|
80
|
+
|
81
|
+
self.chk_save_npz = QCheckBox("Save .npz")
|
82
|
+
self.chk_save_npz.setChecked(True)
|
83
|
+
self.chk_save_npz.setToolTip(
|
84
|
+
"Save the final mask as a compressed NumPy NPZ file."
|
85
|
+
)
|
86
|
+
settings_layout.addWidget(self.chk_save_npz)
|
87
|
+
|
88
|
+
self.chk_save_txt = QCheckBox("Save .txt")
|
89
|
+
self.chk_save_txt.setChecked(True)
|
90
|
+
self.chk_save_txt.setToolTip(
|
91
|
+
"Save bounding box annotations in YOLO TXT format."
|
92
|
+
)
|
93
|
+
settings_layout.addWidget(self.chk_save_txt)
|
94
|
+
|
95
|
+
self.chk_save_class_aliases = QCheckBox("Save Class Aliases (.json)")
|
96
|
+
self.chk_save_class_aliases.setToolTip(
|
97
|
+
"Save class aliases to a companion JSON file."
|
98
|
+
)
|
99
|
+
self.chk_save_class_aliases.setChecked(False)
|
100
|
+
settings_layout.addWidget(self.chk_save_class_aliases)
|
101
|
+
|
102
|
+
settings_group.setLayout(settings_layout)
|
103
|
+
main_layout.addWidget(settings_group)
|
104
|
+
|
105
|
+
sliders_group = QGroupBox("Adjustments")
|
106
|
+
sliders_layout = QVBoxLayout()
|
107
|
+
|
108
|
+
self.size_label = QLabel("Annotation Size: 1.0x")
|
109
|
+
self.size_slider = QSlider(Qt.Orientation.Horizontal)
|
110
|
+
self.size_slider.setRange(1, 50)
|
111
|
+
self.size_slider.setValue(10)
|
112
|
+
self.size_slider.setToolTip("Adjusts the size of points and lines (Ctrl +/-)")
|
113
|
+
sliders_layout.addWidget(self.size_label)
|
114
|
+
sliders_layout.addWidget(self.size_slider)
|
115
|
+
|
116
|
+
sliders_layout.addSpacing(10)
|
117
|
+
|
118
|
+
self.pan_label = QLabel("Pan Speed: 1.0x")
|
119
|
+
self.pan_slider = QSlider(Qt.Orientation.Horizontal)
|
120
|
+
self.pan_slider.setRange(1, 100)
|
121
|
+
self.pan_slider.setValue(10)
|
122
|
+
self.pan_slider.setToolTip(
|
123
|
+
"Adjusts the speed of WASD panning. Hold Shift for 5x boost."
|
124
|
+
)
|
125
|
+
sliders_layout.addWidget(self.pan_label)
|
126
|
+
sliders_layout.addWidget(self.pan_slider)
|
127
|
+
|
128
|
+
sliders_layout.addSpacing(10)
|
129
|
+
|
130
|
+
self.join_label = QLabel("Polygon Join Distance: 2px")
|
131
|
+
self.join_slider = QSlider(Qt.Orientation.Horizontal)
|
132
|
+
self.join_slider.setRange(1, 10)
|
133
|
+
self.join_slider.setValue(2)
|
134
|
+
self.join_slider.setToolTip("The pixel distance to 'snap' a polygon closed.")
|
135
|
+
sliders_layout.addWidget(self.join_label)
|
136
|
+
sliders_layout.addWidget(self.join_slider)
|
137
|
+
|
138
|
+
sliders_group.setLayout(sliders_layout)
|
139
|
+
main_layout.addWidget(sliders_group)
|
140
|
+
|
141
|
+
main_layout.addStretch()
|
142
|
+
|
143
|
+
self.notification_label = QLabel("")
|
144
|
+
font = self.notification_label.font()
|
145
|
+
font.setItalic(True)
|
146
|
+
self.notification_label.setFont(font)
|
147
|
+
self.notification_label.setStyleSheet("color: #ffa500;")
|
148
|
+
self.notification_label.setWordWrap(True)
|
149
|
+
main_layout.addWidget(self.notification_label)
|
150
|
+
|
151
|
+
self.device_label = QLabel("Device: Unknown")
|
152
|
+
main_layout.addWidget(self.device_label)
|
153
|
+
|
154
|
+
layout.addWidget(self.main_controls_widget)
|
155
|
+
self.setFixedWidth(250)
|
156
|
+
|
157
|
+
|
158
|
+
class RightPanel(QWidget):
|
159
|
+
def __init__(self, parent=None):
|
160
|
+
super().__init__(parent)
|
161
|
+
self.v_layout = QVBoxLayout(self)
|
162
|
+
|
163
|
+
toggle_layout = QHBoxLayout()
|
164
|
+
toggle_layout.addStretch()
|
165
|
+
self.btn_toggle_visibility = QPushButton("Hide >")
|
166
|
+
self.btn_toggle_visibility.setToolTip("Hide this panel")
|
167
|
+
toggle_layout.addWidget(self.btn_toggle_visibility)
|
168
|
+
self.v_layout.addLayout(toggle_layout)
|
169
|
+
|
170
|
+
self.main_controls_widget = QWidget()
|
171
|
+
main_layout = QVBoxLayout(self.main_controls_widget)
|
172
|
+
main_layout.setContentsMargins(0, 0, 0, 0)
|
173
|
+
|
174
|
+
v_splitter = QSplitter(Qt.Orientation.Vertical)
|
175
|
+
|
176
|
+
# --- File Explorer Widget ---
|
177
|
+
file_explorer_widget = QWidget()
|
178
|
+
file_explorer_layout = QVBoxLayout(file_explorer_widget)
|
179
|
+
file_explorer_layout.setContentsMargins(0, 0, 0, 0)
|
180
|
+
self.btn_open_folder = QPushButton("Open Image Folder")
|
181
|
+
self.btn_open_folder.setToolTip("Open a directory of images")
|
182
|
+
self.file_tree = QTreeView()
|
183
|
+
file_explorer_layout.addWidget(self.btn_open_folder)
|
184
|
+
file_explorer_layout.addWidget(self.file_tree)
|
185
|
+
v_splitter.addWidget(file_explorer_widget)
|
186
|
+
|
187
|
+
# --- Segment List Widget ---
|
188
|
+
segment_widget = QWidget()
|
189
|
+
segment_layout = QVBoxLayout(segment_widget)
|
190
|
+
segment_layout.setContentsMargins(0, 0, 0, 0)
|
191
|
+
|
192
|
+
class_filter_layout = QHBoxLayout()
|
193
|
+
class_filter_layout.addWidget(QLabel("Filter Class:"))
|
194
|
+
self.class_filter_combo = QComboBox()
|
195
|
+
self.class_filter_combo.setToolTip("Filter segments list by class")
|
196
|
+
class_filter_layout.addWidget(self.class_filter_combo)
|
197
|
+
segment_layout.addLayout(class_filter_layout)
|
198
|
+
|
199
|
+
self.segment_table = QTableWidget()
|
200
|
+
self.segment_table.setColumnCount(3)
|
201
|
+
self.segment_table.setHorizontalHeaderLabels(
|
202
|
+
["Segment ID", "Class ID", "Alias"]
|
203
|
+
)
|
204
|
+
self.segment_table.horizontalHeader().setSectionResizeMode(
|
205
|
+
QHeaderView.ResizeMode.Stretch
|
206
|
+
)
|
207
|
+
self.segment_table.setSelectionBehavior(
|
208
|
+
QAbstractItemView.SelectionBehavior.SelectRows
|
209
|
+
)
|
210
|
+
self.segment_table.setSortingEnabled(True)
|
211
|
+
self.segment_table.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
|
212
|
+
segment_layout.addWidget(self.segment_table)
|
213
|
+
|
214
|
+
segment_action_layout = QHBoxLayout()
|
215
|
+
self.btn_merge_selection = QPushButton("Merge to Class")
|
216
|
+
self.btn_merge_selection.setToolTip(
|
217
|
+
"Merge selected segments into a single class (M)"
|
218
|
+
)
|
219
|
+
self.btn_delete_selection = QPushButton("Delete")
|
220
|
+
self.btn_delete_selection.setToolTip(
|
221
|
+
"Delete selected segments (Delete/Backspace)"
|
222
|
+
)
|
223
|
+
segment_action_layout.addWidget(self.btn_merge_selection)
|
224
|
+
segment_action_layout.addWidget(self.btn_delete_selection)
|
225
|
+
segment_layout.addLayout(segment_action_layout)
|
226
|
+
v_splitter.addWidget(segment_widget)
|
227
|
+
|
228
|
+
# --- Class Table Widget ---
|
229
|
+
class_widget = QWidget()
|
230
|
+
class_layout = QVBoxLayout(class_widget)
|
231
|
+
class_layout.setContentsMargins(0, 0, 0, 0)
|
232
|
+
class_layout.addWidget(QLabel("Class Order:"))
|
233
|
+
self.class_table = ReorderableClassTable()
|
234
|
+
self.class_table.setToolTip(
|
235
|
+
"Double-click to set class aliases and drag to reorder channels for saving."
|
236
|
+
)
|
237
|
+
self.class_table.setColumnCount(2)
|
238
|
+
self.class_table.setHorizontalHeaderLabels(["Alias", "Class ID"])
|
239
|
+
self.class_table.horizontalHeader().setSectionResizeMode(
|
240
|
+
0, QHeaderView.ResizeMode.Stretch
|
241
|
+
)
|
242
|
+
self.class_table.horizontalHeader().setSectionResizeMode(
|
243
|
+
1, QHeaderView.ResizeMode.ResizeToContents
|
244
|
+
)
|
245
|
+
self.class_table.setEditTriggers(QAbstractItemView.EditTrigger.DoubleClicked)
|
246
|
+
class_layout.addWidget(self.class_table)
|
247
|
+
self.btn_reassign_classes = QPushButton("Reassign Class IDs")
|
248
|
+
self.btn_reassign_classes.setToolTip(
|
249
|
+
"Re-index class channels based on the current order in this table"
|
250
|
+
)
|
251
|
+
class_layout.addWidget(self.btn_reassign_classes)
|
252
|
+
v_splitter.addWidget(class_widget)
|
253
|
+
|
254
|
+
main_layout.addWidget(v_splitter)
|
255
|
+
|
256
|
+
self.status_label = QLabel("")
|
257
|
+
self.status_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
258
|
+
main_layout.addWidget(self.status_label)
|
259
|
+
|
260
|
+
self.v_layout.addWidget(self.main_controls_widget)
|
261
|
+
self.setFixedWidth(350)
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import os
|
2
|
+
from PyQt6.QtCore import Qt, QModelIndex, QDir
|
3
|
+
from PyQt6.QtGui import QFileSystemModel, QBrush, QColor
|
4
|
+
|
5
|
+
|
6
|
+
class CustomFileSystemModel(QFileSystemModel):
|
7
|
+
def __init__(self, parent=None):
|
8
|
+
super().__init__(parent)
|
9
|
+
self.setFilter(QDir.Filter.NoDotAndDotDot | QDir.Filter.Files)
|
10
|
+
self.setNameFilterDisables(False)
|
11
|
+
self.setNameFilters(["*.png", "*.jpg", "*.jpeg", "*.tiff", "*.tif"])
|
12
|
+
self.highlighted_path = None
|
13
|
+
|
14
|
+
def set_highlighted_path(self, path):
|
15
|
+
self.highlighted_path = os.path.normpath(path) if path else None
|
16
|
+
self.layoutChanged.emit()
|
17
|
+
|
18
|
+
def columnCount(self, parent: QModelIndex = QModelIndex()) -> int:
|
19
|
+
return 3
|
20
|
+
|
21
|
+
def headerData(
|
22
|
+
self,
|
23
|
+
section: int,
|
24
|
+
orientation: Qt.Orientation,
|
25
|
+
role: int = Qt.ItemDataRole.DisplayRole,
|
26
|
+
):
|
27
|
+
if (
|
28
|
+
orientation == Qt.Orientation.Horizontal
|
29
|
+
and role == Qt.ItemDataRole.DisplayRole
|
30
|
+
):
|
31
|
+
if section == 0:
|
32
|
+
return "File Name"
|
33
|
+
if section == 1:
|
34
|
+
return ".npz"
|
35
|
+
if section == 2:
|
36
|
+
return ".txt"
|
37
|
+
return super().headerData(section, orientation, role)
|
38
|
+
|
39
|
+
def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole):
|
40
|
+
if not index.isValid():
|
41
|
+
return None
|
42
|
+
|
43
|
+
if role == Qt.ItemDataRole.BackgroundRole:
|
44
|
+
filePath = os.path.normpath(self.filePath(index))
|
45
|
+
if (
|
46
|
+
self.highlighted_path
|
47
|
+
and os.path.splitext(filePath)[0]
|
48
|
+
== os.path.splitext(self.highlighted_path)[0]
|
49
|
+
):
|
50
|
+
return QBrush(QColor(40, 80, 40))
|
51
|
+
|
52
|
+
if index.column() > 0 and role == Qt.ItemDataRole.CheckStateRole:
|
53
|
+
filePath = self.filePath(index.siblingAtColumn(0))
|
54
|
+
base_path = os.path.splitext(filePath)[0]
|
55
|
+
|
56
|
+
if index.column() == 1:
|
57
|
+
check_path = base_path + ".npz"
|
58
|
+
elif index.column() == 2:
|
59
|
+
check_path = base_path + ".txt"
|
60
|
+
else:
|
61
|
+
return None
|
62
|
+
|
63
|
+
return (
|
64
|
+
Qt.CheckState.Checked
|
65
|
+
if os.path.exists(check_path)
|
66
|
+
else Qt.CheckState.Unchecked
|
67
|
+
)
|
68
|
+
|
69
|
+
if index.column() > 0 and role == Qt.ItemDataRole.DisplayRole:
|
70
|
+
return ""
|
71
|
+
|
72
|
+
return super().data(index, role)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from PyQt6.QtWidgets import QGraphicsEllipseItem, QGraphicsItem
|
2
2
|
from PyQt6.QtCore import Qt
|
3
|
-
from PyQt6.QtGui import QBrush, QPen
|
3
|
+
from PyQt6.QtGui import QBrush, QPen, QColor
|
4
4
|
|
5
5
|
|
6
6
|
class EditableVertexItem(QGraphicsEllipseItem):
|
@@ -11,8 +11,12 @@ class EditableVertexItem(QGraphicsEllipseItem):
|
|
11
11
|
self.vertex_index = vertex_index
|
12
12
|
|
13
13
|
self.setZValue(200)
|
14
|
-
|
15
|
-
|
14
|
+
|
15
|
+
color = QColor(Qt.GlobalColor.cyan)
|
16
|
+
color.setAlpha(180)
|
17
|
+
self.setBrush(QBrush(color))
|
18
|
+
|
19
|
+
self.setPen(QPen(Qt.GlobalColor.transparent))
|
16
20
|
self.setFlag(QGraphicsItem.GraphicsItemFlag.ItemIsMovable)
|
17
21
|
self.setFlag(QGraphicsItem.GraphicsItemFlag.ItemSendsGeometryChanges)
|
18
22
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
from PyQt6.QtWidgets import QGraphicsPixmapItem
|
2
|
+
|
3
|
+
|
4
|
+
class HoverablePixmapItem(QGraphicsPixmapItem):
|
5
|
+
def __init__(self, parent=None):
|
6
|
+
super().__init__(parent)
|
7
|
+
self.setAcceptHoverEvents(True)
|
8
|
+
self.default_pixmap = None
|
9
|
+
self.hover_pixmap = None
|
10
|
+
|
11
|
+
def set_pixmaps(self, default_pixmap, hover_pixmap):
|
12
|
+
self.default_pixmap = default_pixmap
|
13
|
+
self.hover_pixmap = hover_pixmap
|
14
|
+
self.setPixmap(self.default_pixmap)
|
15
|
+
|
16
|
+
def hoverEnterEvent(self, event):
|
17
|
+
self.setPixmap(self.hover_pixmap)
|
18
|
+
super().hoverEnterEvent(event)
|
19
|
+
|
20
|
+
def hoverLeaveEvent(self, event):
|
21
|
+
self.setPixmap(self.default_pixmap)
|
22
|
+
super().hoverLeaveEvent(event)
|