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 try: # noinspection PyUnresolvedReferences,PyProtectedMember return Path(sys._MEIPASS).resolve() except AttributeError: return Path().resolve() def get_file(filename): return base_path() / "resources" / filename