def __init__(self):
QMainWindow.__init__
(self, None
) #, Qt.FramelessWindowHint)
self.setWindowState(Qt.WindowFullScreen)
self.setLayout(self.vL)
#~ self.view.setRenderHint(QPainter.SmoothPixmapTransform, False)
self.view.setScene(self.scene)
self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.vL.addWidget(self.view)
self.
view.
setRenderHints(QPainter.
SmoothPixmapTransform |
QPainter.
Antialiasing) self.view.setSceneRect(0, 0, self.width(), self.height())
self.img_list = glob('img/*.jpg')
self.img_list.extend(glob('img/*.png'))
def keyPressEvent(self, event):
event.accept()
self.disp_image(self.img_list[random.choice(range(len(self.img_list)))])
def disp_image(self, file, position=None):
i = self.scene.addPixmap(pxmap)
i.setTransformOriginPoint(pxmap.width()/2., pxmap.height()/2.)
i.setRotation(10)
i.setPos((.8*random.random()+.1)*self.width()-pxmap.width()/2., (.8*random.random()+.1)*self.height()-pxmap.height()/2.)
self.view.show()
class MainWindow(QWidget):
def __init__(self):
QMainWindow.__init__(self, None) #, Qt.FramelessWindowHint)
self.setWindowState(Qt.WindowFullScreen)
self.vL = QVBoxLayout()
self.setLayout(self.vL)
self.scene = QGraphicsScene()
self.view = QGraphicsView(self)
#~ self.view.setRenderHint(QPainter.SmoothPixmapTransform, False)
self.view.setScene(self.scene)
self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.vL.addWidget(self.view)
self.view.setRenderHints(QPainter.SmoothPixmapTransform | QPainter.Antialiasing)
self.view.setSceneRect(0, 0, self.width(), self.height())
self.img_list = glob('img/*.jpg')
self.img_list.extend(glob('img/*.png'))
def keyPressEvent(self, event):
event.accept()
self.disp_image(self.img_list[random.choice(range(len(self.img_list)))])
def disp_image(self, file, position=None):
pxmap = QPixmap(file)
i = self.scene.addPixmap(pxmap)
i.setTransformOriginPoint(pxmap.width()/2., pxmap.height()/2.)
i.setRotation(10)
i.setPos((.8*random.random()+.1)*self.width()-pxmap.width()/2., (.8*random.random()+.1)*self.height()-pxmap.height()/2.)
self.view.show()
To copy to clipboard, switch view to plain text mode
Bookmarks