Printing QWidget window using python
-
@khakhil
HI
you will need a way to select real printer
then load the image from file
and draw onto a painter connected to the selected printer.try to play around with this sample
http://stackoverflow.com/questions/8193920/print-a-text-through-a-printer-using-pyqt4
its with preview and all so maybe over the tophere is c++ function that grabs screenshot and print it.
(thx to @Ni-Sumi)void MainWindow::printPage() { QPixmap pix = QPixmap::grabWindow(QApplication::desktop()->winId()); QPrinter printer(QPrinter::HighResolution); printer.setOrientation(QPrinter::Landscape); QPainter painter; painter.begin(&printer); double xscale = printer.pageRect().width() / double(pix.width()); double yscale = printer.pageRect().height() / double(pix.height()); double scale = qMin(xscale, yscale); painter.translate(printer.paperRect().x() + printer.pageRect().width() / 2, printer.paperRect().y() + printer.pageRect().height() / 2); painter.scale(scale, scale); painter.translate(-width() / 2, -height() / 2); painter.drawPixmap(0, 0, pix); painter.end(); }
I assume u can read enough to translate to py. :)