PyQww

PyQww is a Python port (not a set of bindings) of the set of Qt widgets created by Witold Wysota called wwWidgets. These widgets provide some really powerful additional functionality to the abundance that is included with Qt.

This is currently a work in progress, probably unstable and definitely subject to change, but interested parties can browse the source or clone the mercurial repository with the following:

hg clone https://hg.gulon.co.uk/pyqww/

All comments gratefully received.

Downloads

 

Release 0.1 Alpha

This is the first source release for PyQww. It contains a tentative implementation of each of the widgets found in wwWidgets. At this time there are no formal tests or documentation.

The source can be downloaded below:

Installation is achieved in the standard distutils manner:

python setup.py install

The package depends only on PyQt4 available from here. To date, the widgets have been tested with the following configuration:

  • Mac OSX 10.8.2 Mountain Lion
  • Python 2.7.2
  • PyQt4 4.9.5

However, the package is not OS dependent and should function with any PyQt4 configuration. Testing with Windows and Linux systems will follow shortly.

Usage is also relatively simple. Each widget is contained within a single source file, many of which are runnable and serve as examples of sorts. Otherwise, widgets are imported from the PyQww namespace. The API is essentially the same as for the original C++ widgets.

The following is an example of QwwListWidget and QwwListNavigator:

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

from PyQww import *

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

        l=QVBoxLayout(self)

        wl=QHBoxLayout()

        self._listWidget=QwwListWidget(self)
        self._listWidget.addItems(['A', 'B', 'C', 'D'])
        wl.addWidget(self._listWidget)

        self._nav=QwwListNavigator(self)
        self._nav.setOrientation(Qt.Vertical)
        self._nav.setListWidget(self._listWidget)
        wl.addWidget(self._nav)

        l.addLayout(wl)

        add=QToolButton(self, clicked=self.addItem)
        add.setText('Add')

        rem=QToolButton(self, clicked=self._listWidget.removeCurrent)
        rem.setText('Remove')

        up=QToolButton(self, clicked=self._listWidget.moveCurrentUp)
        up.setText('Up')

        down=QToolButton(self, clicked=self._listWidget.moveCurrentDown)
        down.setText('Down')

        hlayout=QHBoxLayout()
        hlayout.addWidget(add)
        hlayout.addWidget(rem)
        hlayout.addStretch()
        hlayout.addWidget(up)
        hlayout.addWidget(down)

        l.addLayout(hlayout)

        self._listWidget.currentAvailable.connect(lambda enabled: rem.setEnabled(enabled))
        self._listWidget.moveUpAvailable.connect(lambda avail: up.setEnabled(avail))
        self._listWidget.moveDownAvailable.connect(lambda avail: down.setEnabled(avail))

        self._listWidget.setCurrentRow(0)

    def addItem(self):
        i,ok=QInputDialog.getText(self, 'Add item', 'Enter item text')
        if not ok: return

        self._listWidget.addItem(i)
        self._listWidget.setCurrentRow(self._listWidget.count()-1)

if __name__=='__main__':
    from sys import argv, exit
    a=QApplication(argv)
    w=Widget()
    w.show()
    w.raise_()
    exit(a.exec_())

List Widget Example

List Widget Example

Leave a Reply

Your email address will not be published. Required fields are marked *