💄 Add progressbar as timer #35

Merged
Shikiryu merged 1 commits from progressbar into main 2024-05-17 23:41:15 +02:00
3 changed files with 25 additions and 6 deletions

View File

@ -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

View File

@ -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()

View File

@ -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":