[+] wrap_text
[+] auto X-Y
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user