Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PySide2 import QtCore
- from PySide2 import QtWidgets, QtGui
- class QMyQLabel(QtWidgets.QLabel):
- # def __init__(self, parent=None):
- # QtWidgets.QLabel.__init__(self, parent)
- # self.image_path = -1
- def mousePressEvent(self, event):
- print self.image_path
- class FontDemo(QtWidgets.QWidget):
- def __init__(self, parent=None):
- super(FontDemo, self).__init__()
- self.setGeometry(QtGui.QCursor.pos().x(), QtGui.QCursor.pos().y(), 900, 800)
- self.setWindowTitle('Font Demo')
- self.widget_layout = QtWidgets.QGridLayout(self)
- self.scrollarea = QtWidgets.QScrollArea()
- self.scrollarea.setWidgetResizable(True)
- self.widget_layout.addWidget(self.scrollarea)
- self.widget = QtWidgets.QWidget()
- self.layout = QtWidgets.QGridLayout(self.widget)
- self.scrollarea.setWidget(self.widget)
- #self.layout.setAlignment(QtCore.Qt.AlignHCenter)
- # Label images
- for i in range(0, 100):
- label2 = QMyQLabel(self)
- test_path = 'C:/Users/mifth/Desktop/tmp/tmp1.png'
- label2.image_path = test_path
- label2.resize(800, 800)
- pixmap = QtGui.QPixmap(test_path)
- pixmap2 = pixmap.scaled(100, 100)
- label2.setPixmap(pixmap2)
- self.layout.addWidget(label2, i/7, (i%7))
- self.setParent(hou.ui.mainQtWindow(), QtCore.Qt.Window)
- self.setLayout(self.layout)
- dialog = FontDemo()
- dialog.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement