From 7722b4f294d990c7c996655795a99a6548590dde Mon Sep 17 00:00:00 2001 From: Shikiryu Date: Tue, 23 May 2023 19:27:48 +0200 Subject: [PATCH] :lipstick: Add Timer toggle button and color when active button Fix #9 --- image.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/image.py b/image.py index 797213b..b9a3e38 100644 --- a/image.py +++ b/image.py @@ -25,14 +25,19 @@ class ImageWindow: next_button = Button(toolbar, relief=FLAT, compound=LEFT, text="next ➡️", command=self.next_image) 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) - bw_button.pack(side=LEFT, padx=0, pady=0) + self.bw_button = Button(toolbar, relief=FLAT, compound=LEFT, text="black&white", + 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") - mirror_button.pack(side=LEFT, padx=0, pady=0) + self.mirror_button = Button(toolbar, relief=FLAT, compound=LEFT, command=self.toggle_mirror, text="mirror") + 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.pack(side=TOP, fill=BOTH, expand=1) + self.timer_label = Label(toolbar, text=self.timer) self.timer_label.pack(side=RIGHT, ipadx=20) @@ -46,7 +51,6 @@ class ImageWindow: if len(self.images) == 0: self.window.destroy() self.window.update() - return self.next_image() @@ -57,14 +61,20 @@ class ImageWindow: self.display_new_timer() def toggle_black_white(self): - print("bw was " + str(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): - print("mirror was " + str(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): random.shuffle(images)