当前位置: 首页>>代码示例>>Python>>正文


Python Canvas.showImage方法代码示例

本文整理汇总了Python中canvas.Canvas.showImage方法的典型用法代码示例。如果您正苦于以下问题:Python Canvas.showImage方法的具体用法?Python Canvas.showImage怎么用?Python Canvas.showImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在canvas.Canvas的用法示例。


在下文中一共展示了Canvas.showImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PreviewArea

# 需要导入模块: from canvas import Canvas [as 别名]
# 或者: from canvas.Canvas import showImage [as 别名]
class PreviewArea(QtWidgets.QWidget):
    def __init__(self, parentQScrollArea, beamer_screen):
        QtWidgets.QWidget.__init__(self)
        
        self.parentQScrollArea = parentQScrollArea
        
        self.layout = QtWidgets.QGridLayout()
        self.setLayout(self.layout)
        
        self.current_id = None
        
        self.setStyleSheet('QWidget { background-color: yellow; }')
        
        self.config = Config()
        #self.screen = self.config.getBeamerScreen()
        self.screen = beamer_screen
        self.column_count = self.config.getPreviewColumnCount()
        
        #self.aspect_ratio = self.getBeamerWindowAspect()
        
        self.canvas = None
        
        #self.alertAlreadyShown = False
        
#        print("##########")
#        print(self.width(), self.height())
#        print(self.sizeHint())
#        print(self.size())
#        print("##########")

#        images_list = ["./testimages/facepalm0.jpg",
#                       "./testimages/facepalm00.jpg",
#                       "./testimages/facepalm1.jpg",
#                       "./testimages/facepalm2.jpg",
#                       "./testimages/facepalm3.jpg"]
        #self.showPreviewWithoutWindow()
        
        #self.generatePreviewsForImagePathList(images_list)
        
    #def showPreviewWithoutWindow(self):
        #label = ClickLabel(self)
        #label.resize(QtCore.QSize(PREVIEW_WIDTH, PREVIEW_HEIGHT))
        ##label.setGeometry(QtCore.QRect(0, 0, 400, 400))
        
        #label.setStyleSheet('QLabel { background-color: red; }')
        
        #self.canvas = Canvas()
        ##self.canvas.showImage("./testimages/facepalm0.jpg")
        #pixmap = QtGui.QPixmap("./testimages/facepalm0.jpg")
        
        #self.canvas.showImage(pixmap)
        ##self.canvas.routeCanvasToScreen()
        #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)
#.........这里部分代码省略.........
开发者ID:beckers,项目名称:musicbeamer,代码行数:103,代码来源:preview_area.py


注:本文中的canvas.Canvas.showImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。