Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 55c9896

Browse filesBrowse files
authored
add polygon button to gridplot toolbar (#334)
1 parent 6075ca2 commit 55c9896
Copy full SHA for 55c9896

File tree

1 file changed

+15
-1
lines changed
Filter options

1 file changed

+15
-1
lines changed

‎fastplotlib/layouts/_gridplot.py

Copy file name to clipboardExpand all lines: fastplotlib/layouts/_gridplot.py
+15-1Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ._defaults import create_controller
2121
from ._subplot import Subplot
2222
from ._record_mixin import RecordMixin
23-
23+
from ..graphics.selectors import PolygonSelector
2424

2525
def to_array(a) -> np.ndarray:
2626
if isinstance(a, np.ndarray):
@@ -481,6 +481,14 @@ def __init__(self, plot: GridPlot):
481481
tooltip="y-axis direction",
482482
)
483483

484+
self.add_polygon_button = Button(
485+
value=False,
486+
disabled=False,
487+
icon="draw-polygon",
488+
layout=Layout(width="auto"),
489+
tooltip="add PolygonSelector"
490+
)
491+
484492
self.record_button = ToggleButton(
485493
value=False,
486494
disabled=False,
@@ -510,6 +518,7 @@ def __init__(self, plot: GridPlot):
510518
self.panzoom_controller_button,
511519
self.maintain_aspect_button,
512520
self.flip_camera_button,
521+
self.add_polygon_button,
513522
self.record_button,
514523
self.dropdown,
515524
]
@@ -580,3 +589,8 @@ def record_plot(self, obj):
580589
self.record_button.value = False
581590
else:
582591
self.plot.record_stop()
592+
593+
def add_polygon(self, obj):
594+
ps = PolygonSelector(edge_width=3, edge_color="magenta")
595+
596+
self.current_subplot.add_graphic(ps, center=False)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.