From a8c0979ef166deb3b68c052c426d7571dd9c9b6f Mon Sep 17 00:00:00 2001 From: Clement Desmidt Date: Fri, 14 Jun 2024 17:32:44 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Add=20not=20cheated=20pause?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For #36 --- assets/icons/pause.png | Bin 0 -> 300 bytes assets/icons/sand-clock.png | Bin 0 -> 543 bytes src/element/image.py | 15 +++++++++++++++ src/element/toolbar.py | 19 ++++++++++++++++++- 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 assets/icons/pause.png create mode 100644 assets/icons/sand-clock.png diff --git a/assets/icons/pause.png b/assets/icons/pause.png new file mode 100644 index 0000000000000000000000000000000000000000..3504889a6e04bcd7bb378adacd395007fb58485b GIT binary patch literal 300 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf4nJ zu>AsI#_LHrDL_HV64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1T6db&7< zcyzvEw?F*^UkHL?#yf!IcLJQcd=|ao#H44LI>|Pr8iaQ0tL4$Fn$o|BA57L m^Tih>Qh&}b{=Yi^v~HYtQ4BnSa5QW!+Eh?piQ zHWq?~5{P}Yh_*Iqv{D1;JuiO}ZN=u@<|St4f^5K0FNKc|4Mo zwT9m~vm5dZJ$Q*vn8JxDc&q5Va>g1ahSwBwO5i Date: Mon, 17 Jun 2024 14:16:58 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=A8=20Add=20cheated=20pause?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For #36 --- src/element/image.py | 17 ++++++++--------- src/element/toolbar.py | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/element/image.py b/src/element/image.py index bcf46d3..c491779 100644 --- a/src/element/image.py +++ b/src/element/image.py @@ -8,7 +8,6 @@ from PIL import ImageTk, Image, ImageOps class ImagePlaceholder: def __init__(self, image_window, images): self.is_break = False - self.is_pause = False self.current_image = None self.current_original_image = None self.paused_original_image = None @@ -64,15 +63,15 @@ class ImagePlaceholder: self.image_label.configure(image=image_to_display) self.image_label.image = image_to_display - def pause(self): - if self.is_pause: - self.is_pause = False + def pause(self, pause=True, cheat=False): + if pause: + self.paused_original_image = self.current_original_image + if not cheat: + image_path = 'assets/images/break.jpg' + self.current_original_image = Image.open(image_path) + else: self.current_original_image = self.paused_original_image self.paused_original_image = None - else: - self.is_pause = True - self.paused_original_image = self.current_original_image - image_path = 'assets/images/break.jpg' - self.current_original_image = Image.open(image_path) + self.current_image = copy.deepcopy(self.current_original_image) self.apply_options() diff --git a/src/element/toolbar.py b/src/element/toolbar.py index 05950c9..3c9f6fa 100644 --- a/src/element/toolbar.py +++ b/src/element/toolbar.py @@ -3,6 +3,7 @@ import subprocess import sys from tkinter import * from tkinter.ttk import Progressbar, Style +from tkinter.messagebox import * import customtkinter from CTkToolTip import * @@ -14,6 +15,7 @@ from src.util import Util class Toolbar: def __init__(self, image_window, timer): self.timers = [] + self.is_paused = False self.current_image = None self.current_original_image = None self.image_window = image_window @@ -154,13 +156,21 @@ class Toolbar: self.image_window.window.attributes("-fullscreen", self.image_window.option["fullscreen"]) def pause(self): + cheating = False + + if not self.is_paused: + cheating = askyesno("Pause", "Laisser l'image affichée ?") + self.is_paused = True + else: + self.is_paused = False + + # timer is paused whatever happened if self.timer_check is not None: self.image_window.window.after_cancel(self.timer_check) self.timer_check = None else: - print(self.timer) - print(100-self.progressbar['value']) self.timer_check = self.image_window.window.after( 1000, self.update_timer, int((100-self.progressbar['value'])*self.timer/100) ) - self.image_window.image.pause() + + self.image_window.image.pause(pause=self.is_paused, cheat=cheating) -- 2.30.2