Add button to leave image always on top #22

Merged
Shikiryu merged 1 commits from feature/always_on_top into main 2023-05-23 22:00:08 +02:00
Showing only changes of commit 273afa6aee - Show all commits

View File

@ -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):