Add a shape property that gracefully accomodates a new image size

This commit is contained in:
blink1073
2014-02-08 22:12:38 -06:00
parent 85537e3f85
commit c70040c236
+14 -2
View File
@@ -50,8 +50,7 @@ class PaintTool(CanvasToolBase):
self.alpha = alpha
self.cmap = LABELS_CMAP
self._overlay_plot = None
self._shape = overlay_shape
self.overlay = np.zeros(overlay_shape, dtype='uint8')
self.shape = overlay_shape
self._cursor = plt.Rectangle((0, 0), 0, 0, **props)
self._cursor.set_visible(False)
@@ -109,6 +108,19 @@ class PaintTool(CanvasToolBase):
self._overlay_plot.set_data(image)
self.redraw()
@property
def shape(self):
return self._shape
@shape.setter
def shape(self, shape):
self._shape = shape
if not self._overlay_plot is None:
self._overlay_plot.set_extent((-0.5, shape[1] + 0.5,
shape[0] + 0.5, -0.5))
self.radius = self._radius
self.overlay = np.zeros(shape, dtype='uint8')
def _on_key_press(self, event):
if event.key == 'enter':
self.callback_on_enter(self.geometry)