Printer.py 424 B

12345678910111213
  1. from PySide6.QtWidgets import QTextEdit, QDialog
  2. from PySide6.QtPrintSupport import QPrintDialog, QPrinter
  3. class Printer:
  4. def __init__(self, text: str) -> None:
  5. self.editor = QTextEdit()
  6. self.editor.setHtml(text)
  7. def print(self) -> None:
  8. dialog = QPrintDialog()
  9. if dialog.exec_() == QDialog.Accepted:
  10. self.editor.document().print_(dialog.printer())