From 273afa6aeeed8e4018f49eaef96d0d2313c47d7c Mon Sep 17 00:00:00 2001 From: Shikiryu Date: Tue, 23 May 2023 21:59:39 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20button=20to=20leave=20image?= =?UTF-8?q?=20always=20on=20top?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #6 --- image.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/image.py b/image.py index 1fbe170..b647573 100644 --- a/image.py +++ b/image.py @@ -13,7 +13,8 @@ class ImageWindow: self.window.geometry("1280x1024") self.option = { "bw": False, - "mirror": False + "mirror": False, + "always_on_top": False, } self.images = [] self.current_image = None @@ -23,6 +24,7 @@ class ImageWindow: self.timer = 0 self.timer_label = None self.timer_check = None + self.timer_check = None next_button = Button(toolbar, relief=FLAT, compound=LEFT, text="next ➡️", command=self.next_image) next_button.pack(side=LEFT, padx=0, pady=0) @@ -38,6 +40,11 @@ class ImageWindow: , text="open folder") self.open_folder_button.pack(side=LEFT, padx=0, pady=0) + self.always_on_top_button = Button(toolbar, relief=FLAT, compound=LEFT, command=self.toggle_always_on_top + , text="always on top") + self.always_on_top_button.pack(side=LEFT, padx=0, pady=0) + self.always_on_top_check = None + self.timer_button = Button(toolbar, relief=FLAT, compound=LEFT, command=self.toggle_timer, text="timer") self.timer_button.pack(side=LEFT, padx=0, pady=0) @@ -84,14 +91,24 @@ class ImageWindow: def open_folder(self): os.startfile(self.app.selected_folder) + def toggle_always_on_top(self): + self.option["always_on_top"] = not self.option["always_on_top"] + if self.option["always_on_top"]: + self.always_on_top_button.config(bg="blue") + self.stay_on_top() + else: + self.always_on_top_button.config(bg="grey85") + self.window.after_cancel(self.always_on_top_check) + + def stay_on_top(self): + # self.window.lift() + self.window.attributes('-topmost', True) + self.always_on_top_check = self.window.after(2000, self.stay_on_top) + def lets_draw(self, images, timer): random.shuffle(images) self.images = images self.timer = timer - - # canvas = Canvas(self.window) - # canvas.pack(fill=BOTH, expand=1) - self.next_image() def display_new_timer(self): -- 2.30.2