[+] wrap_text

[+] auto X-Y
This commit is contained in:
2025-03-20 14:46:57 +03:00
parent 34ca830c5e
commit df69a6cfdd
3 changed files with 49 additions and 8 deletions

View File

@@ -1,3 +1,3 @@
from . import fonts
from .params import Strings, Icons
from .utils import base_path, get_file
from .utils import base_path, get_file, wrap_text

View File

@@ -1,6 +1,26 @@
import sys
from pathlib import Path
def wrap_text(text, max_width, char_width=7):
words = text.split()
lines = []
current_line = []
current_width = 0
for word in words:
word_width = len(word) * char_width
if current_width + word_width + char_width > max_width:
lines.append(" ".join(current_line))
current_line = [word]
current_width = word_width
else:
current_line.append(word)
current_width += word_width + char_width # Добавляем пробел
if current_line:
lines.append(" ".join(current_line))
return lines
def base_path():
# PyInstaller creates a temp folder and stores path in _MEIPASS