本文整理汇总了Python中canvas.Canvas.routeCanvasToScreen方法的典型用法代码示例。如果您正苦于以下问题:Python Canvas.routeCanvasToScreen方法的具体用法?Python Canvas.routeCanvasToScreen怎么用?Python Canvas.routeCanvasToScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类canvas.Canvas
的用法示例。
在下文中一共展示了Canvas.routeCanvasToScreen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PreviewArea
# 需要导入模块: from canvas import Canvas [as 别名]
# 或者: from canvas.Canvas import routeCanvasToScreen [as 别名]
#.........这里部分代码省略.........
#preview_pixmap = QtGui.QPixmap(self.generatePreview())
#pixmap_scaled = preview_pixmap.scaled(label.size(), QtCore.Qt.KeepAspectRatio)
#label.setPixmap(pixmap_scaled)
#label.clicked.connect(lambda: self.imageToCanvas(pixmap))
#self.layout.addWidget(label, 0, 0)
#self.destroyBeamerWindow()
def generatePreviewsForImagePathList(self, image_path_list):
self.images_list = image_path_list
preview_pixmap_list = []
for image in image_path_list:
pixmap = QtGui.QPixmap(image)
self.canvas = Canvas(self.screen)
self.canvas.showImage(pixmap)
preview_pixmap = QtGui.QPixmap()
preview_pixmap = QtGui.QPixmap(self.generatePreview())
preview_pixmap_list.append(preview_pixmap)
self.showPreviews(preview_pixmap_list, image_path_list)
def showPreviews(self, preview_pixmap_list, images_list):
label_list = []
for i, pixmap in enumerate(preview_pixmap_list):
label = ClickLabel(self)
#preview_width = PREVIEW_WIDTH
#preview_width = self.parentQScrollArea.viewportSize().width()
preview_width = self.parentQScrollArea.viewport().width()
preview_height = PREVIEW_HEIGHT
label.resize(QtCore.QSize(preview_width, preview_height))
pixmap_scaled = pixmap.scaled(label.size(), QtCore.Qt.KeepAspectRatio)
label.setPixmap(pixmap_scaled)
label.setPixmapPath(images_list[i])
label.name_id = i
original_pixmap = QtGui.QPixmap(images_list[i])
#label.clicked.connect(lambda: self.imageToCanvas(original_pixmap))
label.clicked.connect(self.imageToCanvas)
label_list.append(label)
for i, label in enumerate(label_list):
x = int(i / self.column_count)
y = i % self.column_count
self.layout.addWidget(label, x, y)
def generatePreview(self):
return self.canvas.getPreviewImage()
def imageToCanvas(self, id):
self.current_id = id
print("CURRENT ID: ", id)
pixmap = QtGui.QPixmap(self.images_list[id])
self.canvas = Canvas(self.screen)
#self.canvas.setScreen(self.config.getBeamerScreen())
self.canvas.showImage(pixmap)
self.canvas.routeCanvasToScreen()
self.connectCanvas()
def destroyBeamerWindow(self):
self.canvas.destroy(True, True)
self.canvas = None
def connectCanvas(self):
self.canvas.beam_prev.connect(self.beamPrev)
self.canvas.beam_next.connect(self.beamNext)
def closeEvent(self, event):
self.destroyBeamerWindow()
def beamNext(self):
next_id = self.current_id + 1
if next_id >= len(self.images_list):
next_id = len(self.images_list)-1
self.imageToCanvas(next_id)
def beamPrev(self):
next_id = self.current_id - 1
if next_id < 0:
next_id = 0
self.imageToCanvas(next_id)
def keyPressEvent(self, e):
if e.key() == QtCore.Qt.Key_Escape:
self.destroyBeamerWindow()
elif e.key() == QtCore.Qt.Key_Left:
self.beamPrev()
elif e.key() == QtCore.Qt.Key_Right:
self.beamNext()