add reset button to crop plugin

This commit is contained in:
arve0
2015-05-07 10:14:38 +02:00
parent add8419f13
commit d7a80f55f3
+11 -1
View File
@@ -1,6 +1,6 @@
from .base import Plugin
from ..canvastools import RectangleTool
from ...viewer.widgets import SaveButtons
from ...viewer.widgets import SaveButtons, Button
__all__ = ['Crop']
@@ -23,6 +23,9 @@ class Crop(Plugin):
on_enter=self.crop)
self.artists.append(self.rect_tool)
self.reset_button = Button('Reset', self.reset)
self.add_widget(self.reset_button)
def help(self):
helpstr = ("Crop tool",
"Select rectangular region and press enter to crop.")
@@ -30,6 +33,13 @@ class Crop(Plugin):
def crop(self, extents):
xmin, xmax, ymin, ymax = extents
if xmin == xmax or ymin == ymax:
return
image = self.image_viewer.image[ymin:ymax+1, xmin:xmax+1]
self.image_viewer.image = image
self.image_viewer.ax.relim()
def reset(self):
self.rect_tool.extents = -10, -10, -10, -10
self.image_viewer.image = self.image_viewer.original_image
self.image_viewer.ax.relim()