import platform import os from module import create_filename from module.MyMessageBox import show_dialog from PySide6.QtWidgets import QMessageBox import subprocess import appdirs def get_path_wkhtmltopdf() -> str: match platform.system(): case 'Linux': result = subprocess.Popen(['whereis wkhtmltopdf'], shell=True, stdout=subprocess.PIPE).stdout.read() return str(result).split(' ')[1] case 'Windows': path_window_programm = "C:\\Program\ Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe" if os.path.exists(path_window_programm): return path_window_programm else: show_dialog(QMessageBox.Icon.Critical, "Не найдено ПО", "Не установлена программа wkhtmltopdf") case _: ... def create_pdf(html_text) -> str: path_to = create_filename('pdf') path_temp_html = os.path.join(appdirs.user_cache_dir(), 'simple.html') with open(path_temp_html, 'w') as file: file.write(html_text) print(F"{get_path_wkhtmltopdf()} {path_temp_html} {path_to}") subprocess.Popen([get_path_wkhtmltopdf(), path_temp_html, path_to]) return path_to def main(): create_pdf('

Hello

') if __name__ == "__main__": main()