File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed
sportorg/modules/printing Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change 33import time
44from multiprocessing import Process , Queue
55
6+ qt_version = 5
67try :
78 from PySide6 .QtCore import QMarginsF , QSizeF
89 from PySide6 .QtGui import QPageLayout , QTextDocument
910 from PySide6 .QtPrintSupport import QPrinter
1011 from PySide6 .QtWidgets import QApplication
12+
13+ qt_version = 6
1114except ModuleNotFoundError :
1215 from PySide2 .QtCore import QMarginsF , QSizeF
1316 from PySide2 .QtGui import QPageLayout , QTextDocument
@@ -68,15 +71,24 @@ def run(self):
6871 text_document = QTextDocument ()
6972
7073 printer .setFullPage (True )
71- printer . setPageMargins (
72- QMarginsF (
74+ if qt_version == 5 :
75+ printer . setPageMargins (
7376 self .margin_left ,
7477 self .margin_top ,
7578 self .margin_right ,
7679 self .margin_bottom ,
77- ),
78- QPageLayout .Unit .Millimeter ,
79- )
80+ QPrinter .Unit .Millimeter ,
81+ )
82+ else :
83+ printer .setPageMargins (
84+ QMarginsF (
85+ self .margin_left ,
86+ self .margin_top ,
87+ self .margin_right ,
88+ self .margin_bottom ,
89+ ),
90+ QPageLayout .Unit .Millimeter ,
91+ )
8092
8193 page_size = QSizeF ()
8294 page_size .setHeight (printer .height ())
@@ -119,7 +131,7 @@ def run(self):
119131 )
120132 )
121133 except Exception as e :
122- logging .error ( str ( e ) )
134+ logging .exception ( e )
123135
124136
125137def print_html (
You can’t perform that action at this time.
0 commit comments