RkBlog

Hardware, programming and astronomy tutorials and reviews.

PictureFlow - listing images in PyQt4

PictureFlow - extra PyQt4 widget

PictureFlow is a Qt4 (and PyQt4) widget that allows "awesome" listing of images. PyQt4 bindings are only available in the SVN code (download tar.gz snapshot) that you can get from:
svn export http://pictureflow.googlecode.com/svn/trunk/ pictureflow
To compile and install PictureFlow use: After installing the widget you can test it with this example script:
import sys
from os import listdir

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from pictureflow import *

app = QApplication(sys.argv)

w = PictureFlow()

images = listdir('/path/to/folder/with/images/')
for i in images:
	if i.endswith('jpg'):
		w.addSlide(QPixmap('/path/to/folder/with/images/%s' % i))
w.show()

sys.exit(app.exec_())
Here is sample result:
pictureflow

PictureFlow class

Below is the PictureFlow class definition for SIP:
public:

  enum ReflectionEffect
  {
    NoReflection,
    PlainReflection,
    BlurredReflection
  };

  PictureFlow(QWidget *parent /TransferThis/ = 0);
  ~PictureFlow();
  QColor backgroundColor() const;
  void setBackgroundColor(const QColor& c);
  QSize slideSize() const;
  void setSlideSize(QSize size);
  int slideCount() const;
  QImage slide(int index) const;
  int centerIndex() const;
  ReflectionEffect reflectionEffect() const;
  void setReflectionEffect(ReflectionEffect effect);

public slots:
  void addSlide(const QImage& image);
  void addSlide(const QPixmap& pixmap);
  void setSlide(int index, const QImage& image);
  void setSlide(int index, const QPixmap& pixmap);
  void setCenterIndex(int index);
  void clear();
  void showPrevious();
  void showNext();
  void showSlide(int index);
  void render();
  void triggerRender();

signals:
  void centerIndexChanged(int index);

protected:
  void paintEvent(QPaintEvent *event);
  void keyPressEvent(QKeyEvent* event);
  void mousePressEvent(QMouseEvent* event);
  void resizeEvent(QResizeEvent* event);
RkBlog

PyQt and GUI, 17 April 2009,

Comment article