Need to implement Print Dialog Box
-
wrote on 7 Feb 2018, 06:42 last edited by
Hi,
I need to implement a Print Dialog box which on clicking a button will pop up and ask for printer configuration. How can I do it in Python? -
Hi,
I need to implement a Print Dialog box which on clicking a button will pop up and ask for printer configuration. How can I do it in Python?@Piyush Did you check http://doc.qt.io/qt-5/qprintdialog.html?
-
Hi,
I need to implement a Print Dialog box which on clicking a button will pop up and ask for printer configuration. How can I do it in Python? -
wrote on 7 Feb 2018, 10:47 last edited by
@JonB Hi,
I am using the following code. But I am getting print in small size i.e. the whole widget is coming in smaller area of the page.
def print_widget(self): printer = QtPrintSupport.QPrinter() setupdialog = QPrintDialog(printer,self) if setupdialog.exec_() == QPrintDialog.Accepted: painter = QtGui.QPainter(self) painter.begin(printer) point = QtCore.QPoint(0,0) screen = self.grab() self.pixmap = QtGui.QPixmap(screen) scaledPix = self.pixmap.scaled(1100,950,Qt.KeepAspectRatio,transformMode = Qt.SmoothTransformation) point.setX(0) point.setY(0) painter.drawPixmap(point, scaledPix) painter.end()
-
@JonB Hi,
I am using the following code. But I am getting print in small size i.e. the whole widget is coming in smaller area of the page.
def print_widget(self): printer = QtPrintSupport.QPrinter() setupdialog = QPrintDialog(printer,self) if setupdialog.exec_() == QPrintDialog.Accepted: painter = QtGui.QPainter(self) painter.begin(printer) point = QtCore.QPoint(0,0) screen = self.grab() self.pixmap = QtGui.QPixmap(screen) scaledPix = self.pixmap.scaled(1100,950,Qt.KeepAspectRatio,transformMode = Qt.SmoothTransformation) point.setX(0) point.setY(0) painter.drawPixmap(point, scaledPix) painter.end()
-
@JonB Hi,
I am using the following code. But I am getting print in small size i.e. the whole widget is coming in smaller area of the page.
def print_widget(self): printer = QtPrintSupport.QPrinter() setupdialog = QPrintDialog(printer,self) if setupdialog.exec_() == QPrintDialog.Accepted: painter = QtGui.QPainter(self) painter.begin(printer) point = QtCore.QPoint(0,0) screen = self.grab() self.pixmap = QtGui.QPixmap(screen) scaledPix = self.pixmap.scaled(1100,950,Qt.KeepAspectRatio,transformMode = Qt.SmoothTransformation) point.setX(0) point.setY(0) painter.drawPixmap(point, scaledPix) painter.end()
@Piyush said in Need to implement Print Dialog Box:
self.pixmap.scaled
Did you try other sizes for scaled()?
-
@JonB Hi,
I am using the following code. But I am getting print in small size i.e. the whole widget is coming in smaller area of the page.
def print_widget(self): printer = QtPrintSupport.QPrinter() setupdialog = QPrintDialog(printer,self) if setupdialog.exec_() == QPrintDialog.Accepted: painter = QtGui.QPainter(self) painter.begin(printer) point = QtCore.QPoint(0,0) screen = self.grab() self.pixmap = QtGui.QPixmap(screen) scaledPix = self.pixmap.scaled(1100,950,Qt.KeepAspectRatio,transformMode = Qt.SmoothTransformation) point.setX(0) point.setY(0) painter.drawPixmap(point, scaledPix) painter.end()
@Piyush
Hi
Its the same as here
https://forum.qt.io/topic/87293/how-to-print-the-current-tab-on-pressing-a-push-buttonScreen is normally maybe 1920x1080 pixels
where as printer might
be 9000 x 9000 pixelsSo if you have an image of 200x200
on screen it look ok big.But if you print it. then 200 pixels out of 9000 looks like the size
of a stamp.
1/7