supervisely 6.73.416__py3-none-any.whl → 6.73.417__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.
- supervisely/app/widgets/transfer/style.css +3 -0
- supervisely/app/widgets/transfer/template.html +3 -1
- supervisely/app/widgets/transfer/transfer.py +48 -45
- {supervisely-6.73.416.dist-info → supervisely-6.73.417.dist-info}/METADATA +1 -1
- {supervisely-6.73.416.dist-info → supervisely-6.73.417.dist-info}/RECORD +9 -8
- {supervisely-6.73.416.dist-info → supervisely-6.73.417.dist-info}/LICENSE +0 -0
- {supervisely-6.73.416.dist-info → supervisely-6.73.417.dist-info}/WHEEL +0 -0
- {supervisely-6.73.416.dist-info → supervisely-6.73.417.dist-info}/entry_points.txt +0 -0
- {supervisely-6.73.416.dist-info → supervisely-6.73.417.dist-info}/top_level.txt +0 -0
|
@@ -41,7 +41,9 @@ class Transfer(Widget):
|
|
|
41
41
|
:param right_checked: A list of keys of the items in the right (target) list, which should be checked at widget
|
|
42
42
|
initialization. Defaults to None.
|
|
43
43
|
:type right_checked: List[str], optional
|
|
44
|
-
|
|
44
|
+
:param width: The width of the widget in pixels. The default and minimum width is 150 pixels.
|
|
45
|
+
:type width: int, optional
|
|
46
|
+
|
|
45
47
|
:Methods:
|
|
46
48
|
get_transferred_items(): returns the list of keys of the items, which are currently displayed in the
|
|
47
49
|
right (target) list.
|
|
@@ -88,7 +90,7 @@ class Transfer(Widget):
|
|
|
88
90
|
"""
|
|
89
91
|
class Routes:
|
|
90
92
|
VALUE_CHANGED = "value_changed"
|
|
91
|
-
|
|
93
|
+
|
|
92
94
|
class Item:
|
|
93
95
|
"""
|
|
94
96
|
Class for representing items in the Transfer widget.
|
|
@@ -123,45 +125,49 @@ class Transfer(Widget):
|
|
|
123
125
|
else:
|
|
124
126
|
self.label = label
|
|
125
127
|
self.disabled = disabled
|
|
126
|
-
|
|
128
|
+
|
|
127
129
|
def to_json(self):
|
|
128
130
|
return {"key": self.key, "label": self.label, "disabled": self.disabled}
|
|
129
|
-
|
|
130
|
-
def __init__(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
131
|
+
|
|
132
|
+
def __init__(
|
|
133
|
+
self,
|
|
134
|
+
items: Optional[Union[List[Item], List[str]]] = None,
|
|
135
|
+
transferred_items: Optional[List[str]] = None,
|
|
136
|
+
widget_id: Optional[str] = None,
|
|
137
|
+
filterable: Optional[bool] = False,
|
|
138
|
+
filter_placeholder: Optional[str] = None,
|
|
139
|
+
titles: Optional[List[str]] = None,
|
|
140
|
+
button_texts: Optional[List[str]] = None,
|
|
141
|
+
left_checked: Optional[List[str]] = None,
|
|
142
|
+
right_checked: Optional[List[str]] = None,
|
|
143
|
+
width: int = 150,
|
|
144
|
+
):
|
|
145
|
+
|
|
141
146
|
self._changes_handled = False
|
|
142
147
|
self._items = []
|
|
143
148
|
self._transferred_items = []
|
|
144
|
-
|
|
149
|
+
|
|
145
150
|
if items:
|
|
146
151
|
self._items = self.__checked_items(items)
|
|
147
|
-
|
|
152
|
+
|
|
148
153
|
if transferred_items:
|
|
149
154
|
self._transferred_items = self.__checked_transferred_items(transferred_items)
|
|
150
|
-
|
|
155
|
+
|
|
151
156
|
# If wrong items are specified, items won't be checked.
|
|
152
157
|
self._left_checked = left_checked
|
|
153
158
|
self._right_checked = right_checked
|
|
154
|
-
|
|
159
|
+
|
|
155
160
|
self._filterable = filterable
|
|
156
161
|
self._filter_placeholder = filter_placeholder
|
|
157
|
-
|
|
162
|
+
|
|
163
|
+
self._width = max(width, 150)
|
|
164
|
+
|
|
158
165
|
self._titles = titles if titles is not None else ["Source", "Target"]
|
|
159
|
-
|
|
166
|
+
|
|
160
167
|
self._button_texts = button_texts
|
|
161
|
-
|
|
168
|
+
|
|
162
169
|
super().__init__(widget_id=widget_id, file_path=__file__)
|
|
163
|
-
|
|
164
|
-
|
|
170
|
+
|
|
165
171
|
def __checked_items(self, items: Optional[Union[List[Item], List[str]]]) -> List[Transfer.Item]:
|
|
166
172
|
"""
|
|
167
173
|
If the list of items is specified as a list of strings, they will be converted to Transfer.Item objects. List of
|
|
@@ -183,17 +189,17 @@ class Transfer(Widget):
|
|
|
183
189
|
if len(set(items)) != len(items):
|
|
184
190
|
# If the keys of the items are not unique, an error will be raised.
|
|
185
191
|
raise ValueError("The keys of the items should be unique.")
|
|
186
|
-
|
|
192
|
+
|
|
187
193
|
checked_items = [Transfer.Item(key=item) for item in items]
|
|
188
194
|
else:
|
|
189
195
|
# If items are specified as Transfer.Item objects, they will be checked for uniqueness.
|
|
190
196
|
if len({item.key for item in items}) != len(items):
|
|
191
197
|
# If the keys of the items are not unique, an error will be raised.
|
|
192
198
|
raise ValueError("The keys of the items should be unique.")
|
|
193
|
-
|
|
199
|
+
|
|
194
200
|
checked_items = items
|
|
195
201
|
return checked_items
|
|
196
|
-
|
|
202
|
+
|
|
197
203
|
def __checked_transferred_items(self, transferred_items: List[str]) -> List[str]:
|
|
198
204
|
"""
|
|
199
205
|
If the self._items is specified, the list of transferred items will be checked for the keys of the items. Since
|
|
@@ -223,7 +229,7 @@ class Transfer(Widget):
|
|
|
223
229
|
"the keys of the items specified in the 'items' argument.")
|
|
224
230
|
else:
|
|
225
231
|
return transferred_items
|
|
226
|
-
|
|
232
|
+
|
|
227
233
|
def get_json_data(self) -> Dict[str, Union[List[Dict[str, Union[str, bool]]], None]]:
|
|
228
234
|
"""
|
|
229
235
|
Returns the data of the widget in JSON format.
|
|
@@ -243,7 +249,7 @@ class Transfer(Widget):
|
|
|
243
249
|
res["items"] = [item.to_json() for item in self._items]
|
|
244
250
|
|
|
245
251
|
return res
|
|
246
|
-
|
|
252
|
+
|
|
247
253
|
def get_json_state(self) -> Dict[str, List[str]]:
|
|
248
254
|
"""
|
|
249
255
|
Returns the state of the widget in JSON format.
|
|
@@ -256,9 +262,9 @@ class Transfer(Widget):
|
|
|
256
262
|
"""
|
|
257
263
|
|
|
258
264
|
transferred_items = self._transferred_items
|
|
259
|
-
|
|
265
|
+
|
|
260
266
|
return {"transferred_items": transferred_items}
|
|
261
|
-
|
|
267
|
+
|
|
262
268
|
def get_transferred_items(self) -> List[str]:
|
|
263
269
|
"""
|
|
264
270
|
Returns the list of transferred items.
|
|
@@ -268,8 +274,7 @@ class Transfer(Widget):
|
|
|
268
274
|
"""
|
|
269
275
|
|
|
270
276
|
return StateJson()[self.widget_id]["transferred_items"]
|
|
271
|
-
|
|
272
|
-
|
|
277
|
+
|
|
273
278
|
def get_untransferred_items(self) -> List[str]:
|
|
274
279
|
"""
|
|
275
280
|
Returns the list of untransferred items.
|
|
@@ -279,8 +284,7 @@ class Transfer(Widget):
|
|
|
279
284
|
"""
|
|
280
285
|
|
|
281
286
|
return [item.key for item in self._items if item.key not in self.get_transferred_items()]
|
|
282
|
-
|
|
283
|
-
|
|
287
|
+
|
|
284
288
|
def value_changed(self, func: Callable) -> Callable:
|
|
285
289
|
"""
|
|
286
290
|
Decorates a function which will be called when the the items in right list are changed (moved in or out of the list).
|
|
@@ -305,22 +309,21 @@ class Transfer(Widget):
|
|
|
305
309
|
print(items.untransferred_items) # ["item3"]
|
|
306
310
|
"""
|
|
307
311
|
|
|
308
|
-
|
|
309
312
|
route_path = self.get_route_path(Transfer.Routes.VALUE_CHANGED)
|
|
310
313
|
server = self._sly_app.get_server()
|
|
311
314
|
self._changes_handled = True
|
|
312
315
|
|
|
313
316
|
@server.post(route_path)
|
|
314
317
|
def _click():
|
|
315
|
-
|
|
318
|
+
|
|
316
319
|
Items = namedtuple("Items", ["transferred_items", "untransferred_items"])
|
|
317
|
-
|
|
320
|
+
|
|
318
321
|
res = Items(transferred_items=self.get_transferred_items(), untransferred_items=self.get_untransferred_items())
|
|
319
|
-
|
|
322
|
+
|
|
320
323
|
func(res)
|
|
321
324
|
|
|
322
325
|
return _click
|
|
323
|
-
|
|
326
|
+
|
|
324
327
|
def set_items(self, items: Union[List[Transfer.Item], List[str]]):
|
|
325
328
|
"""
|
|
326
329
|
Sets the list of items for the widget.
|
|
@@ -345,7 +348,7 @@ class Transfer(Widget):
|
|
|
345
348
|
|
|
346
349
|
# As you can see, the list of items was replaced with the new one.
|
|
347
350
|
"""
|
|
348
|
-
|
|
351
|
+
|
|
349
352
|
if items:
|
|
350
353
|
self._items = self.__checked_items(items)
|
|
351
354
|
else:
|
|
@@ -365,7 +368,7 @@ class Transfer(Widget):
|
|
|
365
368
|
self._transferred_items = self.__checked_transferred_items(transferred_items)
|
|
366
369
|
self.update_state()
|
|
367
370
|
StateJson().send_changes()
|
|
368
|
-
|
|
371
|
+
|
|
369
372
|
def add(self, items: Union[List[Item], List[str]]):
|
|
370
373
|
"""
|
|
371
374
|
Adds new items to the current list of items.
|
|
@@ -391,14 +394,14 @@ class Transfer(Widget):
|
|
|
391
394
|
"""
|
|
392
395
|
|
|
393
396
|
items = self.__checked_items(items)
|
|
394
|
-
|
|
397
|
+
|
|
395
398
|
if any([item.key in [item.key for item in self._items] for item in items]):
|
|
396
399
|
raise ValueError("The 'items' argument should not contain any items with the same key as the items in the current list.")
|
|
397
400
|
else:
|
|
398
401
|
self._items.extend(items)
|
|
399
402
|
self.update_data()
|
|
400
403
|
DataJson().send_changes()
|
|
401
|
-
|
|
404
|
+
|
|
402
405
|
def remove(self, items_keys: List[str]):
|
|
403
406
|
"""
|
|
404
407
|
Removes items from the current list of items.
|
|
@@ -416,7 +419,7 @@ class Transfer(Widget):
|
|
|
416
419
|
self.update_state()
|
|
417
420
|
DataJson().send_changes()
|
|
418
421
|
StateJson().send_changes()
|
|
419
|
-
|
|
422
|
+
|
|
420
423
|
def get_items_keys(self) -> List[str]:
|
|
421
424
|
"""
|
|
422
425
|
Returns the list of keys of the items.
|
|
@@ -537,8 +537,9 @@ supervisely/app/widgets/train_val_splits/__init__.py,sha256=47DEQpj8HBSa-_TImW-5
|
|
|
537
537
|
supervisely/app/widgets/train_val_splits/template.html,sha256=_uvKCMP0nkpSl3FiTUxqy10JZw3q8-9hXCv22W3BDF0,38
|
|
538
538
|
supervisely/app/widgets/train_val_splits/train_val_splits.py,sha256=KN7sW_IWs8UJO8JeLS_bS6L7NU1Qrqc7_fLBa6cettg,20493
|
|
539
539
|
supervisely/app/widgets/transfer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
540
|
-
supervisely/app/widgets/transfer/
|
|
541
|
-
supervisely/app/widgets/transfer/
|
|
540
|
+
supervisely/app/widgets/transfer/style.css,sha256=lPIeJMc4lqkLtPwRuAcxGok6L5sYIVoN77AId9LO2h0,73
|
|
541
|
+
supervisely/app/widgets/transfer/template.html,sha256=R9lKq4xsQhyAT0GOdZV7T7Myc3C999apSMBVacf4pzI,994
|
|
542
|
+
supervisely/app/widgets/transfer/transfer.py,sha256=y8Rg9AH7sNd342tSJwVmTO9Rwi5F5fTmxEMOa353bJo,19847
|
|
542
543
|
supervisely/app/widgets/tree_select/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
543
544
|
supervisely/app/widgets/tree_select/template.html,sha256=eUHN0yn_llRRozAOvdc8SjhY-KX12TcgOUXCemHWGew,613
|
|
544
545
|
supervisely/app/widgets/tree_select/tree_select.py,sha256=A86TCS_gXHi6UvHmsvZUyijnKgTvQ6UGnrHPJ19U_IY,14499
|
|
@@ -1115,9 +1116,9 @@ supervisely/worker_proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
1115
1116
|
supervisely/worker_proto/worker_api_pb2.py,sha256=VQfi5JRBHs2pFCK1snec3JECgGnua3Xjqw_-b3aFxuM,59142
|
|
1116
1117
|
supervisely/worker_proto/worker_api_pb2_grpc.py,sha256=3BwQXOaP9qpdi0Dt9EKG--Lm8KGN0C5AgmUfRv77_Jk,28940
|
|
1117
1118
|
supervisely_lib/__init__.py,sha256=7-3QnN8Zf0wj8NCr2oJmqoQWMKKPKTECvjH9pd2S5vY,159
|
|
1118
|
-
supervisely-6.73.
|
|
1119
|
-
supervisely-6.73.
|
|
1120
|
-
supervisely-6.73.
|
|
1121
|
-
supervisely-6.73.
|
|
1122
|
-
supervisely-6.73.
|
|
1123
|
-
supervisely-6.73.
|
|
1119
|
+
supervisely-6.73.417.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
1120
|
+
supervisely-6.73.417.dist-info/METADATA,sha256=aaq2Z7iTkRFy2PpXSCPFEbOpeaFwVBkFuh4sSy_8Awg,35254
|
|
1121
|
+
supervisely-6.73.417.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
1122
|
+
supervisely-6.73.417.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
|
|
1123
|
+
supervisely-6.73.417.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
|
|
1124
|
+
supervisely-6.73.417.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|