aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2023-03-21 19:05:20 +0100
committerLeonard Kugis <leonard@kug.is>2023-03-21 19:05:20 +0100
commit157832d85788d15a61e885164ef37ab0ee40b048 (patch)
treef48ba1954fefbce9a6a9dec96d6d5a4e8b15a621
parentb1723822dc305c2e2698ce71d9db8b1aff018855 (diff)
GuiImage: Implemented direct rotation
-rw-r--r--gui.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/gui.py b/gui.py
index 248bbe0..6b6a4a2 100644
--- a/gui.py
+++ b/gui.py
@@ -82,8 +82,10 @@ class GuiImage(object):
self.__ret = self.RETURN_NEXT
self.__master = Tk()
self.__tags = StringVar(self.__master, value=','.join(tags))
- self.__image = ImageTk.PhotoImage(image=Image.fromarray(img).convert('RGB'))
- Label(self.__master, width=800, height=800, image=self.__image).grid(row=0, column=0, columnspan=4)
+ self.__image_pil = Image.fromarray(img)
+ self.__image = ImageTk.PhotoImage(image=self.__image_pil)
+ self.__label = Label(self.__master, width=800, height=800, image=self.__image)
+ self.__label.grid(row=0, column=0, columnspan=4)
Entry(self.__master, textvariable=self.__tags).grid(row=1, column=0, columnspan=4, sticky="we")
Button(self.__master, text="↺", command=self.__handle_rotate_90_counterclockwise).grid(row=2, column=0)
Button(self.__master, text="↻", command=self.__handle_rotate_90_clockwise).grid(row=2, column=1)
@@ -95,12 +97,14 @@ class GuiImage(object):
return (self.__ret, self.__tags.get().split(","))
def __handle_rotate_90_counterclockwise(self):
- self.__ret = self.RETURN_ROTATE_90_COUNTERCLOCKWISE
- self.__master.destroy()
+ self.__image_pil = self.__image_pil.rotate(90)
+ self.__image = ImageTk.PhotoImage(image=self.__image_pil)
+ self.__label.config(image=self.__image)
def __handle_rotate_90_clockwise(self):
- self.__ret = self.RETURN_ROTATE_90_CLOCKWISE
- self.__master.destroy()
+ self.__image_pil = self.__image_pil.rotate(-90)
+ self.__image = ImageTk.PhotoImage(image=self.__image_pil)
+ self.__label.config(image=self.__image)
def __handle_next(self):
self.__ret = self.RETURN_NEXT