Add next button

Fix #2
This commit is contained in:
Clement Desmidt 2023-05-23 13:39:16 +02:00
parent fd8d3a25f8
commit cac19935f3

View File

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