Help! Python 2.0 and PyQt 2.1 not Printing on Windows
Coy Krill
ckrill at qvlinc.com
Thu Oct 19 14:22:58 EDT 2000
This program seems to work just fine on Linux but segfaults on Win98 in
the Qt 2.2.1 dll. Anyone know if printing needs some extra setup on
Windows?
#!/usr/bin/env python
import sys
from qt import *
class DrawWidget(QWidget):
def __init__(self):
QWidget.__init__(self)
self.setCaption("Drawing Test")
self.setBackgroundColor(Qt.white)
self.resize(800,600)
self.printer = QPrinter()
self.x = 1
def drawIt(self,painter = None):
painter.drawRect(30,15,500,500)
painter.drawText(40,40,"THIS IS TEST TEXT")
def paintEvent(self,paintEvent):
paint =QPainter(self)
self.drawIt(paint)
if self.x == 1:
self.x = 2
self.printer.setPageSize(QPrinter.Letter)
self.printer.setOrientation(QPrinter.Portrait)
if self.printer.setup(self):
paint2 =QPainter(self.printer)
self.drawIt(paint2)
if __name__ == "__main__":
app = QApplication(sys.argv)
widget = DrawWidget()
app.setMainWidget(widget)
widget.show()
app.connect(app,SIGNAL('lastWindowClosed()'),app,SLOT('quit()'))
app.exec_loop()
More information about the Python-list
mailing list