From 7b399669ed8c0d3297aeafa1c575728cbf6e5989 Mon Sep 17 00:00:00 2001 From: sexfrance Date: Fri, 25 Oct 2024 11:37:26 +0200 Subject: [PATCH] Added clear function in Home class --- README.md | 6 ++++-- logmagix/logger.py | 11 +++++++++-- setup.py | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a7eef32..801ce2f 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,8 @@ home_screen = Home( align="center", adinfo1="discord.cyberious.xyz", adinfo2="v1.0", - credits="Developed by sexfrance" + credits="Developed by sexfrance", + clear = False, # To clear the console, default is True ) home_screen.display() @@ -154,7 +155,8 @@ home_screen = Home( align="center", adinfo1="discord.cyberious.xyz", adinfo2="v1.0", - credits="Developed by sexfrance" + credits="Developed by sexfrance", + clear = False ) home_screen.display() diff --git a/logmagix/logger.py b/logmagix/logger.py index 669aab7..a8d54f5 100644 --- a/logmagix/logger.py +++ b/logmagix/logger.py @@ -104,12 +104,13 @@ def stop(self): print(self.end, flush=True) class Home: - def __init__(self, text, align="left", adinfo1=None, adinfo2=None, credits=None): + def __init__(self, text, align="left", adinfo1=None, adinfo2=None, credits=None, clear=True): self.text = text self.align = align self.adinfo1 = adinfo1 self.adinfo2 = adinfo2 self.credits = credits + self.clear = clear self.username = getpass.getuser() def _get_char_art(self): @@ -141,6 +142,9 @@ def _align_text(self, lines, terminal_width, alignment, block_width): aligned_result.append(aligned_line) return aligned_result + def _clear(self): + os.system('cls' if os.name == 'nt' else 'clear') + def display(self): char_arts, max_height = self._get_char_art() result = [""] * max_height @@ -155,8 +159,11 @@ def display(self): terminal_width = os.get_terminal_size().columns except OSError: terminal_width = 80 - + aligned_result = self._align_text(result, terminal_width, self.align, max_line_width) + if self.clear: + self._clear() + for line in aligned_result: Write.Print(line + "\n", Colors.red_to_blue, interval=0.000) diff --git a/setup.py b/setup.py index 3c05563..255cd12 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="logmagix", - version="1.0.3", + version="1.0.4", packages=find_packages(), install_requires=["colorama"], author="Sexfrance",