From ee8968cbabf1cea2ed4976ef04d883b3cccf3e2f Mon Sep 17 00:00:00 2001 From: Shikiryu Date: Fri, 17 May 2024 23:39:29 +0200 Subject: [PATCH] :lipstick: Add progressbar as timer + remove one bug and updates dependencies --- requirements.txt | 4 ++-- src/element/image.py | 7 ++++++- src/element/toolbar.py | 20 +++++++++++++++++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index d22b91a..2fcfc81 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -pillow~=9.5.0 -pyinstaller==5.12.0 +pillow~=10.0.1 +pyinstaller==5.13.1 pygame~=2.4.0 customtkinter~=5.1.3 configparser~=5.3.0 diff --git a/src/element/image.py b/src/element/image.py index c6a0270..858ac14 100644 --- a/src/element/image.py +++ b/src/element/image.py @@ -1,5 +1,7 @@ import copy from tkinter import * + +import PIL from PIL import ImageTk, Image, ImageOps @@ -16,6 +18,9 @@ class ImagePlaceholder: self.image_label.pack(side=TOP, fill=BOTH, expand=1) def display_new_image(self): + if len(self.images) == 0: + self.image_window.on_closing() + return image_path = self.images.pop(0) if image_path == "break": self.is_break = True @@ -35,7 +40,7 @@ class ImagePlaceholder: if w < 21 or h < 21: w = 1280 h = 1024 - self.current_image.thumbnail((w - 20, h - 20), Image.ANTIALIAS) + self.current_image.thumbnail((w - 20, h - 20), PIL.Image.Resampling.LANCZOS) if reload: self.load_widget() diff --git a/src/element/toolbar.py b/src/element/toolbar.py index 33be9f8..61e3334 100644 --- a/src/element/toolbar.py +++ b/src/element/toolbar.py @@ -1,12 +1,13 @@ -import copy import os import subprocess import sys from tkinter import * +from tkinter.ttk import Progressbar, Style -from CTkToolTip import * -from PIL import ImageTk, Image, ImageOps import customtkinter +from CTkToolTip import * +from PIL import ImageTk, Image + from src.util import Util @@ -65,13 +66,23 @@ class Toolbar: text_color=Util.get_default_button_color()) self.timer_label.pack(side=RIGHT, ipadx=20) + style = Style() + style.theme_use('default') + style.configure("black.Horizontal.TProgressbar", background='black') + + self.progressbar = Progressbar(toolbar, length=280) + self.progressbar.pack(side=RIGHT, ipadx=20) + def display_new_timer(self): + if len(self.timers) == 0: + return self.timer = self.timers.pop(0) self.timer_label.configure(text=Util.format_seconds(self.timer)) self.timer_check = self.image_window.window.after(1000, self.update_timer, self.timer) def update_timer(self, current): current -= 1 + self.progressbar['value'] = 100 - (current * 100 / self.timer) if current == 10: self.image_window.play_countdown() if current > 0: @@ -103,8 +114,11 @@ class Toolbar: try: self.timer_label.pack_info() self.timer_label.pack_forget() + self.progressbar.pack_info() + self.progressbar.pack_forget() except TclError: self.timer_label.pack(side=RIGHT, ipadx=20) + self.progressbar.pack(side=RIGHT, ipadx=20) def open_folder(self): if sys.platform == "win32": -- 2.30.2