better regex for desc

This commit is contained in:
faroukbmiled 2023-09-23 13:41:27 +01:00
parent 3f13a5f0b3
commit 75f793ec60
2 changed files with 8 additions and 4 deletions

View File

@ -646,8 +646,10 @@ class LibraryTab(ctk.CTkScrollableFrame):
name_label.grid(row=0, column=0, columnspan=2, sticky="w", padx=20, pady=5)
desc_threshold = 30
shortened_description = f"{description[:desc_threshold]}... (View)" if len(description) > desc_threshold else description
shortened_description = re.sub(r'\n', '', shortened_description).strip()
shortened_description = re.sub(r'\n', '', description).strip()
shortened_description = re.sub(r'([^a-zA-Z0-9\s:().])', '', shortened_description)
shortened_description = f"{shortened_description[:desc_threshold]}... (View)"\
if len(shortened_description) > desc_threshold else shortened_description
description_lab = ctk.CTkLabel(info_frame, text=f"Description: {shortened_description}")
description_lab.grid(row=1, column=0, columnspan=2, sticky="w", padx=20, pady=5)
if len(description) > desc_threshold:

View File

@ -706,8 +706,10 @@ class BOIIIWD(ctk.CTk):
name_label.grid(row=0, column=0, columnspan=2, sticky="w", padx=20, pady=5)
desc_threshold = 30
shortened_description = f"{description[:desc_threshold]}... (View)" if len(description) > desc_threshold else description
shortened_description = re.sub(r'\n', '', shortened_description).strip()
shortened_description = re.sub(r'\n', '', description).strip()
shortened_description = re.sub(r'([^a-zA-Z0-9\s:().])', '', shortened_description)
shortened_description = f"{shortened_description[:desc_threshold]}... (View)"\
if len(shortened_description) > desc_threshold else shortened_description
description_lab = ctk.CTkLabel(info_frame, text=f"Description: {shortened_description}")
description_lab.grid(row=1, column=0, columnspan=2, sticky="w", padx=20, pady=5)
if len(description) > desc_threshold: