💄 Add Timer toggle button and color when active button

Fix #9
This commit is contained in:
Shikiryu 2023-05-23 19:27:48 +02:00
parent fa13377c14
commit 7722b4f294

View File

@ -25,14 +25,19 @@ class ImageWindow:
next_button = Button(toolbar, relief=FLAT, compound=LEFT, text="next ➡️", command=self.next_image) next_button = Button(toolbar, relief=FLAT, compound=LEFT, text="next ➡️", command=self.next_image)
next_button.pack(side=LEFT, padx=0, pady=0) next_button.pack(side=LEFT, padx=0, pady=0)
bw_button = Button(toolbar, relief=FLAT, compound=LEFT, text="black&white", command=self.toggle_black_white) self.bw_button = Button(toolbar, relief=FLAT, compound=LEFT, text="black&white",
bw_button.pack(side=LEFT, padx=0, pady=0) command=self.toggle_black_white)
self.bw_button.pack(side=LEFT, padx=0, pady=0)
mirror_button = Button(toolbar, relief=FLAT, compound=LEFT, command=self.toggle_mirror, text="mirror") self.mirror_button = Button(toolbar, relief=FLAT, compound=LEFT, command=self.toggle_mirror, text="mirror")
mirror_button.pack(side=LEFT, padx=0, pady=0) self.mirror_button.pack(side=LEFT, padx=0, pady=0)
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)
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(toolbar, text=self.timer) self.timer_label = Label(toolbar, text=self.timer)
self.timer_label.pack(side=RIGHT, ipadx=20) self.timer_label.pack(side=RIGHT, ipadx=20)
@ -46,7 +51,6 @@ class ImageWindow:
if len(self.images) == 0: if len(self.images) == 0:
self.window.destroy() self.window.destroy()
self.window.update() self.window.update()
return return
self.next_image() self.next_image()
@ -57,14 +61,20 @@ class ImageWindow:
self.display_new_timer() self.display_new_timer()
def toggle_black_white(self): def toggle_black_white(self):
print("bw was " + str(self.option["bw"]))
self.option["bw"] = not self.option["bw"] self.option["bw"] = not self.option["bw"]
print("bw is now " + str(self.option["bw"])) self.bw_button.config(bg="blue" if self.option["bw"] else "grey85")
def toggle_mirror(self): def toggle_mirror(self):
print("mirror was " + str(self.option["mirror"]))
self.option["mirror"] = not self.option["mirror"] self.option["mirror"] = not self.option["mirror"]
print("mirror is now " + str(self.option["mirror"])) self.mirror_button.config(bg="blue" if self.option["mirror"] else "grey85")
def toggle_timer(self):
try:
self.timer_label.pack_info()
self.timer_label.pack_forget()
except TclError:
self.timer_label.pack(side=RIGHT, ipadx=20)
# self.timer_label.config()
def lets_draw(self, images, timer): def lets_draw(self, images, timer):
random.shuffle(images) random.shuffle(images)