Add next button #14

Merged
Shikiryu merged 1 commits from enhance/pass_button into main 2023-05-23 13:40:03 +02:00
Showing only changes of commit cac19935f3 - Show all commits

View File

@ -13,12 +13,16 @@ class ImageWindow:
self.images = [] self.images = []
self.current_image = None self.current_image = None
self.image_label = None self.image_label = None
toolbar = Frame(self.window, bd=1, relief=RAISED)
toolbar.pack(side=BOTTOM, fill=X)
self.timer = 0 self.timer = 0
self.timer_label = None 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)
self.image_label = Label(self.window) self.image_label = Label(self.window)
self.image_label.pack(side="top", fill="both", expand=1) self.image_label.pack(side="top", fill="both", expand=1)
self.timer_label = Label(self.window, text=self.timer) self.timer_label = Label(toolbar, text=self.timer)
self.timer_label.pack(side=BOTTOM) self.timer_label.pack(side=BOTTOM)
def update_timer(self, current): def update_timer(self, current):
@ -33,6 +37,11 @@ class ImageWindow:
self.window.update() self.window.update()
return return
self.next_image()
def next_image(self):
if self.timer_check is not None:
self.window.after_cancel(self.timer_check)
self.display_new_image() self.display_new_image()
self.display_new_timer() self.display_new_timer()
@ -44,8 +53,7 @@ class ImageWindow:
# canvas = Canvas(self.window) # canvas = Canvas(self.window)
# canvas.pack(fill=BOTH, expand=1) # canvas.pack(fill=BOTH, expand=1)
self.display_new_image() self.next_image()
self.display_new_timer()
def display_new_timer(self): def display_new_timer(self):
self.timer_label.configure(text=self.timer) self.timer_label.configure(text=self.timer)
@ -56,6 +64,8 @@ class ImageWindow:
self.images.pop(0) self.images.pop(0)
self.current_image = Image.open(image_path) self.current_image = Image.open(image_path)
self.resize_image()
image_to_display = ImageTk.PhotoImage(self.current_image) image_to_display = ImageTk.PhotoImage(self.current_image)
self.image_label.configure(image=image_to_display) self.image_label.configure(image=image_to_display)