✨ Add next button #14
20
image.py
20
image.py
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user