Graphics/PixmapDiagram.py

branch
Py2 comp.
changeset 3058
0a02c433f52d
parent 3057
10516539f238
parent 3022
57179e4cdadd
child 3060
5883ce99ee12
equal deleted inserted replaced
3057:10516539f238 3058:0a02c433f52d
149 @param filename name of the file to be shown (string) 149 @param filename name of the file to be shown (string)
150 @return flag indicating success (boolean) 150 @return flag indicating success (boolean)
151 """ 151 """
152 image = QImage(filename) 152 image = QImage(filename)
153 if image.isNull(): 153 if image.isNull():
154 E5MessageBox.warning(self, 154 E5MessageBox.warning(
155 self,
155 self.trUtf8("Pixmap-Viewer"), 156 self.trUtf8("Pixmap-Viewer"),
156 self.trUtf8("""<p>The file <b>{0}</b> cannot be displayed.""" 157 self.trUtf8(
158 """<p>The file <b>{0}</b> cannot be displayed."""
157 """ The format is not supported.</p>""").format(filename)) 159 """ The format is not supported.</p>""").format(filename))
158 return False 160 return False
159 161
160 self.pixmapLabel.setPixmap(QPixmap.fromImage(image)) 162 self.pixmapLabel.setPixmap(QPixmap.fromImage(image))
161 self.pixmapLabel.adjustSize() 163 self.pixmapLabel.adjustSize()
380 s = self.trUtf8("Diagram: {0}").format(self.getDiagramName()) 382 s = self.trUtf8("Diagram: {0}").format(self.getDiagramName())
381 tc = QColor(50, 50, 50) 383 tc = QColor(50, 50, 50)
382 painter.setPen(tc) 384 painter.setPen(tc)
383 painter.drawRect(marginX, marginY, width, height) 385 painter.drawRect(marginX, marginY, width, height)
384 painter.drawLine(marginX, marginY + height + 2, 386 painter.drawLine(marginX, marginY + height + 2,
385 marginX + width, marginY + height + 2) 387 marginX + width, marginY + height + 2)
386 painter.setFont(font) 388 painter.setFont(font)
387 painter.drawText(marginX, marginY + height + 4, width, 389 painter.drawText(marginX, marginY + height + 4, width,
388 fontHeight, Qt.AlignRight, s) 390 fontHeight, Qt.AlignRight, s)
389 391
390 # render the diagram 392 # render the diagram
391 size = self.pixmapLabel.pixmap().size() 393 size = self.pixmapLabel.pixmap().size()
392 size.scale(QSize(width - 10, height - 10), # 5 px inner margin 394 size.scale(QSize(width - 10, height - 10), # 5 px inner margin
393 Qt.KeepAspectRatio) 395 Qt.KeepAspectRatio)
394 painter.setViewport(marginX + 5, marginY + 5, 396 painter.setViewport(marginX + 5, marginY + 5,
395 size.width(), size.height()) 397 size.width(), size.height())
396 painter.setWindow(self.pixmapLabel.pixmap().rect()) 398 painter.setWindow(self.pixmapLabel.pixmap().rect())
397 painter.drawPixmap(0, 0, self.pixmapLabel.pixmap()) 399 painter.drawPixmap(0, 0, self.pixmapLabel.pixmap())
398 painter.end() 400 painter.end()

eric ide

mercurial