Start New Discussion within our Software Development Community

Just a simple image file slide show using PySide (PyQT).

''' ps_Image_slides101.py
A simple slide show using PySide (PyQT)

PySide is the official LGPL-licensed version of PyQT
I downloaded and used the Windows self-extracting installers
for Python27:
PySide-1.2.1.win32-py2.7.exe
for Python33:
PySide-1.2.1.win32-py3.3.exe
from:
http://qt-project.org/wiki/PySide_Binaries_Windows

tested with PySide121 and Python27/33  by  vegaseat  18nov2013
'''

from PySide.QtCore import *
from PySide.QtGui import *

class Slides(QWidget):
    def __init__(self, image_files, parent=None):
        QWidget.__init__(self, parent)
        self.image_files = image_files

        s = '<>'*300
        self.label = QLabel(s, self)
        self.label.setGeometry(10, 30, 640, 480)

        self.button = QPushButton("Start Slide Show",self)
        self.button.setGeometry(10, 10, 140, 30)
        self.button.clicked.connect(self.timerEvent)

        self.timer = QBasicTimer()
        self.step = 0
        self.delay = 5000  # milliseconds

        sf = "Slides are shown {} seconds apart"
        self.setWindowTitle(sf.format(self.delay/1000.0))

    def timerEvent(self, e=None):
        if self.step >= len(self.image_files):
            self.timer.stop()
            self.button.setText('Slide Show Finished')
            return
        self.timer.start(self.delay, self)
        file = self.image_files[self.step]
        image = QPixmap(file)
        self.label.setPixmap(image)
        self.setWindowTitle("{} --> {}".format(str(self.step), file))
        self.step += 1


# pick image files you have in the working folder
# or give full path name
image_files = [
"Beach1.jpg",
"Beach2.jpg",
"Beach3.jpg",
"Beach4.jpg",
"Beach5.jpg"
]

app = QApplication([])
w = Slides(image_files)
# setGeometry(x, y, w, h)  x,y = upper left corner coordinates
w.setGeometry(100, 100, 700, 500)
w.show()
app.exec_()
The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.